Class XMPPathFactory
- java.lang.Object
-
- com.adobe.internal.xmp.XMPPathFactory
-
public final class XMPPathFactory extends java.lang.Object
Utility services for the metadata object. It has only public static functions, you cannot create an object. These are all functions that layer cleanly on top of the core XMP toolkit.These functions provide support for composing path expressions to deeply nested properties. The functions
XMPMeta
such asgetProperty()
,getArrayItem()
andgetStructField()
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 likegetPropertyAsInteger()
.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:
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.
- Since:
- 25.01.2006
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
composeArrayItemPath
public static java.lang.String composeArrayItemPath(java.lang.String arrayName, int itemIndex) throws XMPException
Compose the path expression for an item in an array.- Parameters:
arrayName
- The name of the array. May be a general path expression, must not benull
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()]
.- Returns:
- Returns the composed path basing on fullPath. This will be of the form ns:arrayName[i], where "ns" is the prefix for schemaNS and "i" is the decimal representation of itemIndex.
- Throws:
XMPException
- Throws exeption if index zero is used.
-
composeStructFieldPath
public static java.lang.String composeStructFieldPath(java.lang.String fieldNS, java.lang.String fieldName) throws XMPException
Compose the path expression for a field in a struct. The result can be added to the path of- Parameters:
fieldNS
- The namespace URI for the field. Must not benull
or the empty string.fieldName
- The name of the field. Must be a simple XML name, must not benull
or the empty string.- Returns:
- Returns the composed path. This will be of the form ns:structName/fNS:fieldName, where "ns" is the prefix for schemaNS and "fNS" is the prefix for fieldNS.
- Throws:
XMPException
- Thrown if the path to create is not valid.
-
composeQualifierPath
public static java.lang.String composeQualifierPath(java.lang.String qualNS, java.lang.String qualName) throws XMPException
Compose the path expression for a qualifier.- Parameters:
qualNS
- The namespace URI for the qualifier. May benull
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 benull
or the empty string.- Returns:
- Returns the composed path. This will be of the form ns:propName/?qNS:qualName, where "ns" is the prefix for schemaNS and "qNS" is the prefix for qualNS.
- Throws:
XMPException
- Thrown if the path to create is not valid.
-
composeLangSelector
public static java.lang.String composeLangSelector(java.lang.String arrayName, java.lang.String langName)
Compose the path expression to select an alternate item by language. The path syntax allows two forms of "content addressing" that may be used to select an item in an array of alternatives. The form used in ComposeLangSelector lets you select an item in an alt-text array based on the value of its xml:lang qualifier. The other form of content addressing is shown in ComposeFieldSelector. \note ComposeLangSelector does not supplant SetLocalizedText or GetLocalizedText. They should generally be used, as they provide extra logic to choose the appropriate language and maintain consistency with the 'x-default' value. ComposeLangSelector gives you an path expression that is explicitly and only for the language given in the langName parameter.- Parameters:
arrayName
- The name of the array. May be a general path expression, must not benull
or the empty string.langName
- The RFC 3066 code for the desired language.- Returns:
- Returns the composed path. This will be of the form ns:arrayName[@xml:lang='langName'], where "ns" is the prefix for schemaNS.
-
composeFieldSelector
public static java.lang.String composeFieldSelector(java.lang.String arrayName, java.lang.String fieldNS, java.lang.String fieldName, java.lang.String fieldValue) throws XMPException
Compose the path expression to select an alternate item by a field's value. The path syntax allows two forms of "content addressing" that may be used to select an item in an array of alternatives. The form used in ComposeFieldSelector lets you select an item in an array of structs based on the value of one of the fields in the structs. The other form of content addressing is shown in ComposeLangSelector. For example, consider a simple struct that has two fields, the name of a city and the URI of an FTP site in that city. Use this to create an array of download alternatives. You can show the user a popup built from the values of the city fields. You can then get the corresponding URI as follows:String path = composeFieldSelector ( schemaNS, "Downloads", fieldNS, "City", chosenCity ); XMPProperty prop = xmpObj.getStructField ( schemaNS, path, fieldNS, "URI" );
- Parameters:
arrayName
- The name of the array. May be a general path expression, must not benull
or the empty string.fieldNS
- The namespace URI for the field used as the selector. Must not benull
or the empty string.fieldName
- The name of the field used as the selector. Must be a simple XML name, must not benull
or the empty string. It must be the name of a field that is itself simple.fieldValue
- The desired value of the field.- Returns:
- Returns the composed path. This will be of the form ns:arrayName[fNS:fieldName='fieldValue'], where "ns" is the prefix for schemaNS and "fNS" is the prefix for fieldNS.
- Throws:
XMPException
- Thrown if the path to create is not valid.
-
-