Package org.apache.xmlgraphics.xmp
Class XMPArray
- java.lang.Object
-
- org.apache.xmlgraphics.xmp.XMPComplexValue
-
- org.apache.xmlgraphics.xmp.XMPArray
-
- All Implemented Interfaces:
XMLizable
public class XMPArray extends XMPComplexValue
Represents an XMP array as defined by the XMP specification.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>
parseTypes
private XMPArrayType
type
private java.util.List
values
private java.util.List
xmllang
-
Constructor Summary
Constructors Constructor Description XMPArray(XMPArrayType type)
Main constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.Object value)
void
add(java.lang.Object value, java.lang.String lang)
Adds a language-dependent value to the array.void
add(java.lang.Object value, java.lang.String lang, java.lang.String parseType)
Adds a new value to the arrayjava.lang.String
getLangValue(java.lang.String lang)
Returns a language-dependent values (available for alternative arrays).private java.lang.String
getParentLanguage(java.lang.String lang)
java.lang.Object
getSimpleValue()
Returns a normal Java object representing the value if it is available.int
getSize()
Returns the current number of values in the array.XMPStructure
getStructure(int idx)
Returns the structure at a given position.XMPArrayType
getType()
java.lang.Object
getValue(int idx)
Returns the value at a given position.boolean
isEmpty()
Indicates whether the array is empty or not.boolean
remove(java.lang.String value)
Removes a value from the array.java.lang.String
removeLangValue(java.lang.String lang)
Removes a language-dependent value.java.lang.Object[]
toObjectArray()
Converts the array to an object array.void
toSAX(org.xml.sax.ContentHandler handler)
Generates SAX events representing the object's state.java.lang.String
toString()
-
-
-
Field Detail
-
type
private XMPArrayType type
-
values
private java.util.List values
-
xmllang
private java.util.List xmllang
-
parseTypes
private java.util.List<java.lang.String> parseTypes
-
-
Constructor Detail
-
XMPArray
public XMPArray(XMPArrayType type)
Main constructor- Parameters:
type
- the intended type of array
-
-
Method Detail
-
getType
public XMPArrayType getType()
- Returns:
- the type of array
-
getValue
public java.lang.Object getValue(int idx)
Returns the value at a given position.- Parameters:
idx
- the index of the requested value- Returns:
- the value at the given position
-
getStructure
public XMPStructure getStructure(int idx)
Returns the structure at a given position. If the value is not a structure a ClassCastException is thrown.- Parameters:
idx
- the index of the requested value- Returns:
- the structure at the given position
-
getSimpleValue
public java.lang.Object getSimpleValue()
Returns a normal Java object representing the value if it is available.- Specified by:
getSimpleValue
in classXMPComplexValue
- Returns:
- a simple object value or null if no such value can be returned (for example, because the value is an array and has multiple entries.
-
getParentLanguage
private java.lang.String getParentLanguage(java.lang.String lang)
-
getLangValue
public java.lang.String getLangValue(java.lang.String lang)
Returns a language-dependent values (available for alternative arrays).- Parameters:
lang
- the language ("x-default" for the default value)- Returns:
- the requested value
-
removeLangValue
public java.lang.String removeLangValue(java.lang.String lang)
Removes a language-dependent value.- Parameters:
lang
- the language ("x-default" for the default value)- Returns:
- the removed value (or null if no value was set)
-
add
public void add(java.lang.Object value, java.lang.String lang, java.lang.String parseType)
Adds a new value to the array- Parameters:
value
- the value
-
add
public void add(java.lang.Object value, java.lang.String lang)
Adds a language-dependent value to the array. Make sure not to add the same language twice.- Parameters:
value
- the valuelang
- the language ("x-default" for the default value)
-
add
public void add(java.lang.Object value)
-
remove
public boolean remove(java.lang.String value)
Removes a value from the array. If the value doesn't exist, nothing happens.- Parameters:
value
- the value to be removed- Returns:
- true if the value was removed, false if it wasn't found
-
getSize
public int getSize()
Returns the current number of values in the array.- Returns:
- the current number of values in the array
-
isEmpty
public boolean isEmpty()
Indicates whether the array is empty or not.- Returns:
- true if the array is empty
-
toObjectArray
public java.lang.Object[] toObjectArray()
Converts the array to an object array.- Returns:
- an object array of all values in the array
-
toSAX
public void toSAX(org.xml.sax.ContentHandler handler) throws org.xml.sax.SAXException
Generates SAX events representing the object's state.- Parameters:
handler
- ContentHandler instance to send the SAX events to- Throws:
org.xml.sax.SAXException
- if there's a problem generating the SAX events
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-