org.apache.jempbox.xmp

Class XMPSchema

public class XMPSchema extends Object

This class represents a metadata schema that can be stored in an XMP document. It handles all generic properties that are available. See subclasses for access to specific properties.

Version: $Revision: 1.8 $

Author: Ben Litchfield

Field Summary
static StringNS_NAMESPACE
The standard xmlns namespace.
protected Stringprefix
The XML schema prefix.
protected Elementschema
The DOM representation of this object.
Constructor Summary
XMPSchema(XMPMetadata parent, String namespaceName, String namespaceURI)
Create a new blank schema that can be populated.
XMPSchema(Element element, String aPrefix)
Create schema from an existing XML element.
Method Summary
voidaddBagValue(String bagName, String bagValue)
Add an entry to a bag property.
voidaddSequenceDateValue(String seqName, Calendar date)
Add a date sequence value to the list.
voidaddSequenceValue(String seqName, String seqValue)
Add a new value to a sequence property.
voidaddSequenceValue(String seqName, Elementable seqValue)
Add a new value to a sequence property.
StringgetAbout()
Get the RDF about attribute.
List<String>getBagList(String bagName)
Get all the values of the bag property.
BooleangetBooleanProperty(String propertyName)
Get the value of the property as a boolean.
CalendargetDateProperty(String propertyName)
Get the value of the property as a date.
ElementgetElement()
Get the XML element that is represented by this schema.
List<ResourceEvent>getEventSequenceList(String seqName)
Get a list of ResourceEvent objects.
IntegergetIntegerProperty(String propertyName)
Get the value of the property as an integer.
StringgetLanguageProperty(String propertyName, String language)
Get the value of a multi-lingual property.
List<String>getLanguagePropertyLanguages(String propertyName)
Get a list of all languages that are currently defined for a specific property.
List<Calendar>getSequenceDateList(String seqName)
Get all the date values in a sequence property.
List<String>getSequenceList(String seqName)
Get all the values in a sequence property.
StringgetTextProperty(String propertyName)
Get the value of a simple text property.
ThumbnailgetThumbnailProperty(String propertyName, String language)
Get the value of a multi-lingual property.
voidmerge(XMPSchema xmpSchema)
A basic schema merge, it merges bags and sequences and replace everything else.
voidremoveBagValue(String bagName, String bagValue)
Remove all matching entries with the given value from the bag.
voidremoveSequenceDateValue(String seqName, Calendar date)
Remove a date sequence value from the list.
voidremoveSequenceValue(String seqName, String seqValue)
Remove all matching values from a sequence property.
voidremoveSequenceValue(String seqName, Elementable seqValue)
Remove a value from a sequence property.
voidsetAbout(String about)
Set the RDF 'about' attribute.
voidsetBooleanProperty(String propertyName, Boolean bool)
Set the value of the property as a boolean.
voidsetDateProperty(String propertyName, Calendar date)
Set the value of the property as a date.
voidsetIntegerProperty(String propertyName, Integer intValue)
Set the value of the property as an integer.
voidsetLanguageProperty(String propertyName, String language, String value)
Set the value of a multi-lingual property.
voidsetTextProperty(String propertyName, String propertyValue)
Set a simple text property on the schema.
voidsetThumbnailProperty(String propertyName, String language, Thumbnail value)
Set the value of a multi-lingual property.

Field Detail

NS_NAMESPACE

public static final String NS_NAMESPACE
The standard xmlns namespace.

prefix

protected String prefix
The XML schema prefix.

schema

protected Element schema
The DOM representation of this object.

Constructor Detail

XMPSchema

public XMPSchema(XMPMetadata parent, String namespaceName, String namespaceURI)
Create a new blank schema that can be populated.

Parameters: parent The parent XMP document that this schema will be part of. namespaceName The name of the namespace, ie pdf,dc,... namespaceURI The URI of the namespace, ie "http://ns.adobe.com/pdf/1.3/"

XMPSchema

public XMPSchema(Element element, String aPrefix)
Create schema from an existing XML element.

Parameters: element The existing XML element. aPrefix The XML prefix.

Method Detail

addBagValue

public void addBagValue(String bagName, String bagValue)
Add an entry to a bag property.

Parameters: bagName The name of the bag, it must include the namespace prefix. ie "pdf:Keywords". bagValue The value to add to the bagList.

addSequenceDateValue

public void addSequenceDateValue(String seqName, Calendar date)
Add a date sequence value to the list.

Parameters: seqName The name of the sequence property, it must include the namespace prefix. ie "pdf:Keywords" date The date to add to the sequence property.

addSequenceValue

public void addSequenceValue(String seqName, String seqValue)
Add a new value to a sequence property.

Parameters: seqName The name of the sequence property, it must include the namespace prefix. ie "pdf:Keywords" seqValue The value to add to the sequence.

addSequenceValue

public void addSequenceValue(String seqName, Elementable seqValue)
Add a new value to a sequence property.

Parameters: seqName The name of the sequence property, it must include the namespace prefix. ie "pdf:Keywords" seqValue The value to add to the sequence.

getAbout

public String getAbout()
Get the RDF about attribute.

Returns: The RDF 'about' attribute.

getBagList

public List<String> getBagList(String bagName)
Get all the values of the bag property. This will return a list of java.lang.String objects, this is a read-only list.

Parameters: bagName The name of the bag property to get, it must include the namespace prefix. ie "pdf:Keywords"

Returns: All of the values of the bag property in a list.

getBooleanProperty

public Boolean getBooleanProperty(String propertyName)
Get the value of the property as a boolean.

Parameters: propertyName The fully qualified property name for the boolean.

Returns: The value of the property as a boolean.

getDateProperty

public Calendar getDateProperty(String propertyName)
Get the value of the property as a date.

Parameters: propertyName The fully qualified property name for the date.

Returns: The value of the property as a date.

Throws: IOException If there is an error converting the value to a date.

getElement

public Element getElement()
Get the XML element that is represented by this schema.

Returns: The root XML element of this schema.

getEventSequenceList

public List<ResourceEvent> getEventSequenceList(String seqName)
Get a list of ResourceEvent objects.

Parameters: seqName The name of the sequence to retrieve.

Returns: A list of ResourceEvent objects or null if they do not exist.

getIntegerProperty

public Integer getIntegerProperty(String propertyName)
Get the value of the property as an integer.

Parameters: propertyName The fully qualified property name for the integer.

Returns: The value of the property as an integer.

getLanguageProperty

public String getLanguageProperty(String propertyName, String language)
Get the value of a multi-lingual property.

Parameters: propertyName The name of the property, it must include the namespace prefix. ie "pdf:Keywords" language The language code of the value. If null then "x-default" is assumed.

Returns: The value of the language property.

getLanguagePropertyLanguages

public List<String> getLanguagePropertyLanguages(String propertyName)
Get a list of all languages that are currently defined for a specific property.

Parameters: propertyName The name of the property, it must include the namespace prefix. ie "pdf:Keywords"

Returns: A list of all languages, this will return an non-null empty list if none have been defined.

getSequenceDateList

public List<Calendar> getSequenceDateList(String seqName)
Get all the date values in a sequence property.

Parameters: seqName The name of the sequence property, it must include the namespace prefix. ie "pdf:Keywords".

Returns: A read-only list of java.util.Calendar objects or null if the property does not exist.

Throws: IOException If there is an error converting the value to a date.

getSequenceList

public List<String> getSequenceList(String seqName)
Get all the values in a sequence property.

Parameters: seqName The name of the sequence property, it must include the namespace prefix. ie "pdf:Keywords".

Returns: A read-only list of java.lang.String objects or null if the property does not exist.

getTextProperty

public String getTextProperty(String propertyName)
Get the value of a simple text property.

Parameters: propertyName The name of the property to get, it must include the namespace prefix. ie "pdf:Keywords".

Returns: The value of the text property or the null if there is no value.

getThumbnailProperty

public Thumbnail getThumbnailProperty(String propertyName, String language)
Get the value of a multi-lingual property.

Parameters: propertyName The name of the property, it must include the namespace prefix. ie "pdf:Keywords" language The language code of the value. If null then "x-default" is assumed.

Returns: The value of the language property.

merge

public void merge(XMPSchema xmpSchema)
A basic schema merge, it merges bags and sequences and replace everything else.

Parameters: xmpSchema The schema to merge.

Throws: IOException If there is an error during the merge.

removeBagValue

public void removeBagValue(String bagName, String bagValue)
Remove all matching entries with the given value from the bag.

Parameters: bagName The name of the bag, it must include the namespace prefix. ie "pdf:Keywords". bagValue The value to remove from the bagList.

removeSequenceDateValue

public void removeSequenceDateValue(String seqName, Calendar date)
Remove a date sequence value from the list.

Parameters: seqName The name of the sequence property, it must include the namespace prefix. ie "pdf:Keywords" date The date to remove from the sequence property.

removeSequenceValue

public void removeSequenceValue(String seqName, String seqValue)
Remove all matching values from a sequence property.

Parameters: seqName The name of the sequence property. It must include the namespace prefix. ie "pdf:Keywords". seqValue The value to remove from the list.

removeSequenceValue

public void removeSequenceValue(String seqName, Elementable seqValue)
Remove a value from a sequence property. This will remove all entries from the list.

Parameters: seqName The name of the sequence property. It must include the namespace prefix. ie "pdf:Keywords". seqValue The value to remove from the list.

setAbout

public void setAbout(String about)
Set the RDF 'about' attribute. Passing in null will clear this attribute.

Parameters: about The new RFD about value.

setBooleanProperty

public void setBooleanProperty(String propertyName, Boolean bool)
Set the value of the property as a boolean.

Parameters: propertyName The fully qualified property name for the boolean. bool The boolean to set, or null to clear.

setDateProperty

public void setDateProperty(String propertyName, Calendar date)
Set the value of the property as a date.

Parameters: propertyName The fully qualified property name for the date. date The date to set, or null to clear.

setIntegerProperty

public void setIntegerProperty(String propertyName, Integer intValue)
Set the value of the property as an integer.

Parameters: propertyName The fully qualified property name for the integer. intValue The int to set, or null to clear.

setLanguageProperty

public void setLanguageProperty(String propertyName, String language, String value)
Set the value of a multi-lingual property.

Parameters: propertyName The name of the property, it must include the namespace prefix. ie "pdf:Keywords" language The language code of the value. If null then "x-default" is assumed. value The value of the property in the specified language.

setTextProperty

public void setTextProperty(String propertyName, String propertyValue)
Set a simple text property on the schema.

Parameters: propertyName The name of the property, it must contain the namespace prefix, ie "pdf:Keywords" propertyValue The value for the property, can be any string. Passing null will remove the property.

setThumbnailProperty

public void setThumbnailProperty(String propertyName, String language, Thumbnail value)
Set the value of a multi-lingual property.

Parameters: propertyName The name of the property, it must include the namespace prefix. ie "pdf:Keywords" language The language code of the value. If null then "x-default" is assumed. value The value of the property in the specified language.

Copyright © 2008-2010 Apache Software Foundation. All Rights Reserved.