public final class XMPPathFactory
extends java.lang.Object
These functions provide support for composing path expressions to deeply nested properties. The
functions XMPMeta
such as getProperty()
,
getArrayItem()
and getStructField()
provide easy access to top
level simple properties, items in top level arrays, and fields of top level structs. They do not
provide convenient access to more complex things like fields several levels deep in a complex
struct, or fields within an array of structs, or items of an array that is a field of a struct.
These functions can also be used to compose paths to top level array items or struct fields so
that you can use the binary accessors like getPropertyAsInteger()
.
You can use these functions is to compose a complete path expression, or all but the last component. Suppose you have a property that is an array of integers within a struct. You can access one of the array items like this:
You could also use this code if you want the string form of the integer:String path = XMPPathFactory.composeStructFieldPath (schemaNS, "Struct", fieldNS, "Array"); String path += XMPPathFactory.composeArrayItemPath (schemaNS, "Array" index); PropertyInteger result = xmpObj.getPropertyAsInteger(schemaNS, path);
String path = XMPPathFactory.composeStructFieldPath (schemaNS, "Struct", fieldNS, "Array"); PropertyText xmpObj.getArrayItem (schemaNS, path, index);
Note: It might look confusing that the schemaNS is passed in all of the calls above. This is because the XMP toolkit keeps the top level "schema" namespace separate from the rest of the path expression. Note: These methods are much simpler than in the C++-API, they don't check the given path or array indices.
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
composeArrayItemPath(java.lang.String arrayName,
int itemIndex)
Compose the path expression for an item in an array.
|
static java.lang.String |
composeFieldSelector(java.lang.String arrayName,
java.lang.String fieldNS,
java.lang.String fieldName,
java.lang.String fieldValue)
Compose the path expression to select an alternate item by a field's value.
|
static java.lang.String |
composeLangSelector(java.lang.String arrayName,
java.lang.String langName)
Compose the path expression to select an alternate item by language.
|
static java.lang.String |
composeQualifierPath(java.lang.String qualNS,
java.lang.String qualName)
Compose the path expression for a qualifier.
|
static java.lang.String |
composeStructFieldPath(java.lang.String fieldNS,
java.lang.String fieldName)
Compose the path expression for a field in a struct.
|
public static java.lang.String composeArrayItemPath(java.lang.String arrayName, int itemIndex) throws XMPException
arrayName
- The name of the array. May be a general path expression, must not be
null
or the empty string.itemIndex
- The index of the desired item. Arrays in XMP are indexed from 1.
0 and below means last array item and renders as [last()]
.XMPException
- Throws exeption if index zero is used.public static java.lang.String composeStructFieldPath(java.lang.String fieldNS, java.lang.String fieldName) throws XMPException
fieldNS
- The namespace URI for the field. Must not be null
or the empty
string.fieldName
- The name of the field. Must be a simple XML name, must not be
null
or the empty string.XMPException
- Thrown if the path to create is not valid.public static java.lang.String composeQualifierPath(java.lang.String qualNS, java.lang.String qualName) throws XMPException
qualNS
- The namespace URI for the qualifier. May be null
or the empty
string if the qualifier is in the XML empty namespace.qualName
- The name of the qualifier. Must be a simple XML name, must not be
null
or the empty string.XMPException
- Thrown if the path to create is not valid.public static java.lang.String composeLangSelector(java.lang.String arrayName, java.lang.String langName)
arrayName
- The name of the array. May be a general path expression, must
not be null
or the empty string.langName
- The RFC 3066 code for the desired language.public static java.lang.String composeFieldSelector(java.lang.String arrayName, java.lang.String fieldNS, java.lang.String fieldName, java.lang.String fieldValue) throws XMPException
String path = composeFieldSelector ( schemaNS, "Downloads", fieldNS, "City", chosenCity ); XMPProperty prop = xmpObj.getStructField ( schemaNS, path, fieldNS, "URI" );
arrayName
- The name of the array. May be a general path expression, must not be
null
or the empty string.fieldNS
- The namespace URI for the field used as the selector. Must not be
null
or the empty string.fieldName
- The name of the field used as the selector. Must be a simple XML name, must
not be null
or the empty string. It must be the name of a field that is
itself simple.fieldValue
- The desired value of the field.XMPException
- Thrown if the path to create is not valid."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"