org.jempbox.xmp

Class 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.
Version:
$Revision: 1.1 $
Author:
Ben Litchfield (ben@benlitchfield.com)

Field Summary

static String
ENCODING_UTF16BE
Supported encoding for persisted XML.
static String
ENCODING_UTF16LE
Supported encoding for persisted XML.
static String
ENCODING_UTF8
Supported encoding for persisted XML.
protected Document
xmpDocument
The DOM representation of the metadata.

Constructor Summary

XMPMetadata()
Default constructor, creates blank XMP doc.
XMPMetadata(Document doc)
Constructor from an existing XML document.

Method Summary

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.
XMPSchemaPDF
addPDFSchema()
Create and add a new PDF Schema to this metadata.
String
getEncoding()
Get the current encoding that will be used to write the XML.
List
getSchemas()
This will get a list of XMPSchema(or subclass) objects.
Document
getXMPDocument()
Get the XML document from this object.
static XMPMetadata
load(InputStream is)
Load metadata from the filesystem.
static XMPMetadata
load(String file)
Load metadata from the filesystem.
static void
main(String[] args)
Test main program.
void
save(String file)
Save the XMP document to a file.
void
setEncoding(String xmlEncoding)
The encoding used to write the XML.

Field Details

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.

Constructor Details

XMPMetadata

public XMPMetadata()
            throws IOException
Default constructor, creates blank XMP doc.

XMPMetadata

public XMPMetadata(Document doc)
Constructor from an existing XML document.
Parameters:
doc - The root XMP document.

Method Details

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()
Returns:
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()
Returns:
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()
Returns:
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.
Returns:
The current encoding to write the XML to.

getSchemas

public List getSchemas()
            throws IOException
This will get a list of XMPSchema(or subclass) objects.
Returns:
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.
Returns:
This object as an XML document.

load

public static XMPMetadata load(InputStream is)
            throws IOException
Load metadata from the filesystem.
Parameters:
is - The stream to load the data from.
Returns:
The loaded XMP document.

load

public static XMPMetadata load(String file)
            throws IOException
Load metadata from the filesystem.
Parameters:
file - The file to load the metadata from.
Returns:
The loaded XMP document.

main

public static void main(String[] args)
            throws Exception
Test main program.
Parameters:
args - The command line arguments.

save

public void save(String file)
            throws Exception
Save the XMP document to a file.
Parameters:
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
Parameters:
xmlEncoding - The encoding to write the XML as.