public class XMPMetadata
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
encoding
The encoding of the XMP document.
|
static java.lang.String |
ENCODING_UTF16BE
Supported encoding for persisted XML.
|
static java.lang.String |
ENCODING_UTF16LE
Supported encoding for persisted XML.
|
static java.lang.String |
ENCODING_UTF8
Supported encoding for persisted XML.
|
protected java.util.Map<java.lang.String,java.lang.Class<?>> |
nsMappings
A mapping of namespaces.
|
protected org.w3c.dom.Document |
xmpDocument
The DOM representation of the metadata.
|
Constructor and Description |
---|
XMPMetadata()
Default constructor, creates blank XMP doc.
|
XMPMetadata(org.w3c.dom.Document doc)
Constructor from an existing XML document.
|
Modifier and Type | Method and Description |
---|---|
XMPSchemaBasicJobTicket |
addBasicJobTicketSchema()
Add a new Job Ticket schema.
|
XMPSchemaBasic |
addBasicSchema()
Create and add a new Basic Schema to this metadata.
|
XMPSchemaDublinCore |
addDublinCoreSchema()
Create and add a new Dublin Core Schema to this metadata.
|
XMPSchemaDynamicMedia |
addDynamicMediaSchema()
Add a new Dynamic Media schema.
|
XMPSchemaIptc4xmpCore |
addIptc4xmpCoreSchema()
Create and add a new IPTC schema to this metadata.
|
XMPSchemaMediaManagement |
addMediaManagementSchema()
Add a new Media Management schema.
|
XMPSchemaPagedText |
addPagedTextSchema()
Add a new Paged Text schema.
|
XMPSchemaPDF |
addPDFSchema()
Create and add a new PDF Schema to this metadata.
|
XMPSchemaPhotoshop |
addPhotoshopSchema()
Create and add a new Photoshop schema to this metadata.
|
XMPSchemaRightsManagement |
addRightsManagementSchema()
Add a new Rights Managment schema.
|
void |
addSchema(XMPSchema schema)
Add a custom schema to the root rdf.
|
void |
addXMLNSMapping(java.lang.String namespace,
java.lang.Class<?> xmpSchema)
Will add a XMPSchema to the set of identified schemas.
|
byte[] |
asByteArray()
Get the XML document as a byte array.
|
protected XMPSchema |
basicAddSchema(XMPSchema schema)
Generic add schema method.
|
XMPSchemaBasicJobTicket |
getBasicJobTicketSchema()
Get the Job Ticket Schema.
|
XMPSchemaBasic |
getBasicSchema()
Get the Basic Schema.
|
XMPSchemaDublinCore |
getDublinCoreSchema()
Get the Dublin Core Schema.
|
XMPSchemaDynamicMedia |
getDynamicMediaSchema()
Get the Dynamic Media Schema.
|
java.lang.String |
getEncoding()
Get the current encoding that will be used to write the XML.
|
XMPSchemaMediaManagement |
getMediaManagementSchema()
Get the Media Management Schema.
|
XMPSchemaPagedText |
getPagedTextSchema()
Get the Paged Text Schema.
|
XMPSchemaPDF |
getPDFSchema()
Get the PDF Schema.
|
XMPSchemaRightsManagement |
getRightsManagementSchema()
Get the Schema Rights Schema.
|
XMPSchema |
getSchemaByClass(java.lang.Class<?> targetSchema)
Tries to retrieve a schema from this by classname.
|
java.util.List<XMPSchema> |
getSchemas()
This will get a list of XMPSchema(or subclass) objects.
|
java.util.List<XMPSchema> |
getSchemasByNamespaceURI(java.lang.String namespaceURI)
Will return all schemas that fit the given namespaceURI.
|
org.w3c.dom.Document |
getXMPDocument()
Get the XML document from this object.
|
boolean |
hasUnknownSchema()
This will return true if the XMP contains an unknown schema.
|
static XMPMetadata |
load(org.xml.sax.InputSource is)
Load a schema from an input source.
|
static XMPMetadata |
load(java.io.InputStream is)
Load metadata from the filesystem.
|
static XMPMetadata |
load(java.lang.String file)
Load metadata from the filesystem.
|
static void |
main(java.lang.String[] args)
Test main program.
|
void |
merge(XMPMetadata metadata)
Merge this metadata with the given metadata object.
|
void |
save(java.io.OutputStream outStream)
Save the XMP document to a stream.
|
void |
save(java.lang.String file)
Save the XMP document to a file.
|
void |
setEncoding(java.lang.String xmlEncoding)
The encoding used to write the XML.
|
public static final java.lang.String ENCODING_UTF8
public static final java.lang.String ENCODING_UTF16BE
public static final java.lang.String ENCODING_UTF16LE
protected org.w3c.dom.Document xmpDocument
protected java.lang.String encoding
protected java.util.Map<java.lang.String,java.lang.Class<?>> nsMappings
public XMPMetadata() throws java.io.IOException
java.io.IOException
- If there is an error creating the initial document.public XMPMetadata(org.w3c.dom.Document doc)
doc
- The root XMP document.public void addXMLNSMapping(java.lang.String namespace, java.lang.Class<?> xmpSchema)
namespace
- The namespace URI of the schmema for instance
http://purl.org/dc/elements/1.1/.xmpSchema
- The schema to associated this identifier with.public XMPSchemaPDF getPDFSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaBasic getBasicSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaDublinCore getDublinCoreSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaMediaManagement getMediaManagementSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaRightsManagement getRightsManagementSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaBasicJobTicket getBasicJobTicketSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaDynamicMedia getDynamicMediaSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaPagedText getPagedTextSchema() throws java.io.IOException
java.io.IOException
- If there is an error accessing the schema.public XMPSchemaMediaManagement addMediaManagementSchema()
public XMPSchemaRightsManagement addRightsManagementSchema()
public XMPSchemaBasicJobTicket addBasicJobTicketSchema()
public XMPSchemaDynamicMedia addDynamicMediaSchema()
public XMPSchemaPagedText addPagedTextSchema()
public void addSchema(XMPSchema schema)
schema
- The schema to add.public void save(java.lang.String file) throws java.lang.Exception
file
- The file to save the XMP document to.java.lang.Exception
- If there is an error while writing to the stream.public void save(java.io.OutputStream outStream) throws javax.xml.transform.TransformerException
outStream
- The stream to save the XMP document to.javax.xml.transform.TransformerException
- If there is an error while writing to the stream.public byte[] asByteArray() throws java.lang.Exception
java.lang.Exception
- If there is an error creating the stream.public org.w3c.dom.Document getXMPDocument()
protected XMPSchema basicAddSchema(XMPSchema schema)
schema
- The schema to add.public XMPSchemaPDF addPDFSchema()
public XMPSchemaDublinCore addDublinCoreSchema()
public XMPSchemaBasic addBasicSchema()
public XMPSchemaIptc4xmpCore addIptc4xmpCoreSchema()
public XMPSchemaPhotoshop addPhotoshopSchema()
public void setEncoding(java.lang.String xmlEncoding)
xmlEncoding
- The encoding to write the XML as.public java.lang.String getEncoding()
public static XMPMetadata load(java.lang.String file) throws java.io.IOException
file
- The file to load the metadata from.java.io.IOException
- If there is an error reading the data.public static XMPMetadata load(org.xml.sax.InputSource is) throws java.io.IOException
is
- The input source to load the schema from.java.io.IOException
- If there was an error while loading the schema.public static XMPMetadata load(java.io.InputStream is) throws java.io.IOException
is
- The stream to load the data from.java.io.IOException
- If there is an error reading the data.public static void main(java.lang.String[] args) throws java.lang.Exception
args
- The command line arguments.java.lang.Exception
- If there is an error.public java.util.List<XMPSchema> getSchemas() throws java.io.IOException
java.io.IOException
- If there is an error creating a specific schema.public java.util.List<XMPSchema> getSchemasByNamespaceURI(java.lang.String namespaceURI) throws java.io.IOException
namespaceURI
- The namespaceURI to filter for.java.io.IOException
- If an operation on the document fails.public boolean hasUnknownSchema() throws java.io.IOException
java.io.IOException
- If there is an errorpublic XMPSchema getSchemaByClass(java.lang.Class<?> targetSchema) throws java.io.IOException
targetSchema
- Class for targetSchema.java.io.IOException
- if there was an error creating the schemas of this.public void merge(XMPMetadata metadata) throws java.io.IOException
metadata
- The metadata to merge with this document.java.io.IOException
- If there is an error merging the data.