Package org.apache.tika.xmp
Class XMPMetadata
java.lang.Object
org.apache.tika.metadata.Metadata
org.apache.tika.xmp.XMPMetadata
- All Implemented Interfaces:
Serializable,org.apache.tika.metadata.ClimateForcast,org.apache.tika.metadata.CreativeCommons,org.apache.tika.metadata.Geographic,org.apache.tika.metadata.HttpHeaders,org.apache.tika.metadata.Message,org.apache.tika.metadata.TIFF,org.apache.tika.metadata.TikaMimeKeys
public class XMPMetadata
extends org.apache.tika.metadata.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:
-
Field Summary
Fields inherited from interface org.apache.tika.metadata.ClimateForcast
ACKNOWLEDGEMENT, COMMAND_LINE, COMMENT, CONTACT, CONVENTIONS, EXPERIMENT_ID, HISTORY, INSTITUTION, MODEL_NAME_ENGLISH, PROGRAM_ID, PROJECT_ID, REALIZATION, REFERENCES, SOURCE, TABLE_IDFields inherited from interface org.apache.tika.metadata.CreativeCommons
LICENSE_LOCATION, LICENSE_URL, WORK_TYPEFields inherited from interface org.apache.tika.metadata.Geographic
ALTITUDE, LATITUDE, LONGITUDE, TIMESTAMPFields inherited from interface org.apache.tika.metadata.HttpHeaders
CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_MD5, CONTENT_TYPE, LOCATIONFields inherited from interface org.apache.tika.metadata.Message
MESSAGE_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_SUBTYPEFields inherited from interface org.apache.tika.metadata.TIFF
BITS_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, SOFTWAREFields inherited from interface org.apache.tika.metadata.TikaMimeKeys
MIME_TYPE_MAGIC, TIKA_MIME_FILE -
Constructor Summary
ConstructorsConstructorDescriptionInitializes with an empty XMP packetXMPMetadata(org.apache.tika.metadata.Metadata meta) XMPMetadata(org.apache.tika.metadata.Metadata meta, String mimetype) Initializes the data by converting the Metadata information to XMP. -
Method Summary
Modifier and TypeMethodDescriptionvoidAs 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.booleanThis method is not implemented, yet.Returns the value of a simple property or the first one of an array.get(org.apache.tika.metadata.Property property) getDate(org.apache.tika.metadata.Property property) getInt(org.apache.tika.metadata.Property property) static StringgetNamespacePrefix(String namespaceURI) Obtain the prefix for a registered namespace URI.static StringgetNamespaceURI(String namespacePrefix) Obtain the URI for a registered namespace prefix.String[]Returns the value of a simple property or all if the property is an array and the elements are of simple type.String[]getValues(org.apache.tika.metadata.Property property) com.adobe.internal.xmp.XMPMetaProvides 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(org.apache.tika.metadata.Property property) String[]names()For XMP it is not clear what that API should return, therefor not implementedvoidprocess(org.apache.tika.metadata.Metadata meta) voidConverts the Metadata information to XMP.static StringregisterNamespace(String namespaceURI, String suggestedPrefix) Register a namespace URI with a suggested prefix.voidRemoves the given property from the XMP data.voidremove(org.apache.tika.metadata.Property property) voidSets the given property.voidset(org.apache.tika.metadata.Property property, double value) voidset(org.apache.tika.metadata.Property property, int value) voidvoidSets array properties.voidvoidsetAll(Properties properties) It will set all simple and array properties that have QName keys in registered namespaces.intsize()Returns the number of top-level namespacestoString()Serializes the XMP data in compact form without packet wrapperMethods inherited from class org.apache.tika.metadata.Metadata
add, add, add, add, getIntValues, getLongValues, set, set, set, set, setMetadataWriteFilter
-
Constructor Details
-
XMPMetadata
public XMPMetadata()Initializes with an empty XMP packet -
XMPMetadata
public XMPMetadata(org.apache.tika.metadata.Metadata meta) throws org.apache.tika.exception.TikaException - Throws:
org.apache.tika.exception.TikaException- See Also:
-
XMPMetadata
public XMPMetadata(org.apache.tika.metadata.Metadata meta, String mimetype) throws org.apache.tika.exception.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-coremimetype- mimetype information- Throws:
org.apache.tika.exception.TikaException- case an error occurred during conversion
-
-
Method Details
-
registerNamespace
public 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
-
getNamespacePrefix
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.
-
getNamespaceURI
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.
-
getNamespaces
- Returns:
- Returns the registered prefix/namespace-pairs as map, where the keys are the namespaces and the values are the prefixes.
-
getPrefixes
- Returns:
- Returns the registered namespace/prefix-pairs as map, where the keys are the prefixes and the values are the namespaces.
-
deleteNamespace
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.
-
process
public void process(org.apache.tika.metadata.Metadata meta) throws org.apache.tika.exception.TikaException - Throws:
org.apache.tika.exception.TikaException- See Also:
-
process
public void process(org.apache.tika.metadata.Metadata meta, String mimetype) throws org.apache.tika.exception.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-coremimetype- mimetype information- Throws:
org.apache.tika.exception.TikaException- case an error occurred during conversion
-
getXMPData
public 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
-
isMultiValued
public boolean isMultiValued(org.apache.tika.metadata.Property property) - Overrides:
isMultiValuedin classorg.apache.tika.metadata.Metadata- See Also:
-
isMultiValued
Checks if the named property is an array.- Overrides:
isMultiValuedin classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.isMultiValued(java.lang.String)
-
names
For XMP it is not clear what that API should return, therefor not implemented- Overrides:
namesin classorg.apache.tika.metadata.Metadata
-
get
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 classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.get(java.lang.String)
-
get
- Overrides:
getin classorg.apache.tika.metadata.Metadata- See Also:
-
getInt
- Overrides:
getIntin classorg.apache.tika.metadata.Metadata- See Also:
-
getDate
- Overrides:
getDatein classorg.apache.tika.metadata.Metadata- See Also:
-
getValues
- Overrides:
getValuesin classorg.apache.tika.metadata.Metadata- See Also:
-
getValues
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 classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.getValues(java.lang.String)
-
add
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 classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.add(java.lang.String, java.lang.String)
-
set
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 classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.set(java.lang.String, java.lang.String)
-
set
- Overrides:
setin classorg.apache.tika.metadata.Metadata- See Also:
-
set
public void set(org.apache.tika.metadata.Property property, int value) - Overrides:
setin classorg.apache.tika.metadata.Metadata- See Also:
-
set
public void set(org.apache.tika.metadata.Property property, double value) - Overrides:
setin classorg.apache.tika.metadata.Metadata- See Also:
-
set
- Overrides:
setin classorg.apache.tika.metadata.Metadata- See Also:
-
set
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 classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.set(org.apache.tika.metadata.Property, java.lang.String[])
-
setAll
It will set all simple and array properties that have QName keys in registered namespaces.- Overrides:
setAllin classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.setAll(java.util.Properties)
-
remove
public void remove(org.apache.tika.metadata.Property property) - See Also:
-
remove
Removes the given property from the XMP data. If it is a complex property the whole subtree is removed- Overrides:
removein classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.remove(java.lang.String)
-
size
public int size()Returns the number of top-level namespaces- Overrides:
sizein classorg.apache.tika.metadata.Metadata
-
equals
This method is not implemented, yet. It is very tedious to check for semantic equality of XMP packets- Overrides:
equalsin classorg.apache.tika.metadata.Metadata
-
hashCode
public int hashCode()- Overrides:
hashCodein classorg.apache.tika.metadata.Metadata
-
toString
Serializes the XMP data in compact form without packet wrapper- Overrides:
toStringin classorg.apache.tika.metadata.Metadata- See Also:
-
Metadata.toString()
-