Package org.faceless.pdf2
Class XMP.Type
- java.lang.Object
-
- org.faceless.pdf2.XMP.Type
-
- All Implemented Interfaces:
Comparable<XMP.Type>
- Enclosing class:
- XMP
public static class XMP.Type extends Object implements Comparable<XMP.Type>
A Type determines the underlying Type of a Property. Types may be simple, lists of types, or complex structures (a collection of [Property,Type] pairs). Types belong to a Schema, but their name should be unique across the whole XMP.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static XMP.Type
altOf(XMP.Type type)
Return a new Type that is an "Alt" of the supplied Type.static XMP.Type
bagOf(XMP.Type type)
Return a new Type that is a "Bag" of the supplied Type.static XMP.Type
choiceOf(Integer... values)
Return a new Type that is a "Closed Choice" of the specified integer values.static XMP.Type
choiceOf(String... values)
Return a new Type that is a "Closed Choice" of the specified Text values.int
compareTo(XMP.Type type)
XMP.Value
create(XMP xmp, Object source)
Create a new Value object of this type from the specified source.boolean
equals(Object o)
XMP.Type
getComponentType()
For Types that are Lists of other types, return the Type of the collection.String
getDescription()
Return the description of the typeXMP.Property
getField(String uri, String localName)
If a complex Type, return the Property that has the matching namespace and name if one is present, otherwise return null.List<XMP.Property>
getFields()
For a complex Type, return a read-only Collection of the Properties that make up the fields in this Type.String
getName()
Return the name of the typeString
getURI()
Return the namespace of the type, which is the same as thegetURI()
value of hte Schema that created this typeint
hashCode()
boolean
isSimple()
Return true if this type has no fieldsboolean
isUndefined()
Return true if this type is undefinedXMP.Property
newField(String name, XMP.Type type, String description)
Add a field to this type.static XMP.Type
seqOf(XMP.Type type)
Return a new Type that is a "Seq" of the supplied Type.String
toString()
protected void
write(org.faceless.pdf2.XMLStreamWriter out, XMP xmp, int format, Object o)
-
-
-
Field Detail
-
UNDEF
public static final XMP.Type UNDEF
The fallback type used when the element type is unknown
-
-
Method Detail
-
compareTo
public int compareTo(XMP.Type type)
- Specified by:
compareTo
in interfaceComparable<XMP.Type>
-
getFields
public List<XMP.Property> getFields()
For a complex Type, return a read-only Collection of the Properties that make up the fields in this Type. Each Property will return this object from itsXMP.Property.getOwnerType()
method. Simple types (e.g. "Text") will return null
-
getField
public XMP.Property getField(String uri, String localName)
If a complex Type, return the Property that has the matching namespace and name if one is present, otherwise return null. Because most fields in a complex Type share the same URI, setting that parameter to null means "match the first field with this localName".- Parameters:
uri
- the namespace of the field being queried, or null to match any URIlocalName
- the local name of the field being queried- Returns:
- the matching Property if present, or null otherwise.
-
newField
public XMP.Property newField(String name, XMP.Type type, String description)
Add a field to this type. If the field already exists it will be replaced.- Parameters:
name
- the name of the property, which will be unique across this typetype
- the type of the fielddescription
- the description of the field, which is used when serializing the Field to a PDF/A extension, and is required.
-
isSimple
public boolean isSimple()
Return true if this type has no fields
-
getComponentType
public XMP.Type getComponentType()
For Types that are Lists of other types, return the Type of the collection. For example, the Type corresponding to "Seq Text" will return the "Text" Type. For non-List types, return null.
-
isUndefined
public boolean isUndefined()
Return true if this type is undefined
-
getName
public String getName()
Return the name of the type
-
getURI
public String getURI()
Return the namespace of the type, which is the same as thegetURI()
value of hte Schema that created this type
-
getDescription
public String getDescription()
Return the description of the type
-
create
public XMP.Value create(XMP xmp, Object source)
Create a new Value object of this type from the specified source.- Parameters:
xmp
- the XMP this value is being created forsource
- the source, which should be parseable by this Type- Throws:
IllegalArgumentException
- if the specified value cannot be parsed by this Type
-
write
protected void write(org.faceless.pdf2.XMLStreamWriter out, XMP xmp, int format, Object o) throws IOException
- Throws:
IOException
-
bagOf
public static XMP.Type bagOf(XMP.Type type)
Return a new Type that is a "Bag" of the supplied Type. This method is useful when creating new Schema of Types we have not yet added to the XMP. In other circumstances it's better to callXMP.getType(java.lang.String)
- Parameters:
type
- the Type- Returns:
- a Bag of 'Type'
-
seqOf
public static XMP.Type seqOf(XMP.Type type)
Return a new Type that is a "Seq" of the supplied Type. This method is useful when creating new Schema of Types we have not yet added to the XMP. In other circumstances it's better to callXMP.getType(java.lang.String)
- Parameters:
type
- the Type- Returns:
- a Bag of 'Type'
-
altOf
public static XMP.Type altOf(XMP.Type type)
Return a new Type that is an "Alt" of the supplied Type. This method is useful when creating new Schema of Types we have not yet added to the XMP. In other circumstances it's better to callXMP.getType(java.lang.String)
- Parameters:
type
- the Type- Returns:
- a Bag of 'Type'
-
choiceOf
public static XMP.Type choiceOf(Integer... values)
Return a new Type that is a "Closed Choice" of the specified integer values. This method is useful when creating a new Schema. When setting a value for this type via the API, the value must be in the specified list. When loading a property from an existing PDF that isn't in this list, theOutputProfile.Feature.XMPMetaDataTypeUnknownChoice
feature is set (although this will not invalidate the XMP in any of the PDF/A profiles)- Parameters:
values
- the list of values
-
choiceOf
public static XMP.Type choiceOf(String... values)
Return a new Type that is a "Closed Choice" of the specified Text values. This method is useful when creating a new Schema. When setting a value for this type via the API, the value must be in the specified list. When loading a property from an existing PDF that isn't in this list, theOutputProfile.Feature.XMPMetaDataTypeUnknownChoice
feature is set (although this will not invalidate the XMP in any of the PDF/A profiles)- Parameters:
values
- the list of values
-
-