org.jempbox.xmp
Class XMPMetadata
java.lang.Object
org.jempbox.xmp.XMPMetadata
public class XMPMetadata
extends java.lang.Object
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.
- Ben Litchfield (ben@benlitchfield.com)
XMPMetadata() - Default constructor, creates blank XMP doc.
|
XMPMetadata(Document doc) - Constructor from an existing XML document.
|
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.
xmpDocument
protected Document xmpDocument
The DOM representation of the metadata.
XMPMetadata
public XMPMetadata()
throws IOException
Default constructor, creates blank XMP doc.
XMPMetadata
public XMPMetadata(Document doc)
Constructor from an existing XML document.
doc
- The root XMP document.
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.
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.
getEncoding
public String getEncoding()
Get the current encoding that will be used to write the XML.
- The current encoding to write the XML to.
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.
getXMPDocument
public Document getXMPDocument()
Get the XML document from this object.
- This object as an XML document.
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.
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.