This class represents the top level XMP data structure and gives access to
the various schemas that are available as part of the XMP specification.
ENCODING_UTF16BE
public static final String ENCODING_UTF16BE
Supported encoding for persisted XML.
ENCODING_UTF16LE
public static final String ENCODING_UTF16LE
Supported encoding for persisted XML.
ENCODING_UTF8
public static final String ENCODING_UTF8
Supported encoding for persisted XML.
encoding
protected String encoding
The encoding of the XMP document. Default is UTF8.
nsMappings
protected Map nsMappings
A mapping of namespaces.
xmpDocument
protected Document xmpDocument
The DOM representation of the metadata.
addBasicSchema
public XMPSchemaBasic addBasicSchema()
Create and add a new Basic Schema to this metadata. Typically a XMP
document will only have one schema for each type (but multiple are
supported) so it is recommended that you first check the existence of a
this scheme by using getDublinCoreSchema()
- A new blank PDF schema that is now part of the metadata.
addDublinCoreSchema
public XMPSchemaDublinCore addDublinCoreSchema()
Create and add a new Dublin Core Schema to this metadata. Typically a XMP
document will only have one schema for each type (but multiple are
supported) so it is recommended that you first check the existence of a
this scheme by using getDublinCoreSchema()
- A new blank PDF schema that is now part of the metadata.
addDynamicMediaSchema
public XMPSchemaDynamicMedia addDynamicMediaSchema()
Add a new Dynamic Media schema.
addIptc4xmpCoreSchema
public XMPSchemaIptc4xmpCore addIptc4xmpCoreSchema()
Create and add a new IPTC schema to this metadata.
- A new blank IPTC schema that is now part of the metadata.
addPDFSchema
public XMPSchemaPDF addPDFSchema()
Create and add a new PDF Schema to this metadata. Typically a XMP
document will only have one PDF schema (but multiple are supported) so it
is recommended that you first check the existence of a PDF scheme by
using getPDFSchema()
- A new blank PDF schema that is now part of the metadata.
addPagedTextSchema
public XMPSchemaPagedText addPagedTextSchema()
Add a new Paged Text schema.
addPhotoshopSchema
public XMPSchemaPhotoshop addPhotoshopSchema()
Create and add a new Photoshop schema to this metadata.
- A new blank Photoshop schema that is now part of the metadata.
addSchema
public void addSchema(XMPSchema schema)
Add a custom schema to the root rdf. The schema has to have been created
as a child of this XMPMetadata.
schema - The schema to add.
addXMLNSMapping
public void addXMLNSMapping(String namespace,
Class xmpSchema) Will add a XMPSchema to the set of identified schemas.
The class needs to have a constructor with parameter Element
namespace - The namespace URI of the schmema for instance
http://purl.org/dc/elements/1.1/.xmpSchema - The schema to associated this identifier with.
asByteArray
public byte[] asByteArray()
throws Exception Get the XML document as a byte array.
- The metadata as an XML byte stream.
basicAddSchema
protected XMPSchema basicAddSchema(XMPSchema schema)
Generic add schema method.
schema - The schema to add.
getBasicJobTicketSchema
public XMPSchemaBasicJobTicket getBasicJobTicketSchema()
throws IOException Get the Job Ticket Schema.
- The first Job Ticket schema in the list.
getBasicSchema
public XMPSchemaBasic getBasicSchema()
throws IOException Get the Basic Schema.
- The first Basic schema in the list.
getDublinCoreSchema
public XMPSchemaDublinCore getDublinCoreSchema()
throws IOException Get the Dublin Core Schema.
- The first Dublin schema in the list.
getDynamicMediaSchema
public XMPSchemaDynamicMedia getDynamicMediaSchema()
throws IOException Get the Dynamic Media Schema.
- The first Dynamic Media schema in the list.
getEncoding
public String getEncoding()
Get the current encoding that will be used to write the XML.
- The current encoding to write the XML to.
getMediaManagementSchema
public XMPSchemaMediaManagement getMediaManagementSchema()
throws IOException Get the Media Management Schema.
- The first Media Management schema in the list.
getPDFSchema
public XMPSchemaPDF getPDFSchema()
throws IOException Get the PDF Schema.
- The first PDF schema in the list.
getPagedTextSchema
public XMPSchemaPagedText getPagedTextSchema()
throws IOException Get the Paged Text Schema.
- The first Paged Text schema in the list.
getRightsManagementSchema
public XMPSchemaRightsManagement getRightsManagementSchema()
throws IOException Get the Schema Rights Schema.
- The first Schema Rights schema in the list.
getSchemaByClass
public XMPSchema getSchemaByClass(Class targetSchema)
throws IOException Tries to retrieve a schema from this by classname.
targetSchema - Class for targetSchema.
- XMPSchema or null if no target is found.
getSchemas
public List getSchemas()
throws IOException This will get a list of XMPSchema(or subclass) objects.
- A non null read-only list of schemas that are part of this
metadata.
getSchemasByNamespaceURI
public List getSchemasByNamespaceURI(String namespaceURI)
throws IOException Will return all schemas that fit the given namespaceURI. Which is only
done by using the namespace mapping (nsMapping) and not by actually
checking the xmlns property.
namespaceURI - The namespaceURI to filter for.
- A list containing the found schemas or an empty list if non are
found or the namespaceURI could not be found in the namespace
mapping.
getXMPDocument
public Document getXMPDocument()
Get the XML document from this object.
- This object as an XML document.
hasUnknownSchema
public boolean hasUnknownSchema()
throws IOException This will return true if the XMP contains an unknown schema.
- True if an unknown schema is found, false otherwise
load
public static XMPMetadata load(InputSource is)
throws IOException Load a schema from an input source.
is - The input source to load the schema from.
- The loaded/parsed schema.
load
public static XMPMetadata load(InputStream is)
throws IOException Load metadata from the filesystem.
is - The stream to load the data from.
load
public static XMPMetadata load(String file)
throws IOException Load metadata from the filesystem.
file - The file to load the metadata from.
main
public static void main(String[] args)
throws Exception Test main program.
args - The command line arguments.
merge
public void merge(XMPMetadata metadata)
throws IOException Merge this metadata with the given metadata object.
metadata - The metadata to merge with this document.
save
public void save(OutputStream outStream)
throws TransformerException Save the XMP document to a stream.
outStream - The stream to save the XMP document to.
save
public void save(String file)
throws Exception Save the XMP document to a file.
file - The file to save the XMP document to.
setEncoding
public void setEncoding(String xmlEncoding)
The encoding used to write the XML. Default value:UTF-8
See the
ENCODING_XXX constants
xmlEncoding - The encoding to write the XML as.