Class Property

java.lang.Object
org.apache.tika.metadata.Property
All Implemented Interfaces:
Comparable<Property>

public final class Property extends Object implements Comparable<Property>
XMP property definition. Each instance of this class defines a single metadata property like "dc:format". In addition to the property name, the value type and category (internal or external) of the property are included in the property definition. The available choice values are also stored for open and closed choice value types.

Every public factory method below throws IllegalArgumentException if name is in the reserved Tika-native namespace (tk:/X-TIKA:); see ReservedNamespaces.

The public factories intern every Property in a static, JVM-global registry, permanently (first-wins: a name collision keeps the earlier registration and WARNs on a shape mismatch). They are for declaration-time constants — a bounded population. Never feed them runtime, per-document, or user-supplied names: each distinct name grows the registry forever, and a collision can shadow a curated constant JVM-wide. Document-derived names go through Metadata.add(KeyPrefix, String, String) with no Property at all.

Since:
Apache Tika 0.7
  • Method Details

    • getPropertyType

      public static Property.PropertyType getPropertyType(String key)
      Get the type of a property
      Parameters:
      key - name of the property
      Returns:
      the type of the property
    • get

      public static Property get(String key)
      Retrieve the property object that corresponds to the given key. Only registered Properties resolve here: document-derived keys (written via Metadata.add(KeyPrefix, String, String) or minted through Property#mintUnregistered) are never interned, so this always returns null for them, even after a write. This is load-bearing for Metadata.reconstruct(java.lang.String, java.lang.String, boolean), which falls back to the trusted String path when lookup misses.
      Parameters:
      key - the property key or name
      Returns:
      the Property object, or null if unregistered
    • getProperties

      public static SortedSet<Property> getProperties(String prefix)
      Like get(String), registered Properties only: never returns a KeyPrefix-minted Property.
    • internalBoolean

      public static Property internalBoolean(String name)
    • internalClosedChoice

      public static Property internalClosedChoice(String name, String... choices)
    • internalDate

      public static Property internalDate(String name)
    • internalDateBag

      public static Property internalDateBag(String name)
    • internalInteger

      public static Property internalInteger(String name)
    • internalIntegerSequence

      public static Property internalIntegerSequence(String name)
    • internalRational

      public static Property internalRational(String name)
    • internalOpenChoice

      public static Property internalOpenChoice(String name, String... choices)
    • internalReal

      public static Property internalReal(String name)
    • internalText

      public static Property internalText(String name)
    • internalTextBag

      public static Property internalTextBag(String name)
    • internalURI

      public static Property internalURI(String name)
    • externalClosedChoice

      public static Property externalClosedChoice(String name, String... choices)
    • externalOpenChoice

      public static Property externalOpenChoice(String name, String... choices)
    • externalDate

      public static Property externalDate(String name)
    • externalReal

      public static Property externalReal(String name)
    • externalRealSeq

      public static Property externalRealSeq(String name)
    • externalIntegerSequence

      public static Property externalIntegerSequence(String name)
    • externalInteger

      public static Property externalInteger(String name)
    • externalBoolean

      public static Property externalBoolean(String name)
    • externalBooleanSeq

      public static Property externalBooleanSeq(String name)
    • externalText

      public static Property externalText(String name)
    • externalTextBag

      public static Property externalTextBag(String name)
    • composite

      public static Property composite(Property primaryProperty, Property[] secondaryExtractProperties)
      Constructs a new composite property from the given primary and array of secondary properties.

      Note that name of the composite property is taken from its primary property, and primary and secondary properties must not be composite properties themselves.

      No reserved-name check here: primaryProperty was already validated at its own mint.

      Parameters:
      primaryProperty -
      secondaryExtractProperties -
      Returns:
      the composite property
    • getName

      public String getName()
    • isInternal

      public boolean isInternal()
    • isExternal

      public boolean isExternal()
    • isMultiValuePermitted

      public boolean isMultiValuePermitted()
      Is the PropertyType one which accepts multiple values?
    • getPropertyType

      public Property.PropertyType getPropertyType()
    • getValueType

      public Property.ValueType getValueType()
    • getChoices

      public Set<String> getChoices()
      Returns the (immutable) set of choices for the values of this property. Only defined for open and closed choice value types.
      Returns:
      available choices, or null
    • getPrimaryProperty

      public Property getPrimaryProperty()
      Gets the primary property for a composite property
      Returns:
      the primary property
    • getSecondaryExtractProperties

      public Property[] getSecondaryExtractProperties()
      Gets the secondary properties for a composite property
      Returns:
      the secondary properties
    • compareTo

      public int compareTo(Property o)
      Specified by:
      compareTo in interface Comparable<Property>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      The property name, so a String→Property constant flip doesn't turn existing logging/concatenation into Property@<hex> with no compile signal.
      Overrides:
      toString in class Object