Package org.apache.tika.xmp
Class XMPMetadata
- java.lang.Object
- 
- org.apache.tika.metadata.Metadata
- 
- org.apache.tika.xmp.XMPMetadata
 
 
- 
- All Implemented Interfaces:
- Serializable,- ClimateForcast,- CreativeCommons,- Geographic,- HttpHeaders,- Message,- TIFF,- TikaMimeKeys
 
 public class XMPMetadata extends Metadata Provides a conversion of the Metadata map from Tika to the XMP data model by also providing the Metadata API for clients to ease transition. But clients can also work directly on the XMP data model, by getting the XMPMeta reference from this class. Usually the instance would be initialized by providing the Metadata object that had been returned from Tika-core which populates the XMP data model with all properties that can be converted.This class is not serializable! - See Also:
- Serialized Form
 
- 
- 
Field Summary- 
Fields inherited from interface org.apache.tika.metadata.ClimateForcastACKNOWLEDGEMENT, COMMAND_LINE, COMMENT, CONTACT, CONVENTIONS, EXPERIMENT_ID, HISTORY, INSTITUTION, MODEL_NAME_ENGLISH, PROGRAM_ID, PROJECT_ID, REALIZATION, REFERENCES, SOURCE, TABLE_ID
 - 
Fields inherited from interface org.apache.tika.metadata.CreativeCommonsLICENSE_LOCATION, LICENSE_URL, WORK_TYPE
 - 
Fields inherited from interface org.apache.tika.metadata.GeographicALTITUDE, LATITUDE, LONGITUDE
 - 
Fields inherited from interface org.apache.tika.metadata.HttpHeadersCONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_TYPE, LOCATION
 - 
Fields inherited from interface org.apache.tika.metadata.MessageMESSAGE_BCC, MESSAGE_BCC_DISPLAY_NAME, MESSAGE_BCC_EMAIL, MESSAGE_BCC_NAME, MESSAGE_CC, MESSAGE_CC_DISPLAY_NAME, MESSAGE_CC_EMAIL, MESSAGE_CC_NAME, MESSAGE_FROM, MESSAGE_FROM_EMAIL, MESSAGE_FROM_NAME, MESSAGE_PREFIX, MESSAGE_RAW_HEADER_PREFIX, MESSAGE_RECIPIENT_ADDRESS, MESSAGE_TO, MESSAGE_TO_DISPLAY_NAME, MESSAGE_TO_EMAIL, MESSAGE_TO_NAME, MULTIPART_BOUNDARY, MULTIPART_SUBTYPE
 - 
Fields inherited from interface org.apache.tika.metadata.TIFFBITS_PER_SAMPLE, EQUIPMENT_MAKE, EQUIPMENT_MODEL, EXIF_PAGE_COUNT, EXPOSURE_TIME, F_NUMBER, FLASH_FIRED, FOCAL_LENGTH, IMAGE_LENGTH, IMAGE_WIDTH, ISO_SPEED_RATINGS, ORIENTATION, ORIGINAL_DATE, RESOLUTION_HORIZONTAL, RESOLUTION_UNIT, RESOLUTION_VERTICAL, SAMPLES_PER_PIXEL, SOFTWARE
 - 
Fields inherited from interface org.apache.tika.metadata.TikaMimeKeysMIME_TYPE_MAGIC, TIKA_MIME_FILE
 
- 
 - 
Constructor SummaryConstructors Constructor Description XMPMetadata()Initializes with an empty XMP packetXMPMetadata(Metadata meta)XMPMetadata(Metadata meta, String mimetype)Initializes the data by converting the Metadata information to XMP.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String name, String value)As this API could only possibly work for simple properties in XMP, it just calls the set method, which replaces any existing valuestatic voiddeleteNamespace(String namespaceURI)Deletes a namespace from the registry.booleanequals(Object o)This method is not implemented, yet.Stringget(String name)Returns the value of a simple property or the first one of an array.Stringget(Property property)Returns the value (if any) of the identified metadata property.DategetDate(Property property)Returns the value of the identified Date based metadata property.IntegergetInt(Property property)Returns the value of the identified Integer based metadata property.static StringgetNamespacePrefix(String namespaceURI)Obtain the prefix for a registered namespace URI.static Map<String,String>getNamespaces()static StringgetNamespaceURI(String namespacePrefix)Obtain the URI for a registered namespace prefix.static Map<String,String>getPrefixes()String[]getValues(String name)Returns the value of a simple property or all if the property is an array and the elements are of simple type.String[]getValues(Property property)Get the values associated to a metadata name.com.adobe.internal.xmp.XMPMetagetXMPData()Provides direct access to the XMP data model, in case a client prefers to work directly on it instead of using the Metadata APIinthashCode()booleanisMultiValued(String name)Checks if the named property is an array.booleanisMultiValued(Property property)Returns true if named value is multivalued.String[]names()For XMP it is not clear what that API should return, therefor not implementedvoidprocess(Metadata meta)voidprocess(Metadata meta, String mimetype)Converts the Metadata information to XMP.static StringregisterNamespace(String namespaceURI, String suggestedPrefix)Register a namespace URI with a suggested prefix.voidremove(String name)Removes the given property from the XMP data.voidremove(Property property)voidset(String name, String value)Sets the given property.voidset(Property property, double value)Sets the real or rational value of the identified metadata property.voidset(Property property, int value)Sets the integer value of the identified metadata property.voidset(Property property, String value)Sets the value of the identified metadata property.voidset(Property property, String[] values)Sets array properties.voidset(Property property, Date date)Sets the date value of the identified metadata property.voidsetAll(Properties properties)It will set all simple and array properties that have QName keys in registered namespaces.intsize()Returns the number of top-level namespacesStringtoString()Serializes the XMP data in compact form without packet wrapper- 
Methods inherited from class org.apache.tika.metadata.Metadataadd, add, add, add, getIntValues, getLongValues, set, set, set, set, setMetadataWriteFilter
 
- 
 
- 
- 
- 
Constructor Detail- 
XMPMetadatapublic XMPMetadata() Initializes with an empty XMP packet
 - 
XMPMetadatapublic XMPMetadata(Metadata meta) throws TikaException - Throws:
- TikaException
- See Also:
- But the mimetype is retrieved from the metadata map.
 
 - 
XMPMetadatapublic XMPMetadata(Metadata meta, String mimetype) throws TikaException Initializes the data by converting the Metadata information to XMP. If a mimetype is provided, a specific converter can be used, that converts all available metadata. If there is no mimetype provided or no specific converter available a generic conversion is done which will convert only those properties that are in known namespaces and are using the correct prefixes- Parameters:
- meta- the Metadata information from Tika-core
- mimetype- mimetype information
- Throws:
- TikaException- case an error occurred during conversion
 
 
- 
 - 
Method Detail- 
registerNamespacepublic static String registerNamespace(String namespaceURI, String suggestedPrefix) throws com.adobe.internal.xmp.XMPException Register a namespace URI with a suggested prefix. It is not an error if the URI is already registered, no matter what the prefix is. If the URI is not registered but the suggested prefix is in use, a unique prefix is created from the suggested one. The actual registered prefix is always returned. The function result tells if the registered prefix is the suggested one. Note: No checking is presently done on either the URI or the prefix.- Parameters:
- namespaceURI- The URI for the namespace. Must be a valid XML URI.
- suggestedPrefix- The suggested prefix to be used if the URI is not yet registered. Must be a valid XML name.
- Returns:
- Returns the registered prefix for this URI, is equal to the suggestedPrefix if the namespace hasn't been registered before, otherwise the existing prefix.
- Throws:
- com.adobe.internal.xmp.XMPException- If the parameters are not accordingly set
 
 - 
getNamespacePrefixpublic static String getNamespacePrefix(String namespaceURI) Obtain the prefix for a registered namespace URI. It is not an error if the namespace URI is not registered.- Parameters:
- namespaceURI- The URI for the namespace. Must not be null or the empty string.
- Returns:
- Returns the prefix registered for this namespace URI or null.
 
 - 
getNamespaceURIpublic static String getNamespaceURI(String namespacePrefix) Obtain the URI for a registered namespace prefix. It is not an error if the namespace prefix is not registered.- Parameters:
- namespacePrefix- The prefix for the namespace. Must not be null or the empty string.
- Returns:
- Returns the URI registered for this prefix or null.
 
 - 
getNamespacespublic static Map<String,String> getNamespaces() - Returns:
- Returns the registered prefix/namespace-pairs as map, where the keys are the namespaces and the values are the prefixes.
 
 - 
getPrefixespublic static Map<String,String> getPrefixes() - Returns:
- Returns the registered namespace/prefix-pairs as map, where the keys are the prefixes and the values are the namespaces.
 
 - 
deleteNamespacepublic static void deleteNamespace(String namespaceURI) Deletes a namespace from the registry.Does nothing if the URI is not registered, or if the namespaceURI parameter is null or the empty string. Note: Not yet implemented. - Parameters:
- namespaceURI- The URI for the namespace.
 
 - 
processpublic void process(Metadata meta) throws TikaException - Throws:
- TikaException
- See Also:
- But the mimetype is retrieved from the metadata map.
 
 - 
processpublic void process(Metadata meta, String mimetype) throws TikaException Converts the Metadata information to XMP. If a mimetype is provided, a specific converter can be used, that converts all available metadata. If there is no mimetype provided or no specific converter available a generic conversion is done which will convert only those properties that are in known namespaces and are using the correct prefixes- Parameters:
- meta- the Metadata information from Tika-core
- mimetype- mimetype information
- Throws:
- TikaException- case an error occurred during conversion
 
 - 
getXMPDatapublic com.adobe.internal.xmp.XMPMeta getXMPData() Provides direct access to the XMP data model, in case a client prefers to work directly on it instead of using the Metadata API- Returns:
- the "internal" XMP data object
 
 - 
isMultiValuedpublic boolean isMultiValued(Property property) Description copied from class:MetadataReturns true if named value is multivalued.- Overrides:
- isMultiValuedin class- Metadata
- Parameters:
- property- metadata property
- Returns:
- true is named value is multivalued, false if single value or null
- See Also:
- isMultiValued(java.lang.String)
 
 - 
isMultiValuedpublic boolean isMultiValued(String name) Checks if the named property is an array.- Overrides:
- isMultiValuedin class- Metadata
- Parameters:
- name- name of metadata
- Returns:
- true is named value is multivalued, false if single value or null
- See Also:
- Metadata.isMultiValued(java.lang.String)
 
 - 
namespublic String[] names() For XMP it is not clear what that API should return, therefor not implemented
 - 
getpublic String get(String name) Returns the value of a simple property or the first one of an array. The given name must contain a namespace prefix of a registered namespace.- Overrides:
- getin class- Metadata
- Parameters:
- name- of the metadata.
- Returns:
- the value associated to the specified metadata name.
- See Also:
- Metadata.get(java.lang.String)
 
 - 
getpublic String get(Property property) Description copied from class:MetadataReturns the value (if any) of the identified metadata property.- Overrides:
- getin class- Metadata
- Parameters:
- property- property definition
- Returns:
- property value, or nullif the property is not set
- See Also:
- get(java.lang.String)
 
 - 
getIntpublic Integer getInt(Property property) Description copied from class:MetadataReturns the value of the identified Integer based metadata property.- Overrides:
- getIntin class- Metadata
- Parameters:
- property- simple integer property definition
- Returns:
- property value as a Integer, or nullif the property is not set, or not a valid Integer
- See Also:
- get(java.lang.String)
 
 - 
getDatepublic Date getDate(Property property) Description copied from class:MetadataReturns the value of the identified Date based metadata property.- Overrides:
- getDatein class- Metadata
- Parameters:
- property- simple date property definition
- Returns:
- property value as a Date, or nullif the property is not set, or not a valid Date
- See Also:
- get(java.lang.String)
 
 - 
getValuespublic String[] getValues(Property property) Description copied from class:MetadataGet the values associated to a metadata name.- Overrides:
- getValuesin class- Metadata
- Parameters:
- property- of the metadata.
- Returns:
- the values associated to a metadata name.
- See Also:
- getValues(java.lang.String)
 
 - 
getValuespublic String[] getValues(String name) Returns the value of a simple property or all if the property is an array and the elements are of simple type. The given name must contain a namespace prefix of a registered namespace.- Overrides:
- getValuesin class- Metadata
- Parameters:
- name- of the metadata.
- Returns:
- the values associated to a metadata name.
- See Also:
- Metadata.getValues(java.lang.String)
 
 - 
addpublic void add(String name, String value) As this API could only possibly work for simple properties in XMP, it just calls the set method, which replaces any existing value- Overrides:
- addin class- Metadata
- Parameters:
- name- the metadata name.
- value- the metadata value.
- See Also:
- Metadata.add(java.lang.String, java.lang.String)
 
 - 
setpublic void set(String name, String value) Sets the given property. If the property already exists, it is overwritten. Only simple properties that use a registered prefix are stored in the XMP.- Overrides:
- setin class- Metadata
- Parameters:
- name- the metadata name.
- value- the metadata value, or- null
- See Also:
- Metadata.set(java.lang.String, java.lang.String)
 
 - 
setpublic void set(Property property, String value) Description copied from class:MetadataSets the value of the identified metadata property.- Overrides:
- setin class- Metadata
- Parameters:
- property- property definition
- value- property value
- See Also:
- set(java.lang.String, java.lang.String)
 
 - 
setpublic void set(Property property, int value) Description copied from class:MetadataSets the integer value of the identified metadata property.- Overrides:
- setin class- Metadata
- Parameters:
- property- simple integer property definition
- value- property value
- See Also:
- set(java.lang.String, java.lang.String)
 
 - 
setpublic void set(Property property, double value) Description copied from class:MetadataSets the real or rational value of the identified metadata property.- Overrides:
- setin class- Metadata
- Parameters:
- property- simple real or simple rational property definition
- value- property value
- See Also:
- set(java.lang.String, java.lang.String)
 
 - 
setpublic void set(Property property, Date date) Description copied from class:MetadataSets the date value of the identified metadata property.- Overrides:
- setin class- Metadata
- Parameters:
- property- simple integer property definition
- date- property value
- See Also:
- set(java.lang.String, java.lang.String)
 
 - 
setpublic void set(Property property, String[] values) Sets array properties. If the property already exists, it is overwritten. Only array properties that use a registered prefix are stored in the XMP.- Overrides:
- setin class- Metadata
- Parameters:
- property- property definition
- values- property values
- See Also:
- Metadata.set(org.apache.tika.metadata.Property, java.lang.String[])
 
 - 
setAllpublic void setAll(Properties properties) It will set all simple and array properties that have QName keys in registered namespaces.- Overrides:
- setAllin class- Metadata
- Parameters:
- properties- properties to copy from
- See Also:
- Metadata.setAll(java.util.Properties)
 
 - 
removepublic void remove(Property property) - See Also:
- remove(java.lang.String)
 
 - 
removepublic void remove(String name) Removes the given property from the XMP data. If it is a complex property the whole subtree is removed- Overrides:
- removein class- Metadata
- Parameters:
- name- metadata name to remove
- See Also:
- Metadata.remove(java.lang.String)
 
 - 
sizepublic int size() Returns the number of top-level namespaces
 - 
equalspublic boolean equals(Object o) This method is not implemented, yet. It is very tedious to check for semantic equality of XMP packets
 - 
toStringpublic String toString() Serializes the XMP data in compact form without packet wrapper- Overrides:
- toStringin class- Metadata
- See Also:
- Metadata.toString()
 
 
- 
 
-