XMP-Core-JAVA-CS6/0000755000000000000000000000000012153406731012220 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/0000755000000000000000000000000012153406731013475 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/build.xml0000644000000000000000000001320711754413532015324 0ustar rootroot XMP-Core-JAVA-CS6/XMPCore/.classpath0000644000000000000000000000034211754413532015462 0ustar rootroot XMP-Core-JAVA-CS6/XMPCore/.project0000644000000000000000000000110211754413532015141 0ustar rootroot XMPCore Copyright 2006-2007 Adobe Systems Incorporated, All Rights Reserved. NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms of the Adobe license agreement accompanying it. org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature XMP-Core-JAVA-CS6/XMPCore/src/0000755000000000000000000000000012153406731014264 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/src/com/0000755000000000000000000000000012153406731015042 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/src/com/adobe/0000755000000000000000000000000012153406731016114 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/0000755000000000000000000000000012153406731016720 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/XMPIterator.java0000644000000000000000000000722311754413532021750 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp; import java.util.Iterator; /** * Interface for the XMPMeta iteration services. * XMPIterator provides a uniform means to iterate over the * schema and properties within an XMP object. *

* The iteration over the schema and properties within an XMP object is very * complex. It is helpful to have a thorough understanding of the XMP data tree. * One way to learn this is to create some complex XMP and examine the output of * XMPMeta#toString. This is also described in the XMP * Specification, in the XMP Data Model chapter. *

* The top of the XMP data tree is a single root node. This does not explicitly * appear in the dump and is never visited by an iterator (that is, it is never * returned from XMPIterator#next()). Beneath the root are * schema nodes. These are just collectors for top level properties in the same * namespace. They are created and destroyed implicitly. Beneath the schema * nodes are the property nodes. The nodes below a property node depend on its * type (simple, struct, or array) and whether it has qualifiers. *

* An XMPIterator is created by XMPMeta#interator() constructor * defines a starting point for the iteration and options that control how it * proceeds. By default the iteration starts at the root and visits all nodes * beneath it in a depth first manner. The root node is not visited, the first * visited node is a schema node. You can provide a schema name or property path * to select a different starting node. By default this visits the named root * node first then all nodes beneath it in a depth first manner. *

* The XMPIterator#next() method delivers the schema URI, path, * and option flags for the node being visited. If the node is simple it also * delivers the value. Qualifiers for this node are visited next. The fields of * a struct or items of an array are visited after the qualifiers of the parent. *

* The options to control the iteration are: *

*

* next() returns XMPPropertyInfo-objects and throws * a NoSuchElementException if there are no more properties to * return. * * @since 25.01.2006 */ public interface XMPIterator extends Iterator { /** * Skip the subtree below the current node when next() is * called. */ void skipSubtree(); /** * Skip the subtree below and remaining siblings of the current node when * next() is called. */ void skipSiblings(); }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/package.html0000644000000000000000000000055411754413532021210 0ustar rootroot Package overview

Package containing the xmpcore interface.

XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/XMPDateTimeFactory.java0000644000000000000000000001222711754413532023203 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; import com.adobe.xmp.impl.XMPDateTimeImpl; /** * A factory to create XMPDateTime-instances from a Calendar or an * ISO 8601 string or for the current time. * * @since 16.02.2006 */ public final class XMPDateTimeFactory { /** The UTC TimeZone */ private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); /** Private constructor */ private XMPDateTimeFactory() { // EMPTY } /** * Creates an XMPDateTime from a Calendar-object. * * @param calendar a Calendar-object. * @return An XMPDateTime-object. */ public static XMPDateTime createFromCalendar(Calendar calendar) { return new XMPDateTimeImpl(calendar); } /** * Creates an empty XMPDateTime-object. * @return Returns an XMPDateTime-object. */ public static XMPDateTime create() { return new XMPDateTimeImpl(); } /** * Creates an XMPDateTime-object from initial values. * @param year years * @param month months from 1 to 12
* Note: Remember that the month in {@link Calendar} is defined from 0 to 11. * @param day days * @return Returns an XMPDateTime-object. */ public static XMPDateTime create(int year, int month, int day) { XMPDateTime dt = new XMPDateTimeImpl(); dt.setYear(year); dt.setMonth(month); dt.setDay(day); return dt; } /** * Creates an XMPDateTime-object from initial values. * @param year years * @param month months from 1 to 12
* Note: Remember that the month in {@link Calendar} is defined from 0 to 11. * @param day days * @param hour hours * @param minute minutes * @param second seconds * @param nanoSecond nanoseconds * @return Returns an XMPDateTime-object. */ public static XMPDateTime create(int year, int month, int day, int hour, int minute, int second, int nanoSecond) { XMPDateTime dt = new XMPDateTimeImpl(); dt.setYear(year); dt.setMonth(month); dt.setDay(day); dt.setHour(hour); dt.setMinute(minute); dt.setSecond(second); dt.setNanoSecond(nanoSecond); return dt; } /** * Creates an XMPDateTime from an ISO 8601 string. * * @param strValue The ISO 8601 string representation of the date/time. * @return An XMPDateTime-object. * @throws XMPException When the ISO 8601 string is non-conform */ public static XMPDateTime createFromISO8601(String strValue) throws XMPException { return new XMPDateTimeImpl(strValue); } /** * Obtain the current date and time. * * @return Returns The returned time is UTC, properly adjusted for the local time zone. The * resolution of the time is not guaranteed to be finer than seconds. */ public static XMPDateTime getCurrentDateTime() { return new XMPDateTimeImpl(new GregorianCalendar()); } /** * Sets the local time zone without touching any other Any existing time zone value is replaced, * the other date/time fields are not adjusted in any way. * * @param dateTime the XMPDateTime variable containing the value to be modified. * @return Returns an updated XMPDateTime-object. */ public static XMPDateTime setLocalTimeZone(XMPDateTime dateTime) { Calendar cal = dateTime.getCalendar(); cal.setTimeZone(TimeZone.getDefault()); return new XMPDateTimeImpl(cal); } /** * Make sure a time is UTC. If the time zone is not UTC, the time is * adjusted and the time zone set to be UTC. * * @param dateTime * the XMPDateTime variable containing the time to * be modified. * @return Returns an updated XMPDateTime-object. */ public static XMPDateTime convertToUTCTime(XMPDateTime dateTime) { long timeInMillis = dateTime.getCalendar().getTimeInMillis(); GregorianCalendar cal = new GregorianCalendar(UTC); cal.setGregorianChange(new Date(Long.MIN_VALUE)); cal.setTimeInMillis(timeInMillis); return new XMPDateTimeImpl(cal); } /** * Make sure a time is local. If the time zone is not the local zone, the time is adjusted and * the time zone set to be local. * * @param dateTime the XMPDateTime variable containing the time to be modified. * @return Returns an updated XMPDateTime-object. */ public static XMPDateTime convertToLocalTime(XMPDateTime dateTime) { long timeInMillis = dateTime.getCalendar().getTimeInMillis(); // has automatically local timezone GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(timeInMillis); return new XMPDateTimeImpl(cal); } }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/XMPVersionInfo.java0000644000000000000000000000256111754413532022420 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp; /** * XMP Toolkit Version Information. *

* Version information for the XMP toolkit is stored in the jar-library and available through a * runtime call, {@link XMPMetaFactory#getVersionInfo()}, addition static version numbers are * defined in "version.properties". * * @since 23.01.2006 */ public interface XMPVersionInfo { /** @return Returns the primary release number, the "1" in version "1.2.3". */ int getMajor(); /** @return Returns the secondary release number, the "2" in version "1.2.3". */ int getMinor(); /** @return Returns the tertiary release number, the "3" in version "1.2.3". */ int getMicro(); /** @return Returns a rolling build number, monotonically increasing in a release. */ int getBuild(); /** @return Returns true if this is a debug build. */ boolean isDebug(); /** @return Returns a comprehensive version information string. */ String getMessage(); }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/XMPPathFactory.java0000644000000000000000000002640111754413532022402 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp; import com.adobe.xmp.impl.Utils; import com.adobe.xmp.impl.xpath.XMPPath; import com.adobe.xmp.impl.xpath.XMPPathParser; /** * 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 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: *

*

* *
 *      String path = XMPPathFactory.composeStructFieldPath (schemaNS, "Struct", fieldNS,
 *          "Array");
 *      String path += XMPPathFactory.composeArrayItemPath (schemaNS, "Array" index);
 *      PropertyInteger result = xmpObj.getPropertyAsInteger(schemaNS, path);
 * 
* *
You could also use this code if you want the string form of the integer: *
* *
 *      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 */ public final class XMPPathFactory { /** Private constructor */ private XMPPathFactory() { // EMPTY } /** * Compose the path expression for an item in an array. * * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. * @param 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()]. * * @return 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. */ public static String composeArrayItemPath(String arrayName, int itemIndex) throws XMPException { if (itemIndex > 0) { return arrayName + '[' + itemIndex + ']'; } else if (itemIndex == XMPConst.ARRAY_LAST_ITEM) { return arrayName + "[last()]"; } else { throw new XMPException("Array index must be larger than zero", XMPError.BADINDEX); } } /** * Compose the path expression for a field in a struct. The result can be added to the * path of * * * @param fieldNS The namespace URI for the field. Must not be null or the empty * string. * @param fieldName The name of the field. Must be a simple XML name, must not be * null or the empty string. * @return 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. */ public static String composeStructFieldPath(String fieldNS, String fieldName) throws XMPException { assertFieldNS(fieldNS); assertFieldName(fieldName); XMPPath fieldPath = XMPPathParser.expandXPath(fieldNS, fieldName); if (fieldPath.size() != 2) { throw new XMPException("The field name must be simple", XMPError.BADXPATH); } return '/' + fieldPath.getSegment(XMPPath.STEP_ROOT_PROP).getName(); } /** * Compose the path expression for a qualifier. * * @param qualNS The namespace URI for the qualifier. May be null or the empty * string if the qualifier is in the XML empty namespace. * @param qualName The name of the qualifier. Must be a simple XML name, must not be * null or the empty string. * @return 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. */ public static String composeQualifierPath( String qualNS, String qualName) throws XMPException { assertQualNS(qualNS); assertQualName(qualName); XMPPath qualPath = XMPPathParser.expandXPath(qualNS, qualName); if (qualPath.size() != 2) { throw new XMPException("The qualifier name must be simple", XMPError.BADXPATH); } return "/?" + qualPath.getSegment(XMPPath.STEP_ROOT_PROP).getName(); } /** * 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. * * @param arrayName * The name of the array. May be a general path expression, must * not be null or the empty string. * @param langName * The RFC 3066 code for the desired language. * @return Returns the composed path. This will be of the form * ns:arrayName[@xml:lang='langName'], where * "ns" is the prefix for schemaNS. */ public static String composeLangSelector(String arrayName, String langName) { return arrayName + "[?xml:lang=\"" + Utils.normalizeLangValue(langName) + "\"]"; } /** * 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" );
	 * 
* *
* * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. * @param fieldNS The namespace URI for the field used as the selector. Must not be * null or the empty string. * @param 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. * @param fieldValue The desired value of the field. * @return 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. */ public static String composeFieldSelector(String arrayName, String fieldNS, String fieldName, String fieldValue) throws XMPException { XMPPath fieldPath = XMPPathParser.expandXPath(fieldNS, fieldName); if (fieldPath.size() != 2) { throw new XMPException("The fieldName name must be simple", XMPError.BADXPATH); } return arrayName + '[' + fieldPath.getSegment(XMPPath.STEP_ROOT_PROP).getName() + "=\"" + fieldValue + "\"]"; } /** * ParameterAsserts that a qualifier namespace is set. * @param qualNS a qualifier namespace * @throws XMPException Qualifier schema is null or empty */ private static void assertQualNS(String qualNS) throws XMPException { if (qualNS == null || qualNS.length() == 0) { throw new XMPException("Empty qualifier namespace URI", XMPError.BADSCHEMA); } } /** * ParameterAsserts that a qualifier name is set. * @param qualName a qualifier name or path * @throws XMPException Qualifier name is null or empty */ private static void assertQualName(String qualName) throws XMPException { if (qualName == null || qualName.length() == 0) { throw new XMPException("Empty qualifier name", XMPError.BADXPATH); } } /** * ParameterAsserts that a struct field namespace is set. * @param fieldNS a struct field namespace * @throws XMPException Struct field schema is null or empty */ private static void assertFieldNS(String fieldNS) throws XMPException { if (fieldNS == null || fieldNS.length() == 0) { throw new XMPException("Empty field namespace URI", XMPError.BADSCHEMA); } } /** * ParameterAsserts that a struct field name is set. * @param fieldName a struct field name or path * @throws XMPException Struct field name is null or empty */ private static void assertFieldName(String fieldName) throws XMPException { if (fieldName == null || fieldName.length() == 0) { throw new XMPException("Empty f name", XMPError.BADXPATH); } } }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/XMPMeta.java0000644000000000000000000014571111754413532021052 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp; import java.util.Calendar; import com.adobe.xmp.options.IteratorOptions; import com.adobe.xmp.options.ParseOptions; import com.adobe.xmp.options.PropertyOptions; import com.adobe.xmp.properties.XMPProperty; /** * This class represents the set of XMP metadata as a DOM representation. It has methods to read and * modify all kinds of properties, create an iterator over all properties and serialize the metadata * to a String, byte-array or OutputStream. * * @since 20.01.2006 */ public interface XMPMeta extends Cloneable { // --------------------------------------------------------------------------------------------- // Basic property manipulation functions /** * The property value getter-methods all take a property specification: the first two parameters * are always the top level namespace URI (the "schema" namespace) and the basic name * of the property being referenced. See the introductory discussion of path expression usage * for more information. *

* All of the functions return an object inherited from PropertyBase or * null if the property does not exists. The result object contains the value of * the property and option flags describing the property. Arrays and the non-leaf levels of * nodes do not have values. *

* See {@link PropertyOptions} for detailed information about the options. *

* This is the simplest property getter, mainly for top level simple properties or after using * the path composition functions in XMPPathFactory. * * @param schemaNS The namespace URI for the property. May be null or the empty * string if the first component of the propName path contains a namespace prefix. The * URI must be for a registered namespace. * @param propName The name of the property. May be a general path expression, must not be * null or the empty string. Using a namespace prefix on the first * component is optional. If present without a schemaNS value then the prefix specifies * the namespace. The prefix must be for a registered namespace. If both a schemaNS URI * and propName prefix are present, they must be corresponding parts of a registered * namespace. * @return Returns a XMPProperty containing the value and the options or * null if the property does not exist. * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPProperty getProperty(String schemaNS, String propName) throws XMPException; /** * Provides access to items within an array. The index is passed as an integer, you need not * worry about the path string syntax for array items, convert a loop index to a string, etc. * * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The * constant {@link XMPConst#ARRAY_LAST_ITEM} always refers to the last existing array * item. * @return Returns a XMPProperty containing the value and the options or * null if the property does not exist. * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPProperty getArrayItem(String schemaNS, String arrayName, int itemIndex) throws XMPException; /** * Returns the number of items in the array. * * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @return Returns the number of items in the array. * @throws XMPException Wraps all errors and exceptions that may occur. */ int countArrayItems(String schemaNS, String arrayName) throws XMPException; /** * Provides access to fields within a nested structure. The namespace for the field is passed as * a URI, you need not worry about the path string syntax. *

* The names of fields should be XML qualified names, that is within an XML namespace. The path * syntax for a qualified name uses the namespace prefix. This is unreliable since the prefix is * never guaranteed. The URI is the formal name, the prefix is just a local shorthand in a given * sequence of XML text. * * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. * @param structName The name of the struct. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the * schemaNS parameter. * @param fieldName The name of the field. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * structName parameter. * @return Returns a XMPProperty containing the value and the options or * null if the property does not exist. Arrays and non-leaf levels of * structs do not have values. * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPProperty getStructField( String schemaNS, String structName, String fieldNS, String fieldName) throws XMPException; /** * Provides access to a qualifier attached to a property. The namespace for the qualifier is * passed as a URI, you need not worry about the path string syntax. In many regards qualifiers * are like struct fields. See the introductory discussion of qualified properties for more * information. *

* The names of qualifiers should be XML qualified names, that is within an XML namespace. The * path syntax for a qualified name uses the namespace prefix. This is unreliable since the * prefix is never guaranteed. The URI is the formal name, the prefix is just a local shorthand * in a given sequence of XML text. *

* Note: Qualifiers are only supported for simple leaf properties at this time. * * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. * @param propName The name of the property to which the qualifier is attached. May be a general * path expression, must not be null or the empty string. Has the same * namespace prefix usage as in getProperty(). * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the * schemaNS parameter. * @param qualName The name of the qualifier. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * propName parameter. * @return Returns a XMPProperty containing the value and the options of the * qualifier or null if the property does not exist. The name of the * qualifier must be a single XML name, must not be null or the empty * string. Has the same namespace prefix usage as the propName parameter. *

* The value of the qualifier is only set if it has one (Arrays and non-leaf levels of * structs do not have values). * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPProperty getQualifier( String schemaNS, String propName, String qualNS, String qualName) throws XMPException; // --------------------------------------------------------------------------------------------- // Functions for setting property values /** * The property value setters all take a property specification, their * differences are in the form of this. The first two parameters are always the top level * namespace URI (the schema namespace) and the basic name of the property being * referenced. See the introductory discussion of path expression usage for more information. *

* All of the functions take a string value for the property and option flags describing the * property. The value must be Unicode in UTF-8 encoding. Arrays and non-leaf levels of structs * do not have values. Empty arrays and structs may be created using appropriate option flags. * All levels of structs that is assigned implicitly are created if necessary. appendArayItem * implicitly creates the named array if necessary. *

* See {@link PropertyOptions} for detailed information about the options. *

* This is the simplest property setter, mainly for top level simple properties or after using * the path composition functions in {@link XMPPathFactory}. * * @param schemaNS The namespace URI for the property. Has the same usage as in getProperty. * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the value for the property (only leaf properties have a value). * Arrays and non-leaf levels of structs do not have values. * Must be null if the value is not relevant.
* The value is automatically detected: Boolean, Integer, Long, Double, XMPDateTime and * byte[] are handled, on all other toString() is called. * * @param options Option flags describing the property. See the earlier description. * @throws XMPException Wraps all errors and exceptions that may occur. */ void setProperty( String schemaNS, String propName, Object propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setProperty(String, String, Object, PropertyOptions) * * @param schemaNS The namespace URI * @param propName The name of the property * @param propValue the value for the property * @throws XMPException Wraps all errors and exceptions */ void setProperty( String schemaNS, String propName, Object propValue) throws XMPException; /** * Replaces an item within an array. The index is passed as an integer, you need not worry about * the path string syntax for array items, convert a loop index to a string, etc. The array * passed must already exist. In normal usage the selected array item is modified. A new item is * automatically appended if the index is the array size plus 1. * * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty. * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. To address * the last existing item, use {@link XMPMeta#countArrayItems(String, String)} to find * out the length of the array. * @param itemValue the new value of the array item. Has the same usage as propValue in * setProperty(). * @param options the set options for the item. * @throws XMPException Wraps all errors and exceptions that may occur. */ void setArrayItem( String schemaNS, String arrayName, int itemIndex, String itemValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setArrayItem(String, String, int, String, PropertyOptions) * * @param schemaNS The namespace URI * @param arrayName The name of the array * @param itemIndex The index to insert the new item * @param itemValue the new value of the array item * @throws XMPException Wraps all errors and exceptions */ void setArrayItem( String schemaNS, String arrayName, int itemIndex, String itemValue) throws XMPException; /** * Inserts an item into an array previous to the given index. The index is passed as an integer, * you need not worry about the path string syntax for array items, convert a loop index to a * string, etc. The array passed must already exist. In normal usage the selected array item is * modified. A new item is automatically appended if the index is the array size plus 1. * * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty. * @param itemIndex The index to insert the new item. Arrays in XMP are indexed from 1. Use * XMPConst.ARRAY_LAST_ITEM to append items. * @param itemValue the new value of the array item. Has the same usage as * propValue in setProperty(). * @param options the set options that decide about the kind of the node. * @throws XMPException Wraps all errors and exceptions that may occur. */ void insertArrayItem( String schemaNS, String arrayName, int itemIndex, String itemValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#insertArrayItem(String, String, int, String, PropertyOptions) * * @param schemaNS The namespace URI for the array * @param arrayName The name of the array * @param itemIndex The index to insert the new item * @param itemValue the value of the array item * @throws XMPException Wraps all errors and exceptions */ void insertArrayItem( String schemaNS, String arrayName, int itemIndex, String itemValue) throws XMPException; /** * Simplifies the construction of an array by not requiring that you pre-create an empty array. * The array that is assigned is created automatically if it does not yet exist. Each call to * appendArrayItem() appends an item to the array. The corresponding parameters have the same * use as setArrayItem(). The arrayOptions parameter is used to specify what kind of array. If * the array exists, it must have the specified form. * * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. * @param arrayName The name of the array. May be a general path expression, must not be null or * the empty string. Has the same namespace prefix usage as propPath in getProperty. * @param arrayOptions Option flags describing the array form. The only valid options are *

* Note: the array options only need to be provided if the array is not * already existing, otherwise you can set them to null or use * {@link XMPMeta#appendArrayItem(String, String, String)}. * @param itemValue the value of the array item. Has the same usage as propValue in getProperty. * @param itemOptions Option flags describing the item to append ({@link PropertyOptions}) * @throws XMPException Wraps all errors and exceptions that may occur. */ void appendArrayItem( String schemaNS, String arrayName, PropertyOptions arrayOptions, String itemValue, PropertyOptions itemOptions) throws XMPException; /** * @see XMPMeta#appendArrayItem(String, String, PropertyOptions, String, PropertyOptions) * * @param schemaNS The namespace URI for the array * @param arrayName The name of the array * @param itemValue the value of the array item * @throws XMPException Wraps all errors and exceptions */ void appendArrayItem( String schemaNS, String arrayName, String itemValue) throws XMPException; /** * Provides access to fields within a nested structure. The namespace for the field is passed as * a URI, you need not worry about the path string syntax. The names of fields should be XML * qualified names, that is within an XML namespace. The path syntax for a qualified name uses * the namespace prefix, which is unreliable because the prefix is never guaranteed. The URI is * the formal name, the prefix is just a local shorthand in a given sequence of XML text. * * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. * @param structName The name of the struct. May be a general path expression, must not be null * or the empty string. Has the same namespace prefix usage as propName in getProperty. * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the * schemaNS parameter. * @param fieldName The name of the field. Must be a single XML name, must not be null or the * empty string. Has the same namespace prefix usage as the structName parameter. * @param fieldValue the value of thefield, if the field has a value. * Has the same usage as propValue in getProperty. * @param options Option flags describing the field. See the earlier description. * @throws XMPException Wraps all errors and exceptions that may occur. */ void setStructField( String schemaNS, String structName, String fieldNS, String fieldName, String fieldValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setStructField(String, String, String, String, String, PropertyOptions) * * @param schemaNS The namespace URI for the struct * @param structName The name of the struct * @param fieldNS The namespace URI for the field * @param fieldName The name of the field * @param fieldValue the value of the field * @throws XMPException Wraps all errors and exceptions */ void setStructField( String schemaNS, String structName, String fieldNS, String fieldName, String fieldValue) throws XMPException; /** * Provides access to a qualifier attached to a property. The namespace for the qualifier is * passed as a URI, you need not worry about the path string syntax. In many regards qualifiers * are like struct fields. See the introductory discussion of qualified properties for more * information. The names of qualifiers should be XML qualified names, that is within an XML * namespace. The path syntax for a qualified name uses the namespace prefix, which is * unreliable because the prefix is never guaranteed. The URI is the formal name, the prefix is * just a local shorthand in a given sequence of XML text. The property the qualifier * will be attached has to exist. * * @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty. * @param propName The name of the property to which the qualifier is attached. Has the same * usage as in getProperty. * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the * schemaNS parameter. * @param qualName The name of the qualifier. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * propName parameter. * @param qualValue A pointer to the null terminated UTF-8 string that is the * value of the qualifier, if the qualifier has a value. Has the same usage as propValue * in getProperty. * @param options Option flags describing the qualifier. See the earlier description. * @throws XMPException Wraps all errors and exceptions that may occur. */ void setQualifier( String schemaNS, String propName, String qualNS, String qualName, String qualValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setQualifier(String, String, String, String, String, PropertyOptions) * * @param schemaNS The namespace URI for the struct * @param propName The name of the property to which the qualifier is attached * @param qualNS The namespace URI for the qualifier * @param qualName The name of the qualifier * @param qualValue the value of the qualifier * @throws XMPException Wraps all errors and exceptions */ void setQualifier( String schemaNS, String propName, String qualNS, String qualName, String qualValue) throws XMPException; // --------------------------------------------------------------------------------------------- // Functions for deleting and detecting properties. These should be obvious from the // descriptions of the getters and setters. /** * Deletes the given XMP subtree rooted at the given property. It is not an error if the * property does not exist. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. Has the same usage as in getProperty. */ void deleteProperty(String schemaNS, String propName); /** * Deletes the given XMP subtree rooted at the given array item. It is not an error if the array * item does not exist. * * @param schemaNS The namespace URI for the array. Has the same usage as in getProperty. * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The * constant XMPConst.ARRAY_LAST_ITEM always refers to the last * existing array item. */ void deleteArrayItem(String schemaNS, String arrayName, int itemIndex); /** * Deletes the given XMP subtree rooted at the given struct field. It is not an error if the * field does not exist. * * @param schemaNS The namespace URI for the struct. Has the same usage as in * getProperty(). * @param structName The name of the struct. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty. * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the * schemaNS parameter. * @param fieldName The name of the field. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * structName parameter. */ void deleteStructField(String schemaNS, String structName, String fieldNS, String fieldName); /** * Deletes the given XMP subtree rooted at the given qualifier. It is not an error if the * qualifier does not exist. * * @param schemaNS The namespace URI for the struct. Has the same usage as in * getProperty(). * @param propName The name of the property to which the qualifier is attached. Has the same * usage as in getProperty. * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the * schemaNS parameter. * @param qualName The name of the qualifier. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * propName parameter. */ void deleteQualifier(String schemaNS, String propName, String qualNS, String qualName); /** * Returns whether the property exists. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns true if the property exists. */ boolean doesPropertyExist(String schemaNS, String propName); /** * Tells if the array item exists. * * @param schemaNS The namespace URI for the array. Has the same usage as in * getProperty(). * @param arrayName The name of the array. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The * constant XMPConst.ARRAY_LAST_ITEM always refers to the last * existing array item. * @return Returns true if the array exists, false otherwise. */ boolean doesArrayItemExist(String schemaNS, String arrayName, int itemIndex); /** * DoesStructFieldExist tells if the struct field exists. * * @param schemaNS The namespace URI for the struct. Has the same usage as in * getProperty(). * @param structName The name of the struct. May be a general path expression, must not be * null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the * schemaNS parameter. * @param fieldName The name of the field. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * structName parameter. * @return Returns true if the field exists. */ boolean doesStructFieldExist( String schemaNS, String structName, String fieldNS, String fieldName); /** * DoesQualifierExist tells if the qualifier exists. * * @param schemaNS The namespace URI for the struct. Has the same usage as in * getProperty(). * @param propName The name of the property to which the qualifier is attached. Has the same * usage as in getProperty(). * @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the * schemaNS parameter. * @param qualName The name of the qualifier. Must be a single XML name, must not be * null or the empty string. Has the same namespace prefix usage as the * propName parameter. * @return Returns true if the qualifier exists. */ boolean doesQualifierExist(String schemaNS, String propName, String qualNS, String qualName); // --------------------------------------------------------------------------------------------- // Specialized Get and Set functions /** * These functions provide convenient support for localized text properties, including a number * of special and obscure aspects. Localized text properties are stored in alt-text arrays. They * allow multiple concurrent localizations of a property value, for example a document title or * copyright in several languages. The most important aspect of these functions is that they * select an appropriate array item based on one or two RFC 3066 language tags. One of these * languages, the "specific" language, is preferred and selected if there is an exact match. For * many languages it is also possible to define a "generic" language that may be used if there * is no specific language match. The generic language must be a valid RFC 3066 primary subtag, * or the empty string. For example, a specific language of "en-US" should be used in the US, * and a specific language of "en-UK" should be used in England. It is also appropriate to use * "en" as the generic language in each case. If a US document goes to England, the "en-US" * title is selected by using the "en" generic language and the "en-UK" specific language. It is * considered poor practice, but allowed, to pass a specific language that is just an RFC 3066 * primary tag. For example "en" is not a good specific language, it should only be used as a * generic language. Passing "i" or "x" as the generic language is also considered poor practice * but allowed. Advice from the W3C about the use of RFC 3066 language tags can be found at: * http://www.w3.org/International/articles/language-tags/ *

* Note: RFC 3066 language tags must be treated in a case insensitive manner. The XMP * Toolkit does this by normalizing their capitalization: *

* The XMP toolkit normalizes alt-text arrays such that the x-default item is the first item. * The SetLocalizedText function has several special features related to the x-default item, see * its description for details. The selection of the array item is the same for GetLocalizedText * and SetLocalizedText: * * A partial match with the generic language is where the start of the item's language matches * the generic string and the next character is '-'. An exact match is also recognized as a * degenerate case. It is fine to pass x-default as the specific language. In this case, * selection of an x-default item is an exact match by the first rule, not a selection by the * 3rd rule. The last 2 rules are fallbacks used when the specific and generic languages fail to * produce a match. getLocalizedText returns information about a selected item in * an alt-text array. The array item is selected according to the rules given above. * * Note: In a future version of this API a method * using Java java.lang.Locale will be added. * * @param schemaNS The namespace URI for the alt-text array. Has the same usage as in * getProperty(). * @param altTextName The name of the alt-text array. May be a general path expression, must not * be null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param genericLang The name of the generic language as an RFC 3066 primary subtag. May be * null or the empty string if no generic language is wanted. * @param specificLang The name of the specific language as an RFC 3066 tag. Must not be * null or the empty string. * @return Returns an XMPProperty containing the value, the actual language and * the options if an appropriate alternate collection item exists, null * if the property. * does not exist. * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPProperty getLocalizedText( String schemaNS, String altTextName, String genericLang, String specificLang) throws XMPException; /** * Modifies the value of a selected item in an alt-text array. Creates an appropriate array item * if necessary, and handles special cases for the x-default item. If the selected item is from * a match with the specific language, the value of that item is modified. If the existing value * of that item matches the existing value of the x-default item, the x-default item is also * modified. If the array only has 1 existing item (which is not x-default), an x-default item * is added with the given value. If the selected item is from a match with the generic language * and there are no other generic matches, the value of that item is modified. If the existing * value of that item matches the existing value of the x-default item, the x-default item is * also modified. If the array only has 1 existing item (which is not x-default), an x-default * item is added with the given value. If the selected item is from a partial match with the * generic language and there are other partial matches, a new item is created for the specific * language. The x-default item is not modified. If the selected item is from the last 2 rules * then a new item is created for the specific language. If the array only had an x-default * item, the x-default item is also modified. If the array was empty, items are created for the * specific language and x-default. * * Note: In a future version of this API a method * using Java java.lang.Locale will be added. * * * @param schemaNS The namespace URI for the alt-text array. Has the same usage as in * getProperty(). * @param altTextName The name of the alt-text array. May be a general path expression, must not * be null or the empty string. Has the same namespace prefix usage as * propName in getProperty(). * @param genericLang The name of the generic language as an RFC 3066 primary subtag. May be * null or the empty string if no generic language is wanted. * @param specificLang The name of the specific language as an RFC 3066 tag. Must not be * null or the empty string. * @param itemValue A pointer to the null terminated UTF-8 string that is the new * value for the appropriate array item. * @param options Option flags, none are defined at present. * @throws XMPException Wraps all errors and exceptions that may occur. */ void setLocalizedText( String schemaNS, String altTextName, String genericLang, String specificLang, String itemValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setLocalizedText(String, String, String, String, String, PropertyOptions) * * @param schemaNS The namespace URI for the alt-text array * @param altTextName The name of the alt-text array * @param genericLang The name of the generic language * @param specificLang The name of the specific language * @param itemValue the new value for the appropriate array item * @throws XMPException Wraps all errors and exceptions */ void setLocalizedText( String schemaNS, String altTextName, String genericLang, String specificLang, String itemValue) throws XMPException; // --------------------------------------------------------------------------------------------- // Functions accessing properties as binary values. /** * These are very similar to getProperty() and SetProperty() above, * but the value is returned or provided in a literal form instead of as a UTF-8 string. * The path composition functions in XMPPathFactory may be used to compose an path * expression for fields in nested structures, items in arrays, or qualifiers. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a Boolean value or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ Boolean getPropertyBoolean(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns an Integer value or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ Integer getPropertyInteger(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a Long value or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ Long getPropertyLong(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a Double value or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ Double getPropertyDouble(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a XMPDateTime-object or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ XMPDateTime getPropertyDate(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a Java Calendar-object or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ Calendar getPropertyCalendar(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a byte[]-array contained the decoded base64 value * or null if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ byte[] getPropertyBase64(String schemaNS, String propName) throws XMPException; /** * Convenience method to retrieve the literal value of a property. * Note: There is no setPropertyString(), * because setProperty() sets a string value. * * @param schemaNS The namespace URI for the property. Has the same usage as in * getProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @return Returns a String value or null * if the property does not exist. * @throws XMPException Wraps all exceptions that may occur, * especially conversion errors. */ String getPropertyString(String schemaNS, String propName) throws XMPException; /** * Convenience method to set a property to a literal boolean value. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the literal property value as boolean. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyBoolean( String schemaNS, String propName, boolean propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyBoolean(String, String, boolean, PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the literal property value as boolean * @throws XMPException Wraps all exceptions */ void setPropertyBoolean( String schemaNS, String propName, boolean propValue) throws XMPException; /** * Convenience method to set a property to a literal int value. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the literal property value as int. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyInteger( String schemaNS, String propName, int propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyInteger(String, String, int, PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the literal property value as int * @throws XMPException Wraps all exceptions */ void setPropertyInteger( String schemaNS, String propName, int propValue) throws XMPException; /** * Convenience method to set a property to a literal long value. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the literal property value as long. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyLong( String schemaNS, String propName, long propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyLong(String, String, long, PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the literal property value as long * @throws XMPException Wraps all exceptions */ void setPropertyLong( String schemaNS, String propName, long propValue) throws XMPException; /** * Convenience method to set a property to a literal double value. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the literal property value as double. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyDouble( String schemaNS, String propName, double propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyDouble(String, String, double, PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the literal property value as double * @throws XMPException Wraps all exceptions */ void setPropertyDouble( String schemaNS, String propName, double propValue) throws XMPException; /** * Convenience method to set a property with an XMPDateTime-object, * which is serialized to an ISO8601 date. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the property value as XMPDateTime. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyDate( String schemaNS, String propName, XMPDateTime propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyDate(String, String, XMPDateTime, PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the property value as XMPDateTime * @throws XMPException Wraps all exceptions */ void setPropertyDate( String schemaNS, String propName, XMPDateTime propValue) throws XMPException; /** * Convenience method to set a property with a Java Calendar-object, * which is serialized to an ISO8601 date. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the property value as Java Calendar. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyCalendar( String schemaNS, String propName, Calendar propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyCalendar(String, String, Calendar, PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the property value as Calendar * @throws XMPException Wraps all exceptions */ void setPropertyCalendar( String schemaNS, String propName, Calendar propValue) throws XMPException; /** * Convenience method to set a property from a binary byte[]-array, * which is serialized as base64-string. * * @param schemaNS The namespace URI for the property. Has the same usage as in * setProperty(). * @param propName The name of the property. * Has the same usage as in getProperty(). * @param propValue the literal property value as byte array. * @param options options of the property to set (optional). * @throws XMPException Wraps all exceptions that may occur. */ void setPropertyBase64( String schemaNS, String propName, byte[] propValue, PropertyOptions options) throws XMPException; /** * @see XMPMeta#setPropertyBase64(String, String, byte[], PropertyOptions) * * @param schemaNS The namespace URI for the property * @param propName The name of the property * @param propValue the literal property value as byte array * @throws XMPException Wraps all exceptions */ void setPropertyBase64( String schemaNS, String propName, byte[] propValue) throws XMPException; /** * Constructs an iterator for the properties within this XMP object. * * @return Returns an XMPIterator. * @see XMPMeta#iterator(String, String, IteratorOptions) * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPIterator iterator() throws XMPException; /** * Constructs an iterator for the properties within this XMP object using some options. * * @param options Option flags to control the iteration. * @return Returns an XMPIterator. * @see XMPMeta#iterator(String, String, IteratorOptions) * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPIterator iterator(IteratorOptions options) throws XMPException; /** * Construct an iterator for the properties within an XMP object. According to the parameters it iterates the entire data tree, * properties within a specific schema, or a subtree rooted at a specific node. * * @param schemaNS Optional schema namespace URI to restrict the iteration. Omitted (visit all * schema) by passing null or empty String. * @param propName Optional property name to restrict the iteration. May be an arbitrary path * expression. Omitted (visit all properties) by passing null or empty * String. If no schema URI is given, it is ignored. * @param options Option flags to control the iteration. See {@link IteratorOptions} for * details. * @return Returns an XMPIterator for this XMPMeta-object * considering the given options. * @throws XMPException Wraps all errors and exceptions that may occur. */ XMPIterator iterator( String schemaNS, String propName, IteratorOptions options) throws XMPException; /** * This correlates to the about-attribute, * returns the empty String if no name is set. * * @return Returns the name of the XMP object. */ String getObjectName(); /** * @param name Sets the name of the XMP object. */ void setObjectName(String name); /** * @return Returns the unparsed content of the <?xpacket> processing instruction. * This contains normally the attribute-like elements 'begin="<BOM>" * id="W5M0MpCehiHzreSzNTczkc9d"' and possibly the deprecated elements 'bytes="1234"' or * 'encoding="XXX"'. If the parsed packet has not been wrapped into an xpacket, * null is returned. */ String getPacketHeader(); /** * Clones the complete metadata tree. * * @return Returns a deep copy of this instance. */ Object clone(); /** * Sorts the complete datamodel according to the following rules: * */ void sort(); /** * Perform the normalization as a separate parsing step. * Normally it is done during parsing, unless the parsing option * {@link ParseOptions#OMIT_NORMALIZATION} is set to true. * Note: It does no harm to call this method to an already normalized xmp object. * It was a PDF/A requirement to get hand on the unnormalized XMPMeta object. * * @param options optional parsing options. * @throws XMPException Wraps all errors and exceptions that may occur. */ void normalize(ParseOptions options) throws XMPException; /** * Renders this node and the tree unter this node in a human readable form. * @return Returns a multiline string containing the dump. */ String dumpObject(); }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/properties/0000755000000000000000000000000012153406731021114 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/properties/package.html0000644000000000000000000000107511754413532023403 0ustar rootroot Package overview

Package containing the property information classes.

XMPProperty and XMPPropertyInfo are used to report properties when they are retrieved by get-methods or by the iterator. XMPAliasInfo informs about a certain property-to-property alias.

XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/properties/XMPAliasInfo.java0000644000000000000000000000236111754413532024216 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.properties; import com.adobe.xmp.options.AliasOptions; /** * This interface is used to return info about an alias. * * @since 27.01.2006 */ public interface XMPAliasInfo { /** * @return Returns Returns the namespace URI for the base property. */ String getNamespace(); /** * @return Returns the default prefix for the given base property. */ String getPrefix(); /** * @return Returns the path of the base property. */ String getPropName(); /** * @return Returns the kind of the alias. This can be a direct alias * (ARRAY), a simple property to an ordered array * (ARRAY_ORDERED), to an alternate array * (ARRAY_ALTERNATE) or to an alternate text array * (ARRAY_ALT_TEXT). */ AliasOptions getAliasForm(); }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/properties/XMPProperty.java0000644000000000000000000000205211754413532024172 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.properties; import com.adobe.xmp.XMPMeta; import com.adobe.xmp.options.PropertyOptions; /** * This interface is used to return a text property together with its and options. * * @since 23.01.2006 */ public interface XMPProperty { /** * @return Returns the value of the property. */ String getValue(); /** * @return Returns the options of the property. */ PropertyOptions getOptions(); /** * Only set by {@link XMPMeta#getLocalizedText(String, String, String, String)}. * @return Returns the language of the alt-text item. */ String getLanguage(); } XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/properties/XMPPropertyInfo.java0000644000000000000000000000222311754413532025006 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.properties; import com.adobe.xmp.options.PropertyOptions; /** * This interface is used to return a property together with its path and namespace. * It is returned when properties are iterated with the XMPIterator. * * @since 06.07.2006 */ public interface XMPPropertyInfo extends XMPProperty { /** * @return Returns the namespace of the property */ String getNamespace(); /** * @return Returns the path of the property, but only if returned by the iterator. */ String getPath(); /** * @return Returns the value of the property. */ String getValue(); /** * @return Returns the options of the property. */ PropertyOptions getOptions(); } XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/0000755000000000000000000000000012153406731020413 5ustar rootrootXMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/IteratorOptions.java0000644000000000000000000000677611754413532024446 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.options; /** * Options for XMPIterator construction. * * @since 24.01.2006 */ public final class IteratorOptions extends Options { /** Just do the immediate children of the root, default is subtree. */ public static final int JUST_CHILDREN = 0x0100; /** Just do the leaf nodes, default is all nodes in the subtree. * Bugfix #2658965: If this option is set the Iterator returns the namespace * of the leaf instead of the namespace of the base property. */ public static final int JUST_LEAFNODES = 0x0200; /** Return just the leaf part of the path, default is the full path. */ public static final int JUST_LEAFNAME = 0x0400; // /** Include aliases, default is just actual properties. Note: Not supported. // * @deprecated it is commonly preferred to work with the base properties */ // public static final int INCLUDE_ALIASES = 0x0800; /** Omit all qualifiers. */ public static final int OMIT_QUALIFIERS = 0x1000; /** * @return Returns whether the option is set. */ public boolean isJustChildren() { return getOption(JUST_CHILDREN); } /** * @return Returns whether the option is set. */ public boolean isJustLeafname() { return getOption(JUST_LEAFNAME); } /** * @return Returns whether the option is set. */ public boolean isJustLeafnodes() { return getOption(JUST_LEAFNODES); } /** * @return Returns whether the option is set. */ public boolean isOmitQualifiers() { return getOption(OMIT_QUALIFIERS); } /** * Sets the option and returns the instance. * * @param value the value to set * @return Returns the instance to call more set-methods. */ public IteratorOptions setJustChildren(boolean value) { setOption(JUST_CHILDREN, value); return this; } /** * Sets the option and returns the instance. * * @param value the value to set * @return Returns the instance to call more set-methods. */ public IteratorOptions setJustLeafname(boolean value) { setOption(JUST_LEAFNAME, value); return this; } /** * Sets the option and returns the instance. * * @param value the value to set * @return Returns the instance to call more set-methods. */ public IteratorOptions setJustLeafnodes(boolean value) { setOption(JUST_LEAFNODES, value); return this; } /** * Sets the option and returns the instance. * * @param value the value to set * @return Returns the instance to call more set-methods. */ public IteratorOptions setOmitQualifiers(boolean value) { setOption(OMIT_QUALIFIERS, value); return this; } /** * @see Options#defineOptionName(int) */ protected String defineOptionName(int option) { switch (option) { case JUST_CHILDREN : return "JUST_CHILDREN"; case JUST_LEAFNODES : return "JUST_LEAFNODES"; case JUST_LEAFNAME : return "JUST_LEAFNAME"; case OMIT_QUALIFIERS : return "OMIT_QUALIFIERS"; default: return null; } } /** * @see Options#getValidOptions() */ protected int getValidOptions() { return JUST_CHILDREN | JUST_LEAFNODES | JUST_LEAFNAME | OMIT_QUALIFIERS; } }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/package.html0000644000000000000000000000164511754413532022705 0ustar rootroot Package overview

Package containing the option classes.

These are used to configure diverse function calls of xmpcore:

XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/SerializeOptions.java0000644000000000000000000002536411754413532024576 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.options; import com.adobe.xmp.XMPException; import com.adobe.xmp.XMPMeta; import com.adobe.xmp.XMPMetaFactory; /** * Options for {@link XMPMetaFactory#serializeToBuffer(XMPMeta, SerializeOptions)}. * * @since 24.01.2006 */ public final class SerializeOptions extends Options { /** Omit the XML packet wrapper. */ public static final int OMIT_PACKET_WRAPPER = 0x0010; /** Mark packet as read-only. Default is a writeable packet. */ public static final int READONLY_PACKET = 0x0020; /** * Use a compact form of RDF. * The compact form is the default serialization format (this flag is technically ignored). * To serialize to the canonical form, set the flag USE_CANONICAL_FORMAT. * If both flags "compact" and "canonical" are set, canonical is used. */ public static final int USE_COMPACT_FORMAT = 0x0040; /** Use the canonical form of RDF if set. By default the compact form is used */ public static final int USE_CANONICAL_FORMAT = 0x0080; /** * Include a padding allowance for a thumbnail image. If no xmp:Thumbnails property * is present, the typical space for a JPEG thumbnail is used. */ public static final int INCLUDE_THUMBNAIL_PAD = 0x0100; /** * The padding parameter provides the overall packet length. The actual amount of padding is * computed. An exception is thrown if the packet exceeds this length with no padding. */ public static final int EXACT_PACKET_LENGTH = 0x0200; /** Omit the <x:xmpmeta&bt;-tag */ public static final int OMIT_XMPMETA_ELEMENT = 0x1000; /** Sort the struct properties and qualifier before serializing */ public static final int SORT = 0x2000; // --------------------------------------------------------------------------------------------- // encoding bit constants /** Bit indicating little endian encoding, unset is big endian */ private static final int LITTLEENDIAN_BIT = 0x0001; /** Bit indication UTF16 encoding. */ private static final int UTF16_BIT = 0x0002; /** UTF8 encoding; this is the default */ public static final int ENCODE_UTF8 = 0; /** UTF16BE encoding */ public static final int ENCODE_UTF16BE = UTF16_BIT; /** UTF16LE encoding */ public static final int ENCODE_UTF16LE = UTF16_BIT | LITTLEENDIAN_BIT; /** */ private static final int ENCODING_MASK = UTF16_BIT | LITTLEENDIAN_BIT; /** * The amount of padding to be added if a writeable XML packet is created. If zero is passed * (the default) an appropriate amount of padding is computed. */ private int padding = 2048; /** * The string to be used as a line terminator. If empty it defaults to; linefeed, U+000A, the * standard XML newline. */ private String newline = "\n"; /** * The string to be used for each level of indentation in the serialized * RDF. If empty it defaults to two ASCII spaces, U+0020. */ private String indent = " "; /** * The number of levels of indentation to be used for the outermost XML element in the * serialized RDF. This is convenient when embedding the RDF in other text, defaults to 0. */ private int baseIndent = 0; /** Omits the Toolkit version attribute, not published, only used for Unit tests. */ private boolean omitVersionAttribute = false; /** * Default constructor. */ public SerializeOptions() { // reveal default constructor } /** * Constructor using inital options * @param options the inital options * @throws XMPException Thrown if options are not consistant. */ public SerializeOptions(int options) throws XMPException { super(options); } /** * @return Returns the option. */ public boolean getOmitPacketWrapper() { return getOption(OMIT_PACKET_WRAPPER); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setOmitPacketWrapper(boolean value) { setOption(OMIT_PACKET_WRAPPER, value); return this; } /** * @return Returns the option. */ public boolean getOmitXmpMetaElement() { return getOption(OMIT_XMPMETA_ELEMENT); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setOmitXmpMetaElement(boolean value) { setOption(OMIT_XMPMETA_ELEMENT, value); return this; } /** * @return Returns the option. */ public boolean getReadOnlyPacket() { return getOption(READONLY_PACKET); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setReadOnlyPacket(boolean value) { setOption(READONLY_PACKET, value); return this; } /** * @return Returns the option. */ public boolean getUseCompactFormat() { return getOption(USE_COMPACT_FORMAT); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setUseCompactFormat(boolean value) { setOption(USE_COMPACT_FORMAT, value); return this; } /** * @return Returns the option. */ public boolean getUseCanonicalFormat() { return getOption(USE_CANONICAL_FORMAT); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setUseCanonicalFormat(boolean value) { setOption(USE_CANONICAL_FORMAT, value); return this; } /** * @return Returns the option. */ public boolean getIncludeThumbnailPad() { return getOption(INCLUDE_THUMBNAIL_PAD); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setIncludeThumbnailPad(boolean value) { setOption(INCLUDE_THUMBNAIL_PAD, value); return this; } /** * @return Returns the option. */ public boolean getExactPacketLength() { return getOption(EXACT_PACKET_LENGTH); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setExactPacketLength(boolean value) { setOption(EXACT_PACKET_LENGTH, value); return this; } /** * @return Returns the option. */ public boolean getSort() { return getOption(SORT); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setSort(boolean value) { setOption(SORT, value); return this; } /** * @return Returns the option. */ public boolean getEncodeUTF16BE() { return (getOptions() & ENCODING_MASK) == ENCODE_UTF16BE; } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setEncodeUTF16BE(boolean value) { // clear unicode bits setOption(UTF16_BIT | LITTLEENDIAN_BIT, false); setOption(ENCODE_UTF16BE, value); return this; } /** * @return Returns the option. */ public boolean getEncodeUTF16LE() { return (getOptions() & ENCODING_MASK) == ENCODE_UTF16LE; } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public SerializeOptions setEncodeUTF16LE(boolean value) { // clear unicode bits setOption(UTF16_BIT | LITTLEENDIAN_BIT, false); setOption(ENCODE_UTF16LE, value); return this; } /** * @return Returns the baseIndent. */ public int getBaseIndent() { return baseIndent; } /** * @param baseIndent * The baseIndent to set. * @return Returns the instance to call more set-methods. */ public SerializeOptions setBaseIndent(int baseIndent) { this.baseIndent = baseIndent; return this; } /** * @return Returns the indent. */ public String getIndent() { return indent; } /** * @param indent * The indent to set. * @return Returns the instance to call more set-methods. */ public SerializeOptions setIndent(String indent) { this.indent = indent; return this; } /** * @return Returns the newline. */ public String getNewline() { return newline; } /** * @param newline * The newline to set. * @return Returns the instance to call more set-methods. */ public SerializeOptions setNewline(String newline) { this.newline = newline; return this; } /** * @return Returns the padding. */ public int getPadding() { return padding; } /** * @param padding * The padding to set. * @return Returns the instance to call more set-methods. */ public SerializeOptions setPadding(int padding) { this.padding = padding; return this; } /** * @return Returns whether the Toolkit version attribute shall be omitted. * Note: This options can only be set by unit tests. */ public boolean getOmitVersionAttribute() { return omitVersionAttribute; } /** * @return Returns the encoding as Java encoding String. */ public String getEncoding() { if (getEncodeUTF16BE()) { return "UTF-16BE"; } else if (getEncodeUTF16LE()) { return "UTF-16LE"; } else { return "UTF-8"; } } /** * * @return Returns clone of this SerializeOptions-object with the same options set. * @throws CloneNotSupportedException Cannot happen in this place. */ public Object clone() throws CloneNotSupportedException { SerializeOptions clone; try { clone = new SerializeOptions(getOptions()); clone.setBaseIndent(baseIndent); clone.setIndent(indent); clone.setNewline(newline); clone.setPadding(padding); return clone; } catch (XMPException e) { // This cannot happen, the options are already checked in "this" object. return null; } } /** * @see Options#defineOptionName(int) */ protected String defineOptionName(int option) { switch (option) { case OMIT_PACKET_WRAPPER : return "OMIT_PACKET_WRAPPER"; case READONLY_PACKET : return "READONLY_PACKET"; case USE_COMPACT_FORMAT : return "USE_COMPACT_FORMAT"; // case USE_CANONICAL_FORMAT : return "USE_CANONICAL_FORMAT"; case INCLUDE_THUMBNAIL_PAD : return "INCLUDE_THUMBNAIL_PAD"; case EXACT_PACKET_LENGTH : return "EXACT_PACKET_LENGTH"; case OMIT_XMPMETA_ELEMENT: return "OMIT_XMPMETA_ELEMENT"; case SORT : return "NORMALIZED"; default: return null; } } /** * @see Options#getValidOptions() */ protected int getValidOptions() { return OMIT_PACKET_WRAPPER | READONLY_PACKET | USE_COMPACT_FORMAT | // USE_CANONICAL_FORMAT | INCLUDE_THUMBNAIL_PAD | OMIT_XMPMETA_ELEMENT | EXACT_PACKET_LENGTH | SORT; } }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/ParseOptions.java0000644000000000000000000000751011754413532023712 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.options; import java.io.InputStream; import com.adobe.xmp.XMPMetaFactory; /** * Options for {@link XMPMetaFactory#parse(InputStream, ParseOptions)}. * * @since 24.01.2006 */ public final class ParseOptions extends Options { /** Require a surrounding "x:xmpmeta" element in the xml-document. */ public static final int REQUIRE_XMP_META = 0x0001; /** Do not reconcile alias differences, throw an exception instead. */ public static final int STRICT_ALIASING = 0x0004; /** Convert ASCII control characters 0x01 - 0x1F (except tab, cr, and lf) to spaces. */ public static final int FIX_CONTROL_CHARS = 0x0008; /** If the input is not unicode, try to parse it as ISO-8859-1. */ public static final int ACCEPT_LATIN_1 = 0x0010; /** Do not carry run the XMPNormalizer on a packet, leave it as it is. */ public static final int OMIT_NORMALIZATION = 0x0020; /** * Sets the options to the default values. */ public ParseOptions() { setOption(FIX_CONTROL_CHARS | ACCEPT_LATIN_1, true); } /** * @return Returns the requireXMPMeta. */ public boolean getRequireXMPMeta() { return getOption(REQUIRE_XMP_META); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public ParseOptions setRequireXMPMeta(boolean value) { setOption(REQUIRE_XMP_META, value); return this; } /** * @return Returns the strictAliasing. */ public boolean getStrictAliasing() { return getOption(STRICT_ALIASING); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public ParseOptions setStrictAliasing(boolean value) { setOption(STRICT_ALIASING, value); return this; } /** * @return Returns the strictAliasing. */ public boolean getFixControlChars() { return getOption(FIX_CONTROL_CHARS); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public ParseOptions setFixControlChars(boolean value) { setOption(FIX_CONTROL_CHARS, value); return this; } /** * @return Returns the strictAliasing. */ public boolean getAcceptLatin1() { return getOption(ACCEPT_LATIN_1); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public ParseOptions setOmitNormalization(boolean value) { setOption(OMIT_NORMALIZATION, value); return this; } /** * @return Returns the option "omit normalization". */ public boolean getOmitNormalization() { return getOption(OMIT_NORMALIZATION); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public ParseOptions setAcceptLatin1(boolean value) { setOption(ACCEPT_LATIN_1, value); return this; } /** * @see Options#defineOptionName(int) */ protected String defineOptionName(int option) { switch (option) { case REQUIRE_XMP_META : return "REQUIRE_XMP_META"; case STRICT_ALIASING : return "STRICT_ALIASING"; case FIX_CONTROL_CHARS: return "FIX_CONTROL_CHARS"; case ACCEPT_LATIN_1: return "ACCEPT_LATIN_1"; case OMIT_NORMALIZATION: return "OMIT_NORMALIZATION"; default: return null; } } /** * @see Options#getValidOptions() */ protected int getValidOptions() { return REQUIRE_XMP_META | STRICT_ALIASING | FIX_CONTROL_CHARS | ACCEPT_LATIN_1 | OMIT_NORMALIZATION; } }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/AliasOptions.java0000644000000000000000000001010611754413532023664 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.options; import com.adobe.xmp.XMPException; /** * Options for XMPSchemaRegistryImpl#registerAlias. * * @since 20.02.2006 */ public final class AliasOptions extends Options { /** This is a direct mapping. The actual data type does not matter. */ public static final int PROP_DIRECT = 0; /** The actual is an unordered array, the alias is to the first element of the array. */ public static final int PROP_ARRAY = PropertyOptions.ARRAY; /** The actual is an ordered array, the alias is to the first element of the array. */ public static final int PROP_ARRAY_ORDERED = PropertyOptions.ARRAY_ORDERED; /** The actual is an alternate array, the alias is to the first element of the array. */ public static final int PROP_ARRAY_ALTERNATE = PropertyOptions.ARRAY_ALTERNATE; /** * The actual is an alternate text array, the alias is to the 'x-default' element of the array. */ public static final int PROP_ARRAY_ALT_TEXT = PropertyOptions.ARRAY_ALT_TEXT; /** * @see Options#Options() */ public AliasOptions() { // EMPTY } /** * @param options the options to init with * @throws XMPException If options are not consistant */ public AliasOptions(int options) throws XMPException { super(options); } /** * @return Returns if the alias is of the simple form. */ public boolean isSimple() { return getOptions() == PROP_DIRECT; } /** * @return Returns the option. */ public boolean isArray() { return getOption(PROP_ARRAY); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public AliasOptions setArray(boolean value) { setOption(PROP_ARRAY, value); return this; } /** * @return Returns the option. */ public boolean isArrayOrdered() { return getOption(PROP_ARRAY_ORDERED); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public AliasOptions setArrayOrdered(boolean value) { setOption(PROP_ARRAY | PROP_ARRAY_ORDERED, value); return this; } /** * @return Returns the option. */ public boolean isArrayAlternate() { return getOption(PROP_ARRAY_ALTERNATE); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public AliasOptions setArrayAlternate(boolean value) { setOption(PROP_ARRAY | PROP_ARRAY_ORDERED | PROP_ARRAY_ALTERNATE, value); return this; } /** * @return Returns the option. */ public boolean isArrayAltText() { return getOption(PROP_ARRAY_ALT_TEXT); } /** * @param value the value to set * @return Returns the instance to call more set-methods. */ public AliasOptions setArrayAltText(boolean value) { setOption(PROP_ARRAY | PROP_ARRAY_ORDERED | PROP_ARRAY_ALTERNATE | PROP_ARRAY_ALT_TEXT, value); return this; } /** * @return returns a {@link PropertyOptions}s object * @throws XMPException If the options are not consistant. */ public PropertyOptions toPropertyOptions() throws XMPException { return new PropertyOptions(getOptions()); } /** * @see Options#defineOptionName(int) */ protected String defineOptionName(int option) { switch (option) { case PROP_DIRECT : return "PROP_DIRECT"; case PROP_ARRAY : return "ARRAY"; case PROP_ARRAY_ORDERED : return "ARRAY_ORDERED"; case PROP_ARRAY_ALTERNATE : return "ARRAY_ALTERNATE"; case PROP_ARRAY_ALT_TEXT : return "ARRAY_ALT_TEXT"; default: return null; } } /** * @see Options#getValidOptions() */ protected int getValidOptions() { return PROP_DIRECT | PROP_ARRAY | PROP_ARRAY_ORDERED | PROP_ARRAY_ALTERNATE | PROP_ARRAY_ALT_TEXT; } } XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/PropertyOptions.java0000644000000000000000000002355511754413532024473 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.options; import com.adobe.xmp.XMPError; import com.adobe.xmp.XMPException; /** * The property flags are used when properties are fetched from the XMPMeta-object * and provide more detailed information about the property. * * @since 03.07.2006 */ public final class PropertyOptions extends Options { /** */ public static final int NO_OPTIONS = 0x00000000; /** */ public static final int URI = 0x00000002; /** */ public static final int HAS_QUALIFIERS = 0x00000010; /** */ public static final int QUALIFIER = 0x00000020; /** */ public static final int HAS_LANGUAGE = 0x00000040; /** */ public static final int HAS_TYPE = 0x00000080; /** */ public static final int STRUCT = 0x00000100; /** */ public static final int ARRAY = 0x00000200; /** */ public static final int ARRAY_ORDERED = 0x00000400; /** */ public static final int ARRAY_ALTERNATE = 0x00000800; /** */ public static final int ARRAY_ALT_TEXT = 0x00001000; /** */ public static final int SCHEMA_NODE = 0x80000000; /** may be used in the future */ public static final int DELETE_EXISTING = 0x20000000; /** * Default constructor */ public PropertyOptions() { // reveal default constructor } /** * Intialization constructor * * @param options the initialization options * @throws XMPException If the options are not valid */ public PropertyOptions(int options) throws XMPException { super(options); } /** * @return Return whether the property value is a URI. It is serialized to RDF using the * rdf:resource attribute. Not mandatory for URIs, but considered RDF-savvy. */ public boolean isURI() { return getOption(URI); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setURI(boolean value) { setOption(URI, value); return this; } /** * @return Return whether the property has qualifiers. These could be an xml:lang * attribute, an rdf:type property, or a general qualifier. See the * introductory discussion of qualified properties for more information. */ public boolean getHasQualifiers() { return getOption(HAS_QUALIFIERS); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setHasQualifiers(boolean value) { setOption(HAS_QUALIFIERS, value); return this; } /** * @return Return whether this property is a qualifier for some other property. Note that if the * qualifier itself has a structured value, this flag is only set for the top node of * the qualifier's subtree. Qualifiers may have arbitrary structure, and may even have * qualifiers. */ public boolean isQualifier() { return getOption(QUALIFIER); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setQualifier(boolean value) { setOption(QUALIFIER, value); return this; } /** @return Return whether this property has an xml:lang qualifier. */ public boolean getHasLanguage() { return getOption(HAS_LANGUAGE); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setHasLanguage(boolean value) { setOption(HAS_LANGUAGE, value); return this; } /** @return Return whether this property has an rdf:type qualifier. */ public boolean getHasType() { return getOption(HAS_TYPE); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setHasType(boolean value) { setOption(HAS_TYPE, value); return this; } /** @return Return whether this property contains nested fields. */ public boolean isStruct() { return getOption(STRUCT); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setStruct(boolean value) { setOption(STRUCT, value); return this; } /** * @return Return whether this property is an array. By itself this indicates a general * unordered array. It is serialized using an rdf:Bag container. */ public boolean isArray() { return getOption(ARRAY); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setArray(boolean value) { setOption(ARRAY, value); return this; } /** * @return Return whether this property is an ordered array. Appears in conjunction with * getPropValueIsArray(). It is serialized using an rdf:Seq container. */ public boolean isArrayOrdered() { return getOption(ARRAY_ORDERED); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setArrayOrdered(boolean value) { setOption(ARRAY_ORDERED, value); return this; } /** * @return Return whether this property is an alternative array. Appears in conjunction with * getPropValueIsArray(). It is serialized using an rdf:Alt container. */ public boolean isArrayAlternate() { return getOption(ARRAY_ALTERNATE); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setArrayAlternate(boolean value) { setOption(ARRAY_ALTERNATE, value); return this; } /** * @return Return whether this property is an alt-text array. Appears in conjunction with * getPropArrayIsAlternate(). It is serialized using an rdf:Alt container. * Each array element is a simple property with an xml:lang attribute. */ public boolean isArrayAltText() { return getOption(ARRAY_ALT_TEXT); } /** * @param value the value to set * @return Returns this to enable cascaded options. */ public PropertyOptions setArrayAltText(boolean value) { setOption(ARRAY_ALT_TEXT, value); return this; } /** * @param value the value to set * @return Returns this to enable cascaded options. */ /** * @return Returns whether the SCHEMA_NODE option is set. */ public boolean isSchemaNode() { return getOption(SCHEMA_NODE); } /** * @param value the option DELETE_EXISTING to set * @return Returns this to enable cascaded options. */ public PropertyOptions setSchemaNode(boolean value) { setOption(SCHEMA_NODE, value); return this; } //-------------------------------------------------------------------------- convenience methods /** * @return Returns whether the property is of composite type - an array or a struct. */ public boolean isCompositeProperty() { return (getOptions() & (ARRAY | STRUCT)) > 0; } /** * @return Returns whether the property is of composite type - an array or a struct. */ public boolean isSimple() { return (getOptions() & (ARRAY | STRUCT)) == 0; } /** * Compares two options set for array compatibility. * * @param options other options * @return Returns true if the array options of the sets are equal. */ public boolean equalArrayTypes(PropertyOptions options) { return isArray() == options.isArray() && isArrayOrdered() == options.isArrayOrdered() && isArrayAlternate() == options.isArrayAlternate() && isArrayAltText() == options.isArrayAltText(); } /** * Merges the set options of a another options object with this. * If the other options set is null, this objects stays the same. * @param options other options * @throws XMPException If illegal options are provided */ public void mergeWith(PropertyOptions options) throws XMPException { if (options != null) { setOptions(getOptions() | options.getOptions()); } } /** * @return Returns true if only array options are set. */ public boolean isOnlyArrayOptions() { return (getOptions() & ~(ARRAY | ARRAY_ORDERED | ARRAY_ALTERNATE | ARRAY_ALT_TEXT)) == 0; } /** * @see Options#getValidOptions() */ protected int getValidOptions() { return URI | HAS_QUALIFIERS | QUALIFIER | HAS_LANGUAGE | HAS_TYPE | STRUCT | ARRAY | ARRAY_ORDERED | ARRAY_ALTERNATE | ARRAY_ALT_TEXT | SCHEMA_NODE; } /** * @see Options#defineOptionName(int) */ protected String defineOptionName(int option) { switch (option) { case URI : return "URI"; case HAS_QUALIFIERS : return "HAS_QUALIFIER"; case QUALIFIER : return "QUALIFIER"; case HAS_LANGUAGE : return "HAS_LANGUAGE"; case HAS_TYPE: return "HAS_TYPE"; case STRUCT : return "STRUCT"; case ARRAY : return "ARRAY"; case ARRAY_ORDERED : return "ARRAY_ORDERED"; case ARRAY_ALTERNATE : return "ARRAY_ALTERNATE"; case ARRAY_ALT_TEXT : return "ARRAY_ALT_TEXT"; case SCHEMA_NODE : return "SCHEMA_NODE"; default: return null; } } /** * Checks that a node not a struct and array at the same time; * and URI cannot be a struct. * * @param options the bitmask to check. * @throws XMPException Thrown if the options are not consistent. */ public void assertConsistency(int options) throws XMPException { if ((options & STRUCT) > 0 && (options & ARRAY) > 0) { throw new XMPException("IsStruct and IsArray options are mutually exclusive", XMPError.BADOPTIONS); } else if ((options & URI) > 0 && (options & (ARRAY | STRUCT)) > 0) { throw new XMPException("Structs and arrays can't have \"value\" options", XMPError.BADOPTIONS); } } }XMP-Core-JAVA-CS6/XMPCore/src/com/adobe/xmp/options/Options.java0000644000000000000000000001466111754413532022724 0ustar rootroot// ================================================================================================= // ADOBE SYSTEMS INCORPORATED // Copyright 2006 Adobe Systems Incorporated // All Rights Reserved // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms // of the Adobe license agreement accompanying it. // ================================================================================================= package com.adobe.xmp.options; import java.util.HashMap; import java.util.Map; import com.adobe.xmp.XMPError; import com.adobe.xmp.XMPException; /** * The base class for a collection of 32 flag bits. Individual flags are defined as enum value bit * masks. Inheriting classes add convenience accessor methods. * * @since 24.01.2006 */ public abstract class Options { /** the internal int containing all options */ private int options = 0; /** a map containing the bit names */ private Map optionNames = null; /** * The default constructor. */ public Options() { // EMTPY } /** * Constructor with the options bit mask. * * @param options the options bit mask * @throws XMPException If the options are not correct */ public Options(int options) throws XMPException { assertOptionsValid(options); setOptions(options); } /** * Resets the options. */ public void clear() { options = 0; } /** * @param optionBits an option bitmask * @return Returns true, if this object is equal to the given options. */ public boolean isExactly(int optionBits) { return getOptions() == optionBits; } /** * @param optionBits an option bitmask * @return Returns true, if this object contains all given options. */ public boolean containsAllOptions(int optionBits) { return (getOptions() & optionBits) == optionBits; } /** * @param optionBits an option bitmask * @return Returns true, if this object contain at least one of the given options. */ public boolean containsOneOf(int optionBits) { return ((getOptions()) & optionBits) != 0; } /** * @param optionBit the binary bit or bits that are requested * @return Returns if all of the requested bits are set or not. */ protected boolean getOption(int optionBit) { return (options & optionBit) != 0; } /** * @param optionBits the binary bit or bits that shall be set to the given value * @param value the boolean value to set */ public void setOption(int optionBits, boolean value) { options = value ? options | optionBits : options & ~optionBits; } /** * Is friendly to access it during the tests. * @return Returns the options. */ public int getOptions() { return options; } /** * @param options The options to set. * @throws XMPException */ public void setOptions(int options) throws XMPException { assertOptionsValid(options); this.options = options; } /** * @see Object#equals(Object) */ public boolean equals(Object obj) { return getOptions() == ((Options) obj).getOptions(); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return getOptions(); } /** * Creates a human readable string from the set options. Note: This method is quite * expensive and should only be used within tests or as * @return Returns a String listing all options that are set to true by their name, * like "option1 | option4". */ public String getOptionsString() { if (options != 0) { StringBuffer sb = new StringBuffer(); int theBits = options; while (theBits != 0) { int oneLessBit = theBits & (theBits - 1); // clear rightmost one bit int singleBit = theBits ^ oneLessBit; String bitName = getOptionName(singleBit); sb.append(bitName); if (oneLessBit != 0) { sb.append(" | "); } theBits = oneLessBit; } return sb.toString(); } else { return ""; } } /** * @return Returns the options as hex bitmask. */ public String toString() { return "0x" + Integer.toHexString(options); } /** * To be implemeted by inheritants. * @return Returns a bit mask where all valid option bits are set. */ protected abstract int getValidOptions(); /** * To be implemeted by inheritants. * @param option a single, valid option bit. * @return Returns a human readable name for an option bit. */ protected abstract String defineOptionName(int option); /** * The inheriting option class can do additional checks on the options. * Note: For performance reasons this method is only called * when setting bitmasks directly. * When get- and set-methods are used, this method must be called manually, * normally only when the Options-object has been created from a client * (it has to be made public therefore). * * @param options the bitmask to check. * @throws XMPException Thrown if the options are not consistent. */ protected void assertConsistency(int options) throws XMPException { // empty, no checks } /** * Checks options before they are set. * First it is checked if only defined options are used, * second the additional {@link Options#assertConsistency(int)}-method is called. * * @param options the options to check * @throws XMPException Thrown if the options are invalid. */ private void assertOptionsValid(int options) throws XMPException { int invalidOptions = options & ~getValidOptions(); if (invalidOptions == 0) { assertConsistency(options); } else { throw new XMPException("The option bit(s) 0x" + Integer.toHexString(invalidOptions) + " are invalid!", XMPError.BADOPTIONS); } } /** * Looks up or asks the inherited class for the name of an option bit. * Its save that there is only one valid option handed into the method. * @param option a single option bit * @return Returns the option name or undefined. */ private String getOptionName(int option) { Map optionsNames = procureOptionNames(); Integer key = new Integer(option); String result = (String) optionsNames.get(key); if (result == null) { result = defineOptionName(option); if (result != null) { optionsNames.put(key, result); } else { result = "