Package org.apache.xmpbox.schema
Class XMPSchema
- java.lang.Object
-
- org.apache.xmpbox.type.AbstractField
-
- org.apache.xmpbox.type.AbstractComplexProperty
-
- org.apache.xmpbox.type.AbstractStructuredType
-
- org.apache.xmpbox.schema.XMPSchema
-
- Direct Known Subclasses:
AdobePDFSchema
,DublinCoreSchema
,ExifSchema
,PDFAExtensionSchema
,PDFAIdentificationSchema
,PhotoshopSchema
,TiffSchema
,XMPageTextSchema
,XMPBasicJobTicketSchema
,XMPBasicSchema
,XMPMediaManagementSchema
,XMPRightsManagementSchema
public class XMPSchema extends AbstractStructuredType
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. MODIFIED TO INCLUDE OBJECT REPRESENTATION
-
-
Field Summary
-
Fields inherited from class org.apache.xmpbox.type.AbstractStructuredType
STRUCTURE_ARRAY_NAME
-
-
Constructor Summary
Constructors Constructor Description XMPSchema(XMPMetadata metadata)
Create a new blank schema that can be populated.XMPSchema(XMPMetadata metadata, java.lang.String prefix)
Create a new blank schema that can be populated.XMPSchema(XMPMetadata metadata, java.lang.String namespaceURI, java.lang.String prefix)
Create a new blank schema that can be populated.XMPSchema(XMPMetadata metadata, java.lang.String namespaceURI, java.lang.String prefix, java.lang.String name)
Create a new blank schema that can be populated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBagValue(java.lang.String qualifiedSeqName, AbstractField seqValue)
Add a new value to a bag property.void
addBagValueAsSimple(java.lang.String simpleName, java.lang.String bagValue)
add a bag value property on the schema, using the current prefix.void
addQualifiedBagValue(java.lang.String simpleName, java.lang.String bagValue)
Add an entry to a bag property.void
addSequenceDateValueAsSimple(java.lang.String simpleName, java.util.Calendar date)
Add a date sequence value to the list using the current prefixvoid
addUnqualifiedSequenceDateValue(java.lang.String seqName, java.util.Calendar date)
Add a date sequence value to the list.void
addUnqualifiedSequenceValue(java.lang.String simpleSeqName, java.lang.String seqValue)
Add a new value to a sequence property.void
addUnqualifiedSequenceValue(java.lang.String seqName, AbstractField seqValue)
Add a new value to a sequence property.Attribute
getAboutAttribute()
Get the RDF about attributejava.lang.String
getAboutValue()
Get the RDF about value.AbstractField
getAbstractProperty(java.lang.String qualifiedName)
Retrieve a generic simple type propertyBooleanType
getBooleanProperty(java.lang.String qualifiedName)
Get a BooleanType property with its namejava.lang.Boolean
getBooleanPropertyValue(java.lang.String qualifiedName)
Get the value of the property as a Boolean.java.lang.Boolean
getBooleanPropertyValueAsSimple(java.lang.String simpleName)
Get a simple boolean property value on the schema, using the current prefix.DateType
getDateProperty(java.lang.String qualifiedName)
Get the Date property with its namejava.util.Calendar
getDatePropertyValue(java.lang.String qualifiedName)
Get the value of the property as a date.java.util.Calendar
getDatePropertyValueAsSimple(java.lang.String simpleName)
Get a simple date property value on the schema, using the current prefix.IntegerType
getIntegerProperty(java.lang.String qualifiedName)
Get the Integer property with its namejava.lang.Integer
getIntegerPropertyValue(java.lang.String qualifiedName)
Get the value of the property as an integer.java.lang.Integer
getIntegerPropertyValueAsSimple(java.lang.String simpleName)
Get a simple integer property value on the schema, using the current prefix.java.util.List<AbstractField>
getUnqualifiedArrayList(java.lang.String name)
Get an AbstractField list corresponding to the content of an array property.java.util.List<java.lang.String>
getUnqualifiedBagValueList(java.lang.String bagName)
Get all the values of the bag property.java.util.List<java.lang.String>
getUnqualifiedLanguagePropertyLanguagesValue(java.lang.String name)
Get a list of all languages that are currently defined for a specific property.java.lang.String
getUnqualifiedLanguagePropertyValue(java.lang.String name, java.lang.String expectedLanguage)
Get the value of a multi-lingual property.java.util.List<java.util.Calendar>
getUnqualifiedSequenceDateValueList(java.lang.String seqName)
Get all the date values in a sequence property.java.util.List<java.lang.String>
getUnqualifiedSequenceValueList(java.lang.String seqName)
Get all the values in a sequence property.TextType
getUnqualifiedTextProperty(java.lang.String name)
Get a TextProperty Type from its namejava.lang.String
getUnqualifiedTextPropertyValue(java.lang.String name)
Get the value of a simple text property.protected AbstractSimpleProperty
instanciateSimple(java.lang.String propertyName, java.lang.Object value)
private void
internalAddBagValue(java.lang.String qualifiedBagName, java.lang.String bagValue)
void
merge(XMPSchema xmpSchema)
A basic schema merge, it merges bags and sequences and replace everything else.private boolean
mergeComplexProperty(java.util.Iterator<AbstractField> itNewValues, ArrayProperty arrayProperty)
private void
removeUnqualifiedArrayValue(java.lang.String arrayName, java.lang.String fieldValue)
Generic array property removingvoid
removeUnqualifiedArrayValue(java.lang.String arrayName, AbstractField fieldValue)
Generic method to remove a field from an array with an Elementable Objectvoid
removeUnqualifiedBagValue(java.lang.String bagName, java.lang.String bagValue)
Remove all matching entries with the given value from the bag.void
removeUnqualifiedSequenceDateValue(java.lang.String seqName, java.util.Calendar date)
Remove a date sequence value from the list.void
removeUnqualifiedSequenceValue(java.lang.String qualifiedSeqName, java.lang.String seqValue)
Remove all matching values from a sequence property.void
removeUnqualifiedSequenceValue(java.lang.String qualifiedSeqName, AbstractField seqValue)
Remove a value from a sequence property.void
reorganizeAltOrder(ComplexPropertyContainer alt)
Method used to place the 'x-default' value in first in Language alternatives as said in xmp specvoid
setAbout(Attribute about)
Set the RDF 'about' attributevoid
setAboutAsSimple(java.lang.String about)
Set the RDF 'about' attribute.void
setBooleanProperty(BooleanType bool)
Set a BooleanType propertyvoid
setBooleanPropertyValue(java.lang.String qualifiedName, java.lang.Boolean bool)
Set the value of the property as a boolean.void
setBooleanPropertyValueAsSimple(java.lang.String simpleName, java.lang.Boolean bool)
Set a simple Boolean property on the schema, using the current prefix.void
setDateProperty(DateType date)
Set a new DatePropertyvoid
setDatePropertyValue(java.lang.String qualifiedName, java.util.Calendar date)
Set the value of the property as a date.void
setDatePropertyValueAsSimple(java.lang.String simpleName, java.util.Calendar date)
Set a simple Date property on the schema, using the current prefix.void
setIntegerProperty(IntegerType prop)
Add an integerPropertyvoid
setIntegerPropertyValue(java.lang.String qualifiedName, java.lang.Integer intValue)
Set the value of the property as an integer.void
setIntegerPropertyValueAsSimple(java.lang.String simpleName, java.lang.Integer intValue)
Set a simple Integer property on the schema, using the current prefix.private void
setSpecifiedSimpleTypeProperty(AbstractSimpleProperty prop)
Add a SimpleProperty to this schemaprivate void
setSpecifiedSimpleTypeProperty(Types type, java.lang.String qualifiedName, java.lang.Object propertyValue)
void
setTextProperty(TextType prop)
Set TextType propertyvoid
setTextPropertyValue(java.lang.String qualifiedName, java.lang.String propertyValue)
Set a simple text property on the schema.void
setTextPropertyValueAsSimple(java.lang.String simpleName, java.lang.String propertyValue)
Set a simple text property on the schema, using the current prefix.void
setUnqualifiedLanguagePropertyValue(java.lang.String name, java.lang.String language, java.lang.String value)
Set the value of a multi-lingual property.-
Methods inherited from class org.apache.xmpbox.type.AbstractStructuredType
addSimpleProperty, createArrayProperty, createTextType, getDatePropertyAsCalendar, getNamespace, getPreferedPrefix, getPrefix, getPropertyValueAsString, setNamespace, setPrefix
-
Methods inherited from class org.apache.xmpbox.type.AbstractComplexProperty
addNamespace, addProperty, getAllNamespacesWithPrefix, getAllProperties, getArrayProperty, getContainer, getFirstEquivalentProperty, getNamespacePrefix, getProperty, removeProperty
-
Methods inherited from class org.apache.xmpbox.type.AbstractField
containsAttribute, getAllAttributes, getAttribute, getMetadata, getPropertyName, removeAttribute, setAttribute, setPropertyName
-
-
-
-
Constructor Detail
-
XMPSchema
public XMPSchema(XMPMetadata metadata, java.lang.String namespaceURI, java.lang.String prefix, java.lang.String name)
Create a new blank schema that can be populated.- Parameters:
metadata
- The parent XMP metadata that this schema will be part of.namespaceURI
- The URI of the namespace, e.g. "http://ns.adobe.com/pdf/1.3/"prefix
- The field prefix of the namespace.name
- The property name.
-
XMPSchema
public XMPSchema(XMPMetadata metadata)
Create a new blank schema that can be populated.- Parameters:
metadata
- The parent XMP metadata that this schema will be part of.
-
XMPSchema
public XMPSchema(XMPMetadata metadata, java.lang.String prefix)
Create a new blank schema that can be populated.- Parameters:
metadata
- The parent XMP metadata that this schema will be part of.prefix
- The field prefix of the namespace.
-
XMPSchema
public XMPSchema(XMPMetadata metadata, java.lang.String namespaceURI, java.lang.String prefix)
Create a new blank schema that can be populated.- Parameters:
metadata
- The parent XMP metadata that this schema will be part of.namespaceURI
- The URI of the namespace, e.g. "http://ns.adobe.com/pdf/1.3/"prefix
- The field prefix of the namespace.
-
-
Method Detail
-
getAbstractProperty
public AbstractField getAbstractProperty(java.lang.String qualifiedName)
Retrieve a generic simple type property- Parameters:
qualifiedName
- Full qualified name of property wanted- Returns:
- The generic simple type property according to its qualified name
-
getAboutAttribute
public Attribute getAboutAttribute()
Get the RDF about attribute- Returns:
- The RDF 'about' attribute.
-
getAboutValue
public java.lang.String getAboutValue()
Get the RDF about value.- Returns:
- The RDF 'about' value. If there is no rdf:about attribute, an empty string is returned.
-
setAbout
public void setAbout(Attribute about) throws BadFieldValueException
Set the RDF 'about' attribute- Parameters:
about
- the well-formed attribute- Throws:
BadFieldValueException
- Bad Attribute name (not corresponding to about attribute)
-
setAboutAsSimple
public void setAboutAsSimple(java.lang.String about)
Set the RDF 'about' attribute. Passing in null will clear this attribute.- Parameters:
about
- The new RFD about value.
-
setSpecifiedSimpleTypeProperty
private void setSpecifiedSimpleTypeProperty(Types type, java.lang.String qualifiedName, java.lang.Object propertyValue)
-
setSpecifiedSimpleTypeProperty
private void setSpecifiedSimpleTypeProperty(AbstractSimpleProperty prop)
Add a SimpleProperty to this schema- Parameters:
prop
- The Property to add
-
setTextProperty
public void setTextProperty(TextType prop)
Set TextType property- Parameters:
prop
- The text property to add
-
setTextPropertyValue
public void setTextPropertyValue(java.lang.String qualifiedName, java.lang.String propertyValue)
Set a simple text property on the schema.- Parameters:
qualifiedName
- 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.
-
setTextPropertyValueAsSimple
public void setTextPropertyValueAsSimple(java.lang.String simpleName, java.lang.String propertyValue)
Set a simple text property on the schema, using the current prefix.- Parameters:
simpleName
- the name of the property without prefixpropertyValue
- The value for the property, can be any string. Passing null will remove the property.
-
getUnqualifiedTextProperty
public TextType getUnqualifiedTextProperty(java.lang.String name)
Get a TextProperty Type from its name- Parameters:
name
- The property name.- Returns:
- The Text Type property wanted
-
getUnqualifiedTextPropertyValue
public java.lang.String getUnqualifiedTextPropertyValue(java.lang.String name)
Get the value of a simple text property.- Parameters:
name
- The property name.- Returns:
- The value of the text property or null if there is no value.
-
getDateProperty
public DateType getDateProperty(java.lang.String qualifiedName)
Get the Date property with its name- Parameters:
qualifiedName
- The name of the property to get, it must include the namespace prefix, e.g. "pdf:Keywords".- Returns:
- Date Type property
-
getDatePropertyValueAsSimple
public java.util.Calendar getDatePropertyValueAsSimple(java.lang.String simpleName)
Get a simple date property value on the schema, using the current prefix.- Parameters:
simpleName
- the local name of the property to get- Returns:
- The value of the property as a calendar.
-
getDatePropertyValue
public java.util.Calendar getDatePropertyValue(java.lang.String qualifiedName)
Get the value of the property as a date.- Parameters:
qualifiedName
- The fully qualified property name for the date.- Returns:
- The value of the property as a date.
-
setDateProperty
public void setDateProperty(DateType date)
Set a new DateProperty- Parameters:
date
- The DateType Property
-
setDatePropertyValueAsSimple
public void setDatePropertyValueAsSimple(java.lang.String simpleName, java.util.Calendar date)
Set a simple Date property on the schema, using the current prefix.- Parameters:
simpleName
- the name of the property without prefixdate
- The calendar value for the property, can be any string. Passing null will remove the property.
-
setDatePropertyValue
public void setDatePropertyValue(java.lang.String qualifiedName, java.util.Calendar date)
Set the value of the property as a date.- Parameters:
qualifiedName
- The fully qualified property name for the date.date
- The date to set, or null to clear.
-
getBooleanProperty
public BooleanType getBooleanProperty(java.lang.String qualifiedName)
Get a BooleanType property with its name- Parameters:
qualifiedName
- the full qualified name of property wanted- Returns:
- boolean Type property
-
getBooleanPropertyValueAsSimple
public java.lang.Boolean getBooleanPropertyValueAsSimple(java.lang.String simpleName)
Get a simple boolean property value on the schema, using the current prefix.- Parameters:
simpleName
- the local name of property wanted- Returns:
- The value of the property as a boolean or null if the property does not exist.
-
getBooleanPropertyValue
public java.lang.Boolean getBooleanPropertyValue(java.lang.String qualifiedName)
Get the value of the property as a Boolean. If you want to use this value like a condition, you must do a null check before.- Parameters:
qualifiedName
- The fully qualified property name for the Boolean.- Returns:
- The value of the property as a Boolean, or null if the property does not exist.
-
setBooleanProperty
public void setBooleanProperty(BooleanType bool)
Set a BooleanType property- Parameters:
bool
- the booleanType property
-
setBooleanPropertyValueAsSimple
public void setBooleanPropertyValueAsSimple(java.lang.String simpleName, java.lang.Boolean bool)
Set a simple Boolean property on the schema, using the current prefix.- Parameters:
simpleName
- the name of the property without prefixbool
- The value for the property, can be any string. Passing null will remove the property.
-
setBooleanPropertyValue
public void setBooleanPropertyValue(java.lang.String qualifiedName, java.lang.Boolean bool)
Set the value of the property as a boolean.- Parameters:
qualifiedName
- The fully qualified property name for the boolean.bool
- The boolean to set, or null to clear.
-
getIntegerProperty
public IntegerType getIntegerProperty(java.lang.String qualifiedName)
Get the Integer property with its name- Parameters:
qualifiedName
- the full qualified name of property wanted- Returns:
- Integer Type property
-
getIntegerPropertyValueAsSimple
public java.lang.Integer getIntegerPropertyValueAsSimple(java.lang.String simpleName)
Get a simple integer property value on the schema, using the current prefix.- Parameters:
simpleName
- the local name of property wanted- Returns:
- The value of the property as an integer.
-
getIntegerPropertyValue
public java.lang.Integer getIntegerPropertyValue(java.lang.String qualifiedName)
Get the value of the property as an integer.- Parameters:
qualifiedName
- The fully qualified property name for the integer.- Returns:
- The value of the property as an integer.
-
setIntegerProperty
public void setIntegerProperty(IntegerType prop)
Add an integerProperty- Parameters:
prop
- The Integer Type property
-
setIntegerPropertyValueAsSimple
public void setIntegerPropertyValueAsSimple(java.lang.String simpleName, java.lang.Integer intValue)
Set a simple Integer property on the schema, using the current prefix.- Parameters:
simpleName
- the name of the property without prefixintValue
- The value for the property, can be any string. Passing null will remove the property.
-
setIntegerPropertyValue
public void setIntegerPropertyValue(java.lang.String qualifiedName, java.lang.Integer intValue)
Set the value of the property as an integer.- Parameters:
qualifiedName
- The fully qualified property name for the integer.intValue
- The int to set, or null to clear.
-
removeUnqualifiedArrayValue
private void removeUnqualifiedArrayValue(java.lang.String arrayName, java.lang.String fieldValue)
Generic array property removing- Parameters:
fieldValue
- the field value
-
removeUnqualifiedBagValue
public void removeUnqualifiedBagValue(java.lang.String bagName, java.lang.String bagValue)
Remove all matching entries with the given value from the bag.- Parameters:
bagName
- The bag name.bagValue
- The value to remove from the bagList.
-
addBagValueAsSimple
public void addBagValueAsSimple(java.lang.String simpleName, java.lang.String bagValue)
add a bag value property on the schema, using the current prefix.- Parameters:
simpleName
- the local name of propertybagValue
- the string value to add
-
internalAddBagValue
private void internalAddBagValue(java.lang.String qualifiedBagName, java.lang.String bagValue)
-
addQualifiedBagValue
public void addQualifiedBagValue(java.lang.String simpleName, java.lang.String bagValue)
Add an entry to a bag property.- Parameters:
simpleName
- The name of the bag without the namespace prefixbagValue
- The value to add to the bagList.
-
getUnqualifiedBagValueList
public java.util.List<java.lang.String> getUnqualifiedBagValueList(java.lang.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 bag name.- Returns:
- All values of the bag property in a list.
-
removeUnqualifiedSequenceValue
public void removeUnqualifiedSequenceValue(java.lang.String qualifiedSeqName, java.lang.String seqValue)
Remove all matching values from a sequence property.- Parameters:
qualifiedSeqName
- The name of the sequence property. It must include the namespace prefix, e.g. "pdf:Keywords".seqValue
- The value to remove from the list.
-
removeUnqualifiedArrayValue
public void removeUnqualifiedArrayValue(java.lang.String arrayName, AbstractField fieldValue)
Generic method to remove a field from an array with an Elementable Object- Parameters:
arrayName
- the name of the property concernedfieldValue
- the elementable field value
-
removeUnqualifiedSequenceValue
public void removeUnqualifiedSequenceValue(java.lang.String qualifiedSeqName, AbstractField seqValue)
Remove a value from a sequence property. This will remove all entries from the list.- Parameters:
qualifiedSeqName
- The name of the sequence property. It must include the namespace prefix, e.g. "pdf:Keywords".seqValue
- The value to remove from the list.
-
addUnqualifiedSequenceValue
public void addUnqualifiedSequenceValue(java.lang.String simpleSeqName, java.lang.String seqValue)
Add a new value to a sequence property.- Parameters:
simpleSeqName
- The name of the sequence property without the namespace prefixseqValue
- The value to add to the sequence.
-
addBagValue
public void addBagValue(java.lang.String qualifiedSeqName, AbstractField seqValue)
Add a new value to a bag property.- Parameters:
qualifiedSeqName
- The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords"seqValue
- The value to add to the bag.
-
addUnqualifiedSequenceValue
public void addUnqualifiedSequenceValue(java.lang.String seqName, AbstractField seqValue)
Add a new value to a sequence property.- Parameters:
seqName
- The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords"seqValue
- The value to add to the sequence.
-
getUnqualifiedSequenceValueList
public java.util.List<java.lang.String> getUnqualifiedSequenceValueList(java.lang.String seqName)
Get all the values in a sequence property.- Parameters:
seqName
- The name of the sequence property without namespace prefix.- Returns:
- A read-only list of java.lang.String objects or null if the property does not exist.
-
removeUnqualifiedSequenceDateValue
public void removeUnqualifiedSequenceDateValue(java.lang.String seqName, java.util.Calendar date)
Remove a date sequence value from the list.- Parameters:
seqName
- The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords"date
- The date to remove from the sequence property.
-
addSequenceDateValueAsSimple
public void addSequenceDateValueAsSimple(java.lang.String simpleName, java.util.Calendar date)
Add a date sequence value to the list using the current prefix- Parameters:
simpleName
- the local name of the propertydate
- the value to add
-
addUnqualifiedSequenceDateValue
public void addUnqualifiedSequenceDateValue(java.lang.String seqName, java.util.Calendar date)
Add a date sequence value to the list.- Parameters:
seqName
- The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords"date
- The date to add to the sequence property.
-
getUnqualifiedSequenceDateValueList
public java.util.List<java.util.Calendar> getUnqualifiedSequenceDateValueList(java.lang.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, e.g. "pdf:Keywords".- Returns:
- A read-only list of java.util.Calendar objects or null if the property does not exist.
-
reorganizeAltOrder
public void reorganizeAltOrder(ComplexPropertyContainer alt)
Method used to place the 'x-default' value in first in Language alternatives as said in xmp spec- Parameters:
alt
- The property to reorganize
-
setUnqualifiedLanguagePropertyValue
public void setUnqualifiedLanguagePropertyValue(java.lang.String name, java.lang.String language, java.lang.String value)
Set the value of a multi-lingual property.- Parameters:
name
- The name of the property, it must include the namespace prefix, e.g. "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.
-
getUnqualifiedLanguagePropertyValue
public java.lang.String getUnqualifiedLanguagePropertyValue(java.lang.String name, java.lang.String expectedLanguage)
Get the value of a multi-lingual property.- Parameters:
name
- The name of the property, without the namespace prefix.expectedLanguage
- The language code of the value. If null then "x-default" is assumed.- Returns:
- The value of the language property.
-
getUnqualifiedLanguagePropertyLanguagesValue
public java.util.List<java.lang.String> getUnqualifiedLanguagePropertyLanguagesValue(java.lang.String name)
Get a list of all languages that are currently defined for a specific property.- Parameters:
name
- The name of the property, it must include the namespace prefix, e.g. "pdf:Keywords".- Returns:
- A list of all languages, this will return an non-null empty list if none have been defined, and null if the property doesn't exist.
-
merge
public void merge(XMPSchema xmpSchema) throws java.io.IOException
A basic schema merge, it merges bags and sequences and replace everything else.- Parameters:
xmpSchema
- The schema to merge.- Throws:
java.io.IOException
- If there is an error during the merge.
-
mergeComplexProperty
private boolean mergeComplexProperty(java.util.Iterator<AbstractField> itNewValues, ArrayProperty arrayProperty)
-
getUnqualifiedArrayList
public java.util.List<AbstractField> getUnqualifiedArrayList(java.lang.String name) throws BadFieldValueException
Get an AbstractField list corresponding to the content of an array property.- Parameters:
name
- The property name without namespace.- Returns:
- List of properties contained in the array property.
- Throws:
BadFieldValueException
- If the property with the requested name isn't an array.
-
instanciateSimple
protected AbstractSimpleProperty instanciateSimple(java.lang.String propertyName, java.lang.Object value)
-
-