You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2013/03/06 16:57:52 UTC
svn commit: r1453395 [6/11] - in /pdfbox/trunk/xmpbox: ./
src/main/java/org/apache/xmpbox/ src/main/java/org/apache/xmpbox/schema/
src/main/java/org/apache/xmpbox/type/ src/main/java/org/apache/xmpbox/xml/
src/test/java/org/apache/xmpbox/ src/test/java...
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFATypeType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFATypeType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFATypeType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFATypeType.java Wed Mar 6 15:57:44 2013
@@ -23,53 +23,57 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="pdfaType",namespace="http://www.aiim.org/pdfa/ns/type#")
-public class PDFATypeType extends AbstractStructuredType {
+@StructuredType(preferedPrefix = "pdfaType", namespace = "http://www.aiim.org/pdfa/ns/type#")
+public class PDFATypeType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String TYPE = "type";
+
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String NS_URI = "namespaceURI";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String PREFIX = "prefix";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String DESCRIPTION = "description";
+
+ @PropertyType(type = Types.PDFAField, card = Cardinality.Seq)
+ public static final String FIELD = "field";
+
+ public PDFATypeType(XMPMetadata metadata)
+ {
+ super(metadata);
+ }
+
+ public String getNamespaceURI()
+ {
+ URIType tt = (URIType) getProperty(NS_URI);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getType()
+ {
+ TextType tt = (TextType) getProperty(TYPE);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getPrefixValue()
+ {
+ TextType tt = (TextType) getProperty(PREFIX);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getDescription()
+ {
+ TextType tt = (TextType) getProperty(DESCRIPTION);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public ArrayProperty getFields()
+ {
+ return (ArrayProperty) getArrayProperty(FIELD);
+ }
- @PropertyType(type = Types.Text , card = Cardinality.Simple)
- public static final String TYPE = "type";
-
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String NS_URI = "namespaceURI";
-
- @PropertyType(type = Types.Text , card = Cardinality.Simple)
- public static final String PREFIX = "prefix";
-
- @PropertyType(type = Types.Text , card = Cardinality.Simple)
- public static final String DESCRIPTION = "description";
-
- @PropertyType(type =Types.PDFAField, card = Cardinality.Seq)
- public static final String FIELD = "field";
-
- public PDFATypeType(XMPMetadata metadata) {
- super(metadata);
- }
-
- public String getNamespaceURI() {
- URIType tt = (URIType) getProperty(NS_URI);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getType() {
- TextType tt = (TextType) getProperty(TYPE);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getPrefixValue() {
- TextType tt = (TextType) getProperty(PREFIX);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getDescription() {
- TextType tt = (TextType) getProperty(DESCRIPTION);
- return tt == null ? null : tt.getStringValue();
- }
-
- public ArrayProperty getFields() {
- return (ArrayProperty) getArrayProperty(FIELD);
- }
-
-
-
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PartType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PartType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PartType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PartType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class PartType extends TextType {
+public class PartType extends TextType
+{
- public PartType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public PartType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ProperNameType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ProperNameType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ProperNameType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ProperNameType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class ProperNameType extends TextType {
+public class ProperNameType extends TextType
+{
- public ProperNameType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public ProperNameType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertiesDescription.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertiesDescription.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertiesDescription.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertiesDescription.java Wed Mar 6 15:57:44 2013
@@ -27,63 +27,64 @@ import java.util.List;
import java.util.Map;
/**
- * Represents all properties known for a specific namespace Type and attributes
- * associated to each properties are saved If a specific type well declared is
- * used, this class map it to a basic type
+ * Represents all properties known for a specific namespace Type and attributes associated to each properties are saved
+ * If a specific type well declared is used, this class map it to a basic type
*
* @author a183132
*
- * Attribute management pre-implemented in order to give clues to make
- * an attribute management system
+ * Attribute management pre-implemented in order to give clues to make an attribute management system
*/
-public class PropertiesDescription {
+public class PropertiesDescription
+{
- private Map<String, PropertyType> types;
+ private Map<String, PropertyType> types;
-
- /**
- * Build PropMapping for specified namespace
- *
- * @param namespace
- * namespace URI concerned by this PropMapping
- */
- public PropertiesDescription() {
- types = new HashMap<String, PropertyType>();
- }
-
- /**
- * Get All Properties Name
- *
- * @return a list of properties qualifiedName
- */
- public List<String> getPropertiesName() {
- return new ArrayList<String>(types.keySet());
- }
-
- /**
- * Add a new property, an attributes list can be given or can be null
- *
- * @param name
- * new property name
- * @param type
- * Valuetype of the new property
- * @param attr
- * A list of attribute (put null while attribute management is
- * not implemented)
- */
- public void addNewProperty(String name, PropertyType type) {
- types.put(name, type);
- }
-
- /**
- * Return a type of a property from its qualifiedName
- *
- * @param name
- * The name of the property concerned
- * @return Type of property or null
- */
- public PropertyType getPropertyType(String name) {
- return types.get(name);
- }
+ /**
+ * Build PropMapping for specified namespace
+ *
+ * @param namespace
+ * namespace URI concerned by this PropMapping
+ */
+ public PropertiesDescription()
+ {
+ types = new HashMap<String, PropertyType>();
+ }
+
+ /**
+ * Get All Properties Name
+ *
+ * @return a list of properties qualifiedName
+ */
+ public List<String> getPropertiesName()
+ {
+ return new ArrayList<String>(types.keySet());
+ }
+
+ /**
+ * Add a new property, an attributes list can be given or can be null
+ *
+ * @param name
+ * new property name
+ * @param type
+ * Valuetype of the new property
+ * @param attr
+ * A list of attribute (put null while attribute management is not implemented)
+ */
+ public void addNewProperty(String name, PropertyType type)
+ {
+ types.put(name, type);
+ }
+
+ /**
+ * Return a type of a property from its qualifiedName
+ *
+ * @param name
+ * The name of the property concerned
+ * @return Type of property or null
+ */
+ public PropertyType getPropertyType(String name)
+ {
+ return types.get(name);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PropertyType.java Wed Mar 6 15:57:44 2013
@@ -34,19 +34,19 @@ import java.lang.annotation.Target;
/**
* Annotation to specify type expected for a property
*/
-public @interface PropertyType {
-
- /**
- * get valuetype defined in this description that must be used to build
- * properties descriptions in schema descriptions
- *
- *
- */
-// String propertyType();
-
- Types type();
-
- Cardinality card ();
-
-
+public @interface PropertyType
+{
+
+ /**
+ * get valuetype defined in this description that must be used to build properties descriptions in schema
+ * descriptions
+ *
+ *
+ */
+ // String propertyType();
+
+ Types type();
+
+ Cardinality card();
+
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RealType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RealType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RealType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RealType.java Wed Mar 6 15:57:44 2013
@@ -29,61 +29,69 @@ import org.apache.xmpbox.XMPMetadata;
* @author a183132
*
*/
-public class RealType extends AbstractSimpleProperty {
+public class RealType extends AbstractSimpleProperty
+{
- private float realValue;
-
- /**
- * Property Real type constructor (namespaceURI is given)
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespaceURI
- * the namespace URI to associate to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this property
- * @param value
- * The value to set
- */
- public RealType(XMPMetadata metadata, String namespaceURI, String prefix,
- String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
-
- }
-
- /**
- * return the property value
- *
- * @return float the property value
- */
- public Float getValue() {
- return realValue;
- }
-
- /**
- * Set the property value
- *
- * @param value
- * The value to set
- */
- public void setValue(Object value) {
- if (value instanceof Float) {
- realValue = ((Float)value).floatValue();
- } else if (value instanceof String) {
- // NumberFormatException is thrown (sub of InvalidArgumentException)
- realValue = Float.valueOf((String)value);
- } else {
- // invalid type of value
- throw new IllegalArgumentException("Value given is not allowed for the Real type.");
- }
- }
-
- @Override
- public String getStringValue() {
- return Float.toString(realValue);
- }
+ private float realValue;
+ /**
+ * Property Real type constructor (namespaceURI is given)
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespaceURI
+ * the namespace URI to associate to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this property
+ * @param value
+ * The value to set
+ */
+ public RealType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+
+ }
+
+ /**
+ * return the property value
+ *
+ * @return float the property value
+ */
+ public Float getValue()
+ {
+ return realValue;
+ }
+
+ /**
+ * Set the property value
+ *
+ * @param value
+ * The value to set
+ */
+ public void setValue(Object value)
+ {
+ if (value instanceof Float)
+ {
+ realValue = ((Float) value).floatValue();
+ }
+ else if (value instanceof String)
+ {
+ // NumberFormatException is thrown (sub of InvalidArgumentException)
+ realValue = Float.valueOf((String) value);
+ }
+ else
+ {
+ // invalid type of value
+ throw new IllegalArgumentException("Value given is not allowed for the Real type.");
+ }
+ }
+
+ @Override
+ public String getStringValue()
+ {
+ return Float.toString(realValue);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RenditionClassType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RenditionClassType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RenditionClassType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/RenditionClassType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,13 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class RenditionClassType extends TextType {
+public class RenditionClassType extends TextType
+{
- public RenditionClassType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public RenditionClassType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName,
+ Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceEventType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceEventType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceEventType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceEventType.java Wed Mar 6 15:57:44 2013
@@ -25,92 +25,103 @@ import java.util.Calendar;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="stEvt",namespace="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#")
-public class ResourceEventType extends AbstractStructuredType {
+@StructuredType(preferedPrefix = "stEvt", namespace = "http://ns.adobe.com/xap/1.0/sType/ResourceEvent#")
+public class ResourceEventType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Choice, card = Cardinality.Simple)
+ public static final String ACTION = "action";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String CHANGED = "changed";
+
+ @PropertyType(type = Types.GUID, card = Cardinality.Simple)
+ public static final String INSTANCE_ID = "instanceID";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String PARAMETERS = "parameters";
+
+ @PropertyType(type = Types.AgentName, card = Cardinality.Simple)
+ public static final String SOFTWARE_AGENT = "softwareAgent";
+
+ @PropertyType(type = Types.Date, card = Cardinality.Simple)
+ public static final String WHEN = "when";
+
+ /**
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespace
+ * the namespace URI to associate to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this thumbnail type
+ */
+ public ResourceEventType(XMPMetadata metadata)
+ {
+ super(metadata);
+ addNamespace(getNamespace(), getPreferedPrefix());
+ }
+
+ public String getInstanceID()
+ {
+ return getPropertyValueAsString(INSTANCE_ID);
+ }
+
+ public void setInstanceID(String value)
+ {
+ addSimpleProperty(INSTANCE_ID, value);
+ }
+
+ public String getSoftwareAgent()
+ {
+ return getPropertyValueAsString(SOFTWARE_AGENT);
+ }
+
+ public void setSoftwareAgent(String value)
+ {
+ addSimpleProperty(SOFTWARE_AGENT, value);
+ }
+
+ public Calendar getWhen()
+ {
+ return getDatePropertyAsCalendar(WHEN);
+ }
+
+ public void setWhen(Calendar value)
+ {
+ addSimpleProperty(WHEN, value);
+ }
+
+ public String getAction()
+ {
+ return getPropertyValueAsString(ACTION);
+ }
+
+ public void setAction(String value)
+ {
+ addSimpleProperty(ACTION, value);
+ }
+
+ public String getChanged()
+ {
+ return getPropertyValueAsString(CHANGED);
+ }
+
+ public void setChanged(String value)
+ {
+ addSimpleProperty(CHANGED, value);
+ }
+
+ public String getParameters()
+ {
+ return getPropertyValueAsString(PARAMETERS);
+ }
+
+ public void setParameters(String value)
+ {
+ addSimpleProperty(PARAMETERS, value);
+ }
- @PropertyType(type = Types.Choice, card = Cardinality.Simple)
- public static final String ACTION = "action";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String CHANGED = "changed";
-
- @PropertyType(type = Types.GUID, card = Cardinality.Simple)
- public static final String INSTANCE_ID = "instanceID";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String PARAMETERS = "parameters";
-
- @PropertyType(type = Types.AgentName, card = Cardinality.Simple)
- public static final String SOFTWARE_AGENT = "softwareAgent";
-
- @PropertyType(type = Types.Date, card = Cardinality.Simple)
- public static final String WHEN = "when";
-
-
- /**
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespace
- * the namespace URI to associate to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this thumbnail type
- */
- public ResourceEventType(XMPMetadata metadata) {
- super(metadata);
- addNamespace(getNamespace(), getPreferedPrefix());
- }
-
-
- public String getInstanceID () {
- return getPropertyValueAsString(INSTANCE_ID);
- }
-
- public void setInstanceID (String value) {
- addSimpleProperty(INSTANCE_ID, value);
- }
-
- public String getSoftwareAgent () {
- return getPropertyValueAsString(SOFTWARE_AGENT);
- }
-
- public void setSoftwareAgent (String value) {
- addSimpleProperty(SOFTWARE_AGENT, value);
- }
-
- public Calendar getWhen () {
- return getDatePropertyAsCalendar(WHEN);
- }
-
- public void setWhen (Calendar value) {
- addSimpleProperty(WHEN, value);
- }
-
- public String getAction () {
- return getPropertyValueAsString(ACTION);
- }
-
- public void setAction (String value) {
- addSimpleProperty(ACTION, value);
- }
-
-
- public String getChanged () {
- return getPropertyValueAsString(CHANGED);
- }
-
- public void setChanged (String value) {
- addSimpleProperty(CHANGED, value);
- }
-
- public String getParameters () {
- return getPropertyValueAsString(PARAMETERS);
- }
-
- public void setParameters (String value) {
- addSimpleProperty(PARAMETERS, value);
- }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceRefType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceRefType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceRefType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ResourceRefType.java Wed Mar 6 15:57:44 2013
@@ -26,302 +26,385 @@ import java.util.List;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="stRef",namespace="http://ns.adobe.com/xap/1.0/sType/ResourceRef#")
-public class ResourceRefType extends AbstractStructuredType {
+@StructuredType(preferedPrefix = "stRef", namespace = "http://ns.adobe.com/xap/1.0/sType/ResourceRef#")
+public class ResourceRefType extends AbstractStructuredType
+{
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String DOCUMENT_ID = "documentID";
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String DOCUMENT_ID = "documentID";
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String FILE_PATH = "filePath";
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String FILE_PATH = "filePath";
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String INSTANCE_ID = "instanceID";
-
- @PropertyType(type = Types.Date, card = Cardinality.Simple)
- public static final String LAST_MODIFY_DATE = "lastModifyDate";
-
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String MANAGE_TO = "manageTo";
-
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String MANAGE_UI = "manageUI";
-
- @PropertyType(type = Types.AgentName, card = Cardinality.Simple)
- public static final String MANAGER = "manager";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String MANAGER_VARIANT = "managerVariant";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String PART_MAPPING = "partMapping";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String RENDITION_PARAMS = "renditionParams";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String VERSION_ID = "versionID";
-
- @PropertyType(type = Types.Choice, card = Cardinality.Simple)
- public static final String MASK_MARKERS = "maskMarkers";
-
- @PropertyType(type = Types.RenditionClass, card = Cardinality.Simple)
- public static final String RENDITION_CLASS = "renditionClass";
-
- @PropertyType(type = Types.Part, card = Cardinality.Simple)
- public static final String FROM_PART = "fromPart";
-
- @PropertyType(type = Types.Part, card = Cardinality.Simple)
- public static final String TO_PART = "toPart";
-
- public static final String ALTERNATE_PATHS = "alternatePaths";
-
- /**
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespace
- * the namespace URI to associate to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this thumbnail type
- */
- public ResourceRefType(XMPMetadata metadata) {
- super(metadata);
- addNamespace(getNamespace(), getPreferedPrefix());
-
- }
-
- public String getDocumentID () {
- TextType absProp = (TextType)getFirstEquivalentProperty(DOCUMENT_ID,URIType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setDocumentID (String value) {
- addSimpleProperty(DOCUMENT_ID, value);
- }
-
- public String getFilePath () {
- TextType absProp = (TextType)getFirstEquivalentProperty(FILE_PATH,URIType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setFilePath (String value) {
- addSimpleProperty(FILE_PATH, value);
- }
-
- public String getInstanceID () {
- TextType absProp = (TextType)getFirstEquivalentProperty(INSTANCE_ID,URIType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setInstanceID (String value) {
- addSimpleProperty(INSTANCE_ID, value);
- }
-
- public Calendar getLastModifyDate () {
- DateType absProp = (DateType)getFirstEquivalentProperty(LAST_MODIFY_DATE,DateType.class);
- if (absProp != null) {
- return absProp.getValue();
- } else {
- return null;
- }
- }
-
- public void setLastModifyDate (Calendar value) {
- addSimpleProperty(LAST_MODIFY_DATE, value);
- }
-
- public String getManageUI () {
- TextType absProp = (TextType)getFirstEquivalentProperty(MANAGE_UI,URIType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setManageUI (String value) {
- addSimpleProperty(MANAGE_UI, value);
- }
-
- public String getManageTo () {
- TextType absProp = (TextType)getFirstEquivalentProperty(MANAGE_TO,URIType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setManageTo (String value) {
- addSimpleProperty(MANAGE_TO, value);
- }
-
- public String getManager () {
- TextType absProp = (TextType)getFirstEquivalentProperty(MANAGER,AgentNameType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setManager (String value) {
- addSimpleProperty(MANAGER, value);
- }
-
- public String getManagerVariant () {
- TextType absProp = (TextType)getFirstEquivalentProperty(MANAGER_VARIANT,TextType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setManagerVariant (String value) {
- addSimpleProperty(MANAGER_VARIANT, value);
- }
-
- public String getPartMapping () {
- TextType absProp = (TextType)getFirstEquivalentProperty(PART_MAPPING,TextType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setPartMapping (String value) {
- addSimpleProperty(PART_MAPPING, value);
- }
-
- public String getRenditionParams () {
- TextType absProp = (TextType)getFirstEquivalentProperty(RENDITION_PARAMS,TextType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setRenditionParams (String value) {
- addSimpleProperty(RENDITION_PARAMS, value);
- }
-
- public String getVersionID () {
- TextType absProp = (TextType)getFirstEquivalentProperty(VERSION_ID,TextType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setVersionID (String value) {
- addSimpleProperty(VERSION_ID, value);
- }
-
- public String getMaskMarkers () {
- TextType absProp = (TextType)getFirstEquivalentProperty(MASK_MARKERS,ChoiceType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setMaskMarkers (String value) {
- addSimpleProperty(MASK_MARKERS, value);
- }
-
- public String getRenditionClass () {
- TextType absProp = (TextType)getFirstEquivalentProperty(RENDITION_CLASS,RenditionClassType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setRenditionClass (String value) {
- addSimpleProperty(RENDITION_CLASS, value);
- }
-
- public String getFromPart () {
- TextType absProp = (TextType)getFirstEquivalentProperty(FROM_PART,PartType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setFromPart (String value) {
- addSimpleProperty(FROM_PART, value);
- }
-
- public String getToPart () {
- TextType absProp = (TextType)getFirstEquivalentProperty(TO_PART,PartType.class);
- if (absProp != null) {
- return absProp.getStringValue();
- } else {
- return null;
- }
- }
-
- public void setToPart (String value) {
- addSimpleProperty(TO_PART, value);
- }
-
- public void addAlternatePath(String value) {
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String INSTANCE_ID = "instanceID";
+
+ @PropertyType(type = Types.Date, card = Cardinality.Simple)
+ public static final String LAST_MODIFY_DATE = "lastModifyDate";
+
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String MANAGE_TO = "manageTo";
+
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String MANAGE_UI = "manageUI";
+
+ @PropertyType(type = Types.AgentName, card = Cardinality.Simple)
+ public static final String MANAGER = "manager";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String MANAGER_VARIANT = "managerVariant";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String PART_MAPPING = "partMapping";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String RENDITION_PARAMS = "renditionParams";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String VERSION_ID = "versionID";
+
+ @PropertyType(type = Types.Choice, card = Cardinality.Simple)
+ public static final String MASK_MARKERS = "maskMarkers";
+
+ @PropertyType(type = Types.RenditionClass, card = Cardinality.Simple)
+ public static final String RENDITION_CLASS = "renditionClass";
+
+ @PropertyType(type = Types.Part, card = Cardinality.Simple)
+ public static final String FROM_PART = "fromPart";
+
+ @PropertyType(type = Types.Part, card = Cardinality.Simple)
+ public static final String TO_PART = "toPart";
+
+ public static final String ALTERNATE_PATHS = "alternatePaths";
+
+ /**
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespace
+ * the namespace URI to associate to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this thumbnail type
+ */
+ public ResourceRefType(XMPMetadata metadata)
+ {
+ super(metadata);
+ addNamespace(getNamespace(), getPreferedPrefix());
+
+ }
+
+ public String getDocumentID()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(DOCUMENT_ID, URIType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setDocumentID(String value)
+ {
+ addSimpleProperty(DOCUMENT_ID, value);
+ }
+
+ public String getFilePath()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(FILE_PATH, URIType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setFilePath(String value)
+ {
+ addSimpleProperty(FILE_PATH, value);
+ }
+
+ public String getInstanceID()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(INSTANCE_ID, URIType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setInstanceID(String value)
+ {
+ addSimpleProperty(INSTANCE_ID, value);
+ }
+
+ public Calendar getLastModifyDate()
+ {
+ DateType absProp = (DateType) getFirstEquivalentProperty(LAST_MODIFY_DATE, DateType.class);
+ if (absProp != null)
+ {
+ return absProp.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setLastModifyDate(Calendar value)
+ {
+ addSimpleProperty(LAST_MODIFY_DATE, value);
+ }
+
+ public String getManageUI()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(MANAGE_UI, URIType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setManageUI(String value)
+ {
+ addSimpleProperty(MANAGE_UI, value);
+ }
+
+ public String getManageTo()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(MANAGE_TO, URIType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setManageTo(String value)
+ {
+ addSimpleProperty(MANAGE_TO, value);
+ }
+
+ public String getManager()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(MANAGER, AgentNameType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setManager(String value)
+ {
+ addSimpleProperty(MANAGER, value);
+ }
+
+ public String getManagerVariant()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(MANAGER_VARIANT, TextType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setManagerVariant(String value)
+ {
+ addSimpleProperty(MANAGER_VARIANT, value);
+ }
+
+ public String getPartMapping()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(PART_MAPPING, TextType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setPartMapping(String value)
+ {
+ addSimpleProperty(PART_MAPPING, value);
+ }
+
+ public String getRenditionParams()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(RENDITION_PARAMS, TextType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setRenditionParams(String value)
+ {
+ addSimpleProperty(RENDITION_PARAMS, value);
+ }
+
+ public String getVersionID()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(VERSION_ID, TextType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setVersionID(String value)
+ {
+ addSimpleProperty(VERSION_ID, value);
+ }
+
+ public String getMaskMarkers()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(MASK_MARKERS, ChoiceType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setMaskMarkers(String value)
+ {
+ addSimpleProperty(MASK_MARKERS, value);
+ }
+
+ public String getRenditionClass()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(RENDITION_CLASS, RenditionClassType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setRenditionClass(String value)
+ {
+ addSimpleProperty(RENDITION_CLASS, value);
+ }
+
+ public String getFromPart()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(FROM_PART, PartType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setFromPart(String value)
+ {
+ addSimpleProperty(FROM_PART, value);
+ }
+
+ public String getToPart()
+ {
+ TextType absProp = (TextType) getFirstEquivalentProperty(TO_PART, PartType.class);
+ if (absProp != null)
+ {
+ return absProp.getStringValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setToPart(String value)
+ {
+ addSimpleProperty(TO_PART, value);
+ }
+
+ public void addAlternatePath(String value)
+ {
ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class);
- if (seq==null) {
- seq = getMetadata().getTypeMapping().createArrayProperty(null,
- getPreferedPrefix(), ALTERNATE_PATHS,
+ if (seq == null)
+ {
+ seq = getMetadata().getTypeMapping().createArrayProperty(null, getPreferedPrefix(), ALTERNATE_PATHS,
Cardinality.Seq);
- addProperty(seq);
+ addProperty(seq);
}
- TypeMapping tm = getMetadata().getTypeMapping();
- TextType tt = (TextType)tm.instanciateSimpleProperty(null, "rdf", "li", value, Types.Text);
+ TypeMapping tm = getMetadata().getTypeMapping();
+ TextType tt = (TextType) tm.instanciateSimpleProperty(null, "rdf", "li", value, Types.Text);
seq.addProperty(tt);
- }
+ }
- /**
- * Get Versions property
- *
- * @return version property to set
- */
- public ArrayProperty getAlternatePathsProperty() {
+ /**
+ * Get Versions property
+ *
+ * @return version property to set
+ */
+ public ArrayProperty getAlternatePathsProperty()
+ {
return (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class);
- }
+ }
- /**
- * Get List of Versions values
- *
- * @return List of Versions values
- */
- public List<String> getAlternatePaths() {
+ /**
+ * Get List of Versions values
+ *
+ * @return List of Versions values
+ */
+ public List<String> getAlternatePaths()
+ {
ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class);
- if (seq!=null) {
- return seq.getElementsAsString();
- } else {
- return null;
+ if (seq != null)
+ {
+ return seq.getElementsAsString();
+ }
+ else
+ {
+ return null;
}
- }
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/StructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/StructuredType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/StructuredType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/StructuredType.java Wed Mar 6 15:57:44 2013
@@ -28,10 +28,11 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
-public @interface StructuredType {
+public @interface StructuredType
+{
+
+ String namespace();
+
+ String preferedPrefix();
- String namespace ();
-
- String preferedPrefix();
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TextType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TextType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TextType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TextType.java Wed Mar 6 15:57:44 2013
@@ -29,56 +29,60 @@ import org.apache.xmpbox.XMPMetadata;
* @author a183132
*
*/
-public class TextType extends AbstractSimpleProperty {
+public class TextType extends AbstractSimpleProperty
+{
- private String textValue;
+ private String textValue;
- /**
- * Property Text type constructor (namespaceURI is given)
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespaceURI
- * the namespace URI to associate to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this property
- * @param value
- * The value to set
- */
- public TextType(XMPMetadata metadata, String namespaceURI, String prefix,
- String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
-
- }
-
- /**
- * Set the property value
- *
- * @param value
- * The value to set
- */
- public void setValue(Object value) {
- if (!(value instanceof String)) {
- throw new IllegalArgumentException(
- "Value given is not allowed for the Text type : '" + value
- + "'");
- } else {
- textValue = (String)value;
- }
-
- }
-
- @Override
- public String getStringValue() {
- return textValue;
- }
-
- @Override
- public Object getValue() {
- return textValue;
- }
+ /**
+ * Property Text type constructor (namespaceURI is given)
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespaceURI
+ * the namespace URI to associate to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this property
+ * @param value
+ * The value to set
+ */
+ public TextType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+
+ }
+
+ /**
+ * Set the property value
+ *
+ * @param value
+ * The value to set
+ */
+ public void setValue(Object value)
+ {
+ if (!(value instanceof String))
+ {
+ throw new IllegalArgumentException("Value given is not allowed for the Text type : '" + value + "'");
+ }
+ else
+ {
+ textValue = (String) value;
+ }
+
+ }
+
+ @Override
+ public String getStringValue()
+ {
+ return textValue;
+ }
+
+ @Override
+ public Object getValue()
+ {
+ return textValue;
+ }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ThumbnailType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ThumbnailType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ThumbnailType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ThumbnailType.java Wed Mar 6 15:57:44 2013
@@ -24,153 +24,163 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.XmpConstants;
-
/**
* Object representation of an Thumbnail XMP type
*
* @author eric
*/
-@StructuredType(preferedPrefix="xmpGImg",namespace="http://ns.adobe.com/xap/1.0/g/img/")
-public class ThumbnailType extends AbstractStructuredType {
-
- @PropertyType(type = Types.Choice, card = Cardinality.Simple)
- public static final String FORMAT = "format";
-
- @PropertyType(type = Types.Integer, card = Cardinality.Simple)
- public static final String HEIGHT = "height";
-
- @PropertyType(type = Types.Integer, card = Cardinality.Simple)
- public static final String WIDTH = "width";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String IMAGE = "image";
-
- /**
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespace
- * the namespace URI to associate to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this thumbnail type
- */
- public ThumbnailType(XMPMetadata metadata) {
- super(metadata);
- setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "parseType", "Resource"));
- }
-
- /**
- * Get Height
- *
- * @return the height
- */
- public Integer getHeight() {
- AbstractField absProp = getFirstEquivalentProperty(HEIGHT,
- IntegerType.class);
- if (absProp != null) {
- return ((IntegerType) absProp).getValue();
- }
- return null;
- }
-
- /**
- * Set Height
- *
- * @param prefix
- * the prefix of Height property to set
- * @param name
- * the name of Height property to set
- * @param height
- * the value of Height property to set
- */
- public void setHeight(Integer height) {
- addSimpleProperty(HEIGHT, height);
- }
-
- /**
- * Get Width
- *
- * @return the width
- */
- public Integer getWidth() {
- AbstractField absProp = getFirstEquivalentProperty(WIDTH,
- IntegerType.class);
- if (absProp != null) {
-
- return ((IntegerType) absProp).getValue();
- }
- return null;
- }
-
- /**
- * Set Width
- *
- * @param prefix
- * the prefix of width property to set
- * @param name
- * the name of width property to set
- * @param width
- * the value of width property to set
- */
- public void setWidth(Integer width) {
- addSimpleProperty(WIDTH, width);
- }
-
- /**
- * Get The img data
- *
- * @return the img
- */
- public String getImage() {
- AbstractField absProp = getFirstEquivalentProperty(IMAGE,
- TextType.class);
- if (absProp != null) {
- return ((TextType) absProp).getStringValue();
- }
- return null;
- }
-
- /**
- * Set Image data
- *
- * @param prefix
- * the prefix of image property to set
- * @param name
- * the name of image property to set
- * @param image
- * the value of image property to set
- */
- public void setImage(String image) {
- addSimpleProperty(IMAGE, image);
- }
-
- /**
- * Get Format
- *
- * @return the format
- */
- public String getFormat() {
- AbstractField absProp = getFirstEquivalentProperty(FORMAT,ChoiceType.class);
- if (absProp != null) {
- return ((TextType) absProp).getStringValue();
- }
- return null;
- }
-
- /**
- * Set Format
- *
- * @param prefix
- * the prefix of format property to set
- * @param name
- * the name of format property to set
- * @param format
- * the value of format property to set
- */
- public void setFormat(String format) {
- addSimpleProperty(FORMAT, format);
- }
-
+@StructuredType(preferedPrefix = "xmpGImg", namespace = "http://ns.adobe.com/xap/1.0/g/img/")
+public class ThumbnailType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Choice, card = Cardinality.Simple)
+ public static final String FORMAT = "format";
+
+ @PropertyType(type = Types.Integer, card = Cardinality.Simple)
+ public static final String HEIGHT = "height";
+
+ @PropertyType(type = Types.Integer, card = Cardinality.Simple)
+ public static final String WIDTH = "width";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String IMAGE = "image";
+
+ /**
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespace
+ * the namespace URI to associate to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this thumbnail type
+ */
+ public ThumbnailType(XMPMetadata metadata)
+ {
+ super(metadata);
+ setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "parseType", "Resource"));
+ }
+
+ /**
+ * Get Height
+ *
+ * @return the height
+ */
+ public Integer getHeight()
+ {
+ AbstractField absProp = getFirstEquivalentProperty(HEIGHT, IntegerType.class);
+ if (absProp != null)
+ {
+ return ((IntegerType) absProp).getValue();
+ }
+ return null;
+ }
+
+ /**
+ * Set Height
+ *
+ * @param prefix
+ * the prefix of Height property to set
+ * @param name
+ * the name of Height property to set
+ * @param height
+ * the value of Height property to set
+ */
+ public void setHeight(Integer height)
+ {
+ addSimpleProperty(HEIGHT, height);
+ }
+
+ /**
+ * Get Width
+ *
+ * @return the width
+ */
+ public Integer getWidth()
+ {
+ AbstractField absProp = getFirstEquivalentProperty(WIDTH, IntegerType.class);
+ if (absProp != null)
+ {
+
+ return ((IntegerType) absProp).getValue();
+ }
+ return null;
+ }
+
+ /**
+ * Set Width
+ *
+ * @param prefix
+ * the prefix of width property to set
+ * @param name
+ * the name of width property to set
+ * @param width
+ * the value of width property to set
+ */
+ public void setWidth(Integer width)
+ {
+ addSimpleProperty(WIDTH, width);
+ }
+
+ /**
+ * Get The img data
+ *
+ * @return the img
+ */
+ public String getImage()
+ {
+ AbstractField absProp = getFirstEquivalentProperty(IMAGE, TextType.class);
+ if (absProp != null)
+ {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+ /**
+ * Set Image data
+ *
+ * @param prefix
+ * the prefix of image property to set
+ * @param name
+ * the name of image property to set
+ * @param image
+ * the value of image property to set
+ */
+ public void setImage(String image)
+ {
+ addSimpleProperty(IMAGE, image);
+ }
+
+ /**
+ * Get Format
+ *
+ * @return the format
+ */
+ public String getFormat()
+ {
+ AbstractField absProp = getFirstEquivalentProperty(FORMAT, ChoiceType.class);
+ if (absProp != null)
+ {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+ /**
+ * Set Format
+ *
+ * @param prefix
+ * the prefix of format property to set
+ * @param name
+ * the name of format property to set
+ * @param format
+ * the value of format property to set
+ */
+ public void setFormat(String format)
+ {
+ addSimpleProperty(FORMAT, format);
+ }
+
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/TypeMapping.java Wed Mar 6 15:57:44 2013
@@ -45,383 +45,446 @@ import org.apache.xmpbox.schema.XMPSchem
import org.apache.xmpbox.schema.XMPSchemaFactory;
import org.apache.xmpbox.schema.XmpSchemaException;
-public final class TypeMapping {
+public final class TypeMapping
+{
- private Map<Types, PropertiesDescription> structuredMappings;
+ private Map<Types, PropertiesDescription> structuredMappings;
- // ns -> type
- private Map<String, Types> structuredNamespaces;
+ // ns -> type
+ private Map<String, Types> structuredNamespaces;
- // ns -> type
- private Map<String, String> definedStructuredNamespaces;
-
- private Map<String, PropertiesDescription> definedStructuredMappings;
-
- private XMPMetadata metadata;
-
- private Map<String, XMPSchemaFactory> schemaMap;
-
-
- public TypeMapping(XMPMetadata metadata) {
- this.metadata = metadata;
- initialize();
- }
-
-
- private static Class<?> [] simplePropertyConstParams = new Class<?> [] {
- XMPMetadata.class,
- String.class,
- String.class,
- String.class,
- Object.class
- };
-
- private void initialize () {
- // structured types
- structuredMappings = new HashMap<Types, PropertiesDescription>();
- structuredNamespaces = new HashMap<String, Types>();
- for (Types type : Types.values()) {
- if (type.isStructured()) {
- Class<? extends AbstractStructuredType> clz = type.getImplementingClass().asSubclass(AbstractStructuredType.class);
- StructuredType st = clz.getAnnotation(StructuredType.class);
- String ns = st.namespace();
- PropertiesDescription pm = initializePropMapping(clz);
- structuredNamespaces.put(ns, type);
- structuredMappings.put(type, pm);
- }
- }
-
- // define structured types
- definedStructuredNamespaces = new HashMap<String, String>();
- definedStructuredMappings = new HashMap<String, PropertiesDescription>();
-
- // schema
- schemaMap = new HashMap<String, XMPSchemaFactory>();
- addNameSpace(XMPBasicSchema.class);
- addNameSpace(DublinCoreSchema.class);
- addNameSpace(PDFAExtensionSchema.class);
- addNameSpace(XMPMediaManagementSchema.class);
- addNameSpace(AdobePDFSchema.class);
- addNameSpace(PDFAIdentificationSchema.class);
- addNameSpace(XMPRightsManagementSchema.class);
- addNameSpace(PhotoshopSchema.class);
- addNameSpace(XMPBasicJobTicketSchema.class);
-
- }
-
- public void addToDefinedStructuredTypes (String typeName, String ns, PropertiesDescription pm) {
- definedStructuredNamespaces.put(ns, typeName);
- definedStructuredMappings.put(typeName, pm);
- }
-
- public PropertiesDescription getDefinedDescriptionByNamespace (String namespace) {
- String dt = definedStructuredNamespaces.get(namespace);
- return this.definedStructuredMappings.get(dt);
- }
-
- public AbstractStructuredType instanciateStructuredType (Types type, String propertyName) throws BadFieldValueException {
- try {
- Class<? extends AbstractStructuredType> propertyTypeClass = type.getImplementingClass().asSubclass(AbstractStructuredType.class);
- Constructor<? extends AbstractStructuredType> construct = propertyTypeClass.getConstructor(new Class<?> [] {
- XMPMetadata.class});
- AbstractStructuredType tmp = construct.newInstance(metadata);
- tmp.setPropertyName(propertyName);
- return tmp;
- } catch (InvocationTargetException e) {
- throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
- } catch (IllegalArgumentException e) {
- throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
- } catch (InstantiationException e) {
- throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
- } catch (IllegalAccessException e) {
- throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
- } catch (SecurityException e) {
- throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
- } catch (NoSuchMethodException e) {
- throw new BadFieldValueException("Failed to instanciate structured type : "+type,e);
- }
- }
-
- public AbstractStructuredType instanciateDefinedType (String propertyName, String namespace) {
- return new DefinedStructuredType(metadata, namespace, null, propertyName);
- }
-
-
-
- public AbstractSimpleProperty instanciateSimpleProperty (String nsuri, String prefix, String name, Object value, Types type) {
- // constructor parameters
- Object [] params = new Object [] {
- metadata,
- nsuri,
- prefix,
- name,
- value
- };
- // type
- try {
- Class<? extends AbstractSimpleProperty> clz = type.getImplementingClass().asSubclass(AbstractSimpleProperty.class);
- Constructor<? extends AbstractSimpleProperty> cons = clz.getConstructor(simplePropertyConstParams);
- return cons.newInstance(params);
- } catch (NoSuchMethodError e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- } catch (SecurityException e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- } catch (NoSuchMethodException e) {
- throw new IllegalArgumentException("Failed to instanciate property", e);
- }
- }
-
-
- public AbstractSimpleProperty instanciateSimpleField (Class<?> clz, String nsuri, String prefix,String propertyName, Object value) {
- PropertiesDescription pm = initializePropMapping(clz);
- PropertyType simpleType = pm.getPropertyType(propertyName);
- Types type = simpleType.type();
- return instanciateSimpleProperty(nsuri, prefix, propertyName, value, type);
- }
-
- /**
- * Check if a namespace used reference a complex basic types (like
- * Thumbnails)
- *
- * @param namespace
- * The namespace URI to check
- * @return True if namespace URI is a reference for a complex basic type
- */
- public boolean isStructuredTypeNamespace(String namespace) {
- return structuredNamespaces.containsKey(namespace);
- }
-
- public boolean isDefinedTypeNamespace(String namespace) {
- return definedStructuredNamespaces.containsKey(namespace);
- }
-
- // public String getTypeInArray (String type) {
- // int pos = type.indexOf(' ');
- // if (pos<0) {
- // // not array
- // return null;
- // } else {
- // return type.substring(pos+1);
- // }
- // }
-
- public boolean isDefinedType (String name) {
- return this.definedStructuredMappings.containsKey(name);
- }
-
- private void addNameSpace(Class<? extends XMPSchema> classSchem) {
- StructuredType st = classSchem.getAnnotation(StructuredType.class);
- String ns = st.namespace();
- schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem)));
- }
-
- public void addNewNameSpace(String ns,String prefered) {
- PropertiesDescription mapping = new PropertiesDescription();
- schemaMap.put(ns, new XMPSchemaFactory(ns, XMPSchema.class, mapping));
- }
-
- public PropertiesDescription getStructuredPropMapping (Types type) {
- return structuredMappings.get(type);
- }
-
- /**
- * Return the specialized schema class representation if it's known (create
- * and add it to metadata). In other cases, return null
- *
- * @param metadata
- * Metadata to link the new schema
- * @param namespace
- * The namespace URI
- * @return Schema representation
- * @throws XmpSchemaException
- * When Instancing specified Object Schema failed
- */
- public XMPSchema getAssociatedSchemaObject(XMPMetadata metadata, String namespace, String prefix) throws XmpSchemaException {
- if (schemaMap.containsKey(namespace)) {
- XMPSchemaFactory factory = schemaMap.get(namespace);
- return factory.createXMPSchema(metadata, prefix);
- } else {
- XMPSchemaFactory factory = getSchemaFactory(namespace);
- return factory!=null?factory.createXMPSchema(metadata, prefix):null;
- }
- }
-
- public XMPSchemaFactory getSchemaFactory(String namespace) {
- return schemaMap.get(namespace);
- }
-
- /**
- * Say if a specific namespace is known
- *
- * @param namespace
- * The namespace URI checked
- * @return True if namespace URI is known
- */
- public boolean isDefinedSchema(String namespace) {
- return schemaMap.containsKey(namespace);
- }
-
- public boolean isDefinedNamespace (String namespace) {
- return isDefinedSchema(namespace) || isStructuredTypeNamespace(namespace)||isDefinedTypeNamespace(namespace);
- }
-
- /**
- * Give type of specified property in specified schema (given by its
- * namespaceURI)
- *
- * @param prop
- * the property Qualified Name
- * @return Property type declared for namespace specified, null if unknown
- */
- public PropertyType getSpecifiedPropertyType (QName name) throws BadFieldValueException {
- XMPSchemaFactory factory =getSchemaFactory(name.getNamespaceURI());
- if (factory!=null) {
- // found in schema
- return factory.getPropertyType(name.getLocalPart());
- } else {
- // try in structured
- Types st = structuredNamespaces.get(name.getNamespaceURI());
- if (st!=null) {
- return createPropertyType(st,Cardinality.Simple);
- } else {
- // try in defined
- String dt = definedStructuredNamespaces.get(name.getNamespaceURI());
- if (dt==null) {
- // not found
- throw new BadFieldValueException("No descriptor found for "+name);
- } else {
- return createPropertyType(Types.DefinedType,Cardinality.Simple);
- }
- }
- }
- }
-
- public PropertiesDescription initializePropMapping(Class<?> classSchem) {
- PropertiesDescription propMap = new PropertiesDescription();
- Field [] fields = classSchem.getFields();
- String propName = null;
- for (Field field : fields) {
- if (field.isAnnotationPresent(PropertyType.class)) {
- try {
- propName = (String) field.get(propName);
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "couldn't read one type declaration, please check accessibility and declaration of fields annoted in "
- + classSchem.getName(), e);
- }
- PropertyType propType = field.getAnnotation(PropertyType.class);
- propMap.addNewProperty(propName, propType);
- }
- }
- return propMap;
- }
-
- public BooleanType createBoolean (String namespaceURI, String prefix,
- String propertyName, boolean value) {
- return new BooleanType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public DateType createDate (String namespaceURI, String prefix,
- String propertyName, Calendar value) {
- return new DateType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public IntegerType createInteger (String namespaceURI, String prefix,
- String propertyName, int value) {
- return new IntegerType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public RealType createReal (String namespaceURI, String prefix,
- String propertyName, float value) {
- return new RealType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public TextType createText (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new TextType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public ProperNameType createProperName (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new ProperNameType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public URIType createURI (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new URIType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public URLType createURL (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new URLType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public RenditionClassType createRenditionClass (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new RenditionClassType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public PartType createPart (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new PartType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public MIMEType createMIMEType (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new MIMEType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public LocaleType createLocale (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new LocaleType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public GUIDType createGUID (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new GUIDType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public ChoiceType createChoice (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new ChoiceType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public AgentNameType createAgentName (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new AgentNameType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public XPathType createXPath (String namespaceURI, String prefix,
- String propertyName, String value) {
- return new XPathType(metadata, namespaceURI, prefix,propertyName, value);
- }
-
- public ArrayProperty createArrayProperty (String namespace, String prefix, String propertyName, Cardinality type) {
- return new ArrayProperty(metadata, namespace, prefix, propertyName, type);
- }
-
- public static PropertyType createPropertyType (final Types type, final Cardinality card) {
- return new PropertyType() {
-
- public Class<? extends Annotation> annotationType() {
- return null;
- }
-
- public Types type() {
- return type;
- }
-
- public Cardinality card() {
- return card;
- }
- };
- }
+ // ns -> type
+ private Map<String, String> definedStructuredNamespaces;
+
+ private Map<String, PropertiesDescription> definedStructuredMappings;
+
+ private XMPMetadata metadata;
+
+ private Map<String, XMPSchemaFactory> schemaMap;
+
+ public TypeMapping(XMPMetadata metadata)
+ {
+ this.metadata = metadata;
+ initialize();
+ }
+
+ private static Class<?>[] simplePropertyConstParams = new Class<?>[] { XMPMetadata.class, String.class,
+ String.class, String.class, Object.class };
+
+ private void initialize()
+ {
+ // structured types
+ structuredMappings = new HashMap<Types, PropertiesDescription>();
+ structuredNamespaces = new HashMap<String, Types>();
+ for (Types type : Types.values())
+ {
+ if (type.isStructured())
+ {
+ Class<? extends AbstractStructuredType> clz = type.getImplementingClass().asSubclass(
+ AbstractStructuredType.class);
+ StructuredType st = clz.getAnnotation(StructuredType.class);
+ String ns = st.namespace();
+ PropertiesDescription pm = initializePropMapping(clz);
+ structuredNamespaces.put(ns, type);
+ structuredMappings.put(type, pm);
+ }
+ }
+
+ // define structured types
+ definedStructuredNamespaces = new HashMap<String, String>();
+ definedStructuredMappings = new HashMap<String, PropertiesDescription>();
+
+ // schema
+ schemaMap = new HashMap<String, XMPSchemaFactory>();
+ addNameSpace(XMPBasicSchema.class);
+ addNameSpace(DublinCoreSchema.class);
+ addNameSpace(PDFAExtensionSchema.class);
+ addNameSpace(XMPMediaManagementSchema.class);
+ addNameSpace(AdobePDFSchema.class);
+ addNameSpace(PDFAIdentificationSchema.class);
+ addNameSpace(XMPRightsManagementSchema.class);
+ addNameSpace(PhotoshopSchema.class);
+ addNameSpace(XMPBasicJobTicketSchema.class);
+
+ }
+
+ public void addToDefinedStructuredTypes(String typeName, String ns, PropertiesDescription pm)
+ {
+ definedStructuredNamespaces.put(ns, typeName);
+ definedStructuredMappings.put(typeName, pm);
+ }
+
+ public PropertiesDescription getDefinedDescriptionByNamespace(String namespace)
+ {
+ String dt = definedStructuredNamespaces.get(namespace);
+ return this.definedStructuredMappings.get(dt);
+ }
+
+ public AbstractStructuredType instanciateStructuredType(Types type, String propertyName)
+ throws BadFieldValueException
+ {
+ try
+ {
+ Class<? extends AbstractStructuredType> propertyTypeClass = type.getImplementingClass().asSubclass(
+ AbstractStructuredType.class);
+ Constructor<? extends AbstractStructuredType> construct = propertyTypeClass
+ .getConstructor(new Class<?>[] { XMPMetadata.class });
+ AbstractStructuredType tmp = construct.newInstance(metadata);
+ tmp.setPropertyName(propertyName);
+ return tmp;
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
+ }
+ catch (SecurityException e)
+ {
+ throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
+ }
+ }
+
+ public AbstractStructuredType instanciateDefinedType(String propertyName, String namespace)
+ {
+ return new DefinedStructuredType(metadata, namespace, null, propertyName);
+ }
+
+ public AbstractSimpleProperty instanciateSimpleProperty(String nsuri, String prefix, String name, Object value,
+ Types type)
+ {
+ // constructor parameters
+ Object[] params = new Object[] { metadata, nsuri, prefix, name, value };
+ // type
+ try
+ {
+ Class<? extends AbstractSimpleProperty> clz = type.getImplementingClass().asSubclass(
+ AbstractSimpleProperty.class);
+ Constructor<? extends AbstractSimpleProperty> cons = clz.getConstructor(simplePropertyConstParams);
+ return cons.newInstance(params);
+ }
+ catch (NoSuchMethodError e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ catch (SecurityException e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new IllegalArgumentException("Failed to instanciate property", e);
+ }
+ }
+
+ public AbstractSimpleProperty instanciateSimpleField(Class<?> clz, String nsuri, String prefix,
+ String propertyName, Object value)
+ {
+ PropertiesDescription pm = initializePropMapping(clz);
+ PropertyType simpleType = pm.getPropertyType(propertyName);
+ Types type = simpleType.type();
+ return instanciateSimpleProperty(nsuri, prefix, propertyName, value, type);
+ }
+
+ /**
+ * Check if a namespace used reference a complex basic types (like Thumbnails)
+ *
+ * @param namespace
+ * The namespace URI to check
+ * @return True if namespace URI is a reference for a complex basic type
+ */
+ public boolean isStructuredTypeNamespace(String namespace)
+ {
+ return structuredNamespaces.containsKey(namespace);
+ }
+
+ public boolean isDefinedTypeNamespace(String namespace)
+ {
+ return definedStructuredNamespaces.containsKey(namespace);
+ }
+
+ // public String getTypeInArray (String type) {
+ // int pos = type.indexOf(' ');
+ // if (pos<0) {
+ // // not array
+ // return null;
+ // } else {
+ // return type.substring(pos+1);
+ // }
+ // }
+
+ public boolean isDefinedType(String name)
+ {
+ return this.definedStructuredMappings.containsKey(name);
+ }
+
+ private void addNameSpace(Class<? extends XMPSchema> classSchem)
+ {
+ StructuredType st = classSchem.getAnnotation(StructuredType.class);
+ String ns = st.namespace();
+ schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem)));
+ }
+
+ public void addNewNameSpace(String ns, String prefered)
+ {
+ PropertiesDescription mapping = new PropertiesDescription();
+ schemaMap.put(ns, new XMPSchemaFactory(ns, XMPSchema.class, mapping));
+ }
+
+ public PropertiesDescription getStructuredPropMapping(Types type)
+ {
+ return structuredMappings.get(type);
+ }
+
+ /**
+ * Return the specialized schema class representation if it's known (create and add it to metadata). In other cases,
+ * return null
+ *
+ * @param metadata
+ * Metadata to link the new schema
+ * @param namespace
+ * The namespace URI
+ * @return Schema representation
+ * @throws XmpSchemaException
+ * When Instancing specified Object Schema failed
+ */
+ public XMPSchema getAssociatedSchemaObject(XMPMetadata metadata, String namespace, String prefix)
+ throws XmpSchemaException
+ {
+ if (schemaMap.containsKey(namespace))
+ {
+ XMPSchemaFactory factory = schemaMap.get(namespace);
+ return factory.createXMPSchema(metadata, prefix);
+ }
+ else
+ {
+ XMPSchemaFactory factory = getSchemaFactory(namespace);
+ return factory != null ? factory.createXMPSchema(metadata, prefix) : null;
+ }
+ }
+
+ public XMPSchemaFactory getSchemaFactory(String namespace)
+ {
+ return schemaMap.get(namespace);
+ }
+
+ /**
+ * Say if a specific namespace is known
+ *
+ * @param namespace
+ * The namespace URI checked
+ * @return True if namespace URI is known
+ */
+ public boolean isDefinedSchema(String namespace)
+ {
+ return schemaMap.containsKey(namespace);
+ }
+
+ public boolean isDefinedNamespace(String namespace)
+ {
+ return isDefinedSchema(namespace) || isStructuredTypeNamespace(namespace) || isDefinedTypeNamespace(namespace);
+ }
+
+ /**
+ * Give type of specified property in specified schema (given by its namespaceURI)
+ *
+ * @param prop
+ * the property Qualified Name
+ * @return Property type declared for namespace specified, null if unknown
+ */
+ public PropertyType getSpecifiedPropertyType(QName name) throws BadFieldValueException
+ {
+ XMPSchemaFactory factory = getSchemaFactory(name.getNamespaceURI());
+ if (factory != null)
+ {
+ // found in schema
+ return factory.getPropertyType(name.getLocalPart());
+ }
+ else
+ {
+ // try in structured
+ Types st = structuredNamespaces.get(name.getNamespaceURI());
+ if (st != null)
+ {
+ return createPropertyType(st, Cardinality.Simple);
+ }
+ else
+ {
+ // try in defined
+ String dt = definedStructuredNamespaces.get(name.getNamespaceURI());
+ if (dt == null)
+ {
+ // not found
+ throw new BadFieldValueException("No descriptor found for " + name);
+ }
+ else
+ {
+ return createPropertyType(Types.DefinedType, Cardinality.Simple);
+ }
+ }
+ }
+ }
+
+ public PropertiesDescription initializePropMapping(Class<?> classSchem)
+ {
+ PropertiesDescription propMap = new PropertiesDescription();
+ Field[] fields = classSchem.getFields();
+ String propName = null;
+ for (Field field : fields)
+ {
+ if (field.isAnnotationPresent(PropertyType.class))
+ {
+ try
+ {
+ propName = (String) field.get(propName);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException(
+ "couldn't read one type declaration, please check accessibility and declaration of fields annoted in "
+ + classSchem.getName(), e);
+ }
+ PropertyType propType = field.getAnnotation(PropertyType.class);
+ propMap.addNewProperty(propName, propType);
+ }
+ }
+ return propMap;
+ }
+
+ public BooleanType createBoolean(String namespaceURI, String prefix, String propertyName, boolean value)
+ {
+ return new BooleanType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public DateType createDate(String namespaceURI, String prefix, String propertyName, Calendar value)
+ {
+ return new DateType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public IntegerType createInteger(String namespaceURI, String prefix, String propertyName, int value)
+ {
+ return new IntegerType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public RealType createReal(String namespaceURI, String prefix, String propertyName, float value)
+ {
+ return new RealType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public TextType createText(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new TextType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public ProperNameType createProperName(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new ProperNameType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public URIType createURI(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new URIType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public URLType createURL(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new URLType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public RenditionClassType createRenditionClass(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new RenditionClassType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public PartType createPart(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new PartType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public MIMEType createMIMEType(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new MIMEType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public LocaleType createLocale(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new LocaleType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public GUIDType createGUID(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new GUIDType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public ChoiceType createChoice(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new ChoiceType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public AgentNameType createAgentName(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new AgentNameType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public XPathType createXPath(String namespaceURI, String prefix, String propertyName, String value)
+ {
+ return new XPathType(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ public ArrayProperty createArrayProperty(String namespace, String prefix, String propertyName, Cardinality type)
+ {
+ return new ArrayProperty(metadata, namespace, prefix, propertyName, type);
+ }
+
+ public static PropertyType createPropertyType(final Types type, final Cardinality card)
+ {
+ return new PropertyType()
+ {
+
+ public Class<? extends Annotation> annotationType()
+ {
+ return null;
+ }
+
+ public Types type()
+ {
+ return type;
+ }
+
+ public Cardinality card()
+ {
+ return card;
+ }
+ };
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Types.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Types.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Types.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Types.java Wed Mar 6 15:57:44 2013
@@ -21,78 +21,70 @@
package org.apache.xmpbox.type;
-public enum Types {
+public enum Types
+{
- Structured(false,null,null),
- DefinedType(false,null,null),
+ Structured(false, null, null), DefinedType(false, null, null),
+
+ // basic
+ Text(true, null, TextType.class), Date(true, null, DateType.class), Boolean(true, null, BooleanType.class), Integer(
+ true, null, IntegerType.class), Real(true, null, RealType.class),
+
+ ProperName(true, Text, ProperNameType.class), Locale(true, Text, LocaleType.class), AgentName(true, Text,
+ AgentNameType.class), GUID(true, Text, GUIDType.class), XPath(true, Text, XPathType.class), Part(true,
+ Text, PartType.class), URL(true, Text, URLType.class), URI(true, Text, URIType.class), Choice(true, Text,
+ ChoiceType.class), MIMEType(true, Text, MIMEType.class), LangAlt(true, Text, TextType.class), RenditionClass(
+ true, Text, RenditionClassType.class),
+
+ Layer(false, Structured, LayerType.class), Thumbnail(false, Structured, ThumbnailType.class), ResourceEvent(false,
+ Structured, ResourceEventType.class), ResourceRef(false, Structured, ResourceRefType.class), Version(false,
+ Structured, VersionType.class), PDFASchema(false, Structured, PDFASchemaType.class), PDFAField(false,
+ Structured, PDFAFieldType.class), PDFAProperty(false, Structured, PDFAPropertyType.class), PDFAType(false,
+ Structured, PDFATypeType.class), Job(false, Structured, JobType.class);
+
+ // For defined types
+
+ private boolean simple;
+
+ private Types basic;
+
+ private Class<? extends AbstractField> clz;
+
+ private Types(boolean s, Types b, Class<? extends AbstractField> c)
+ {
+ this.simple = s;
+ this.basic = b;
+ this.clz = c;
+ }
+
+ public boolean isSimple()
+ {
+ return simple;
+ }
+
+ public boolean isBasic()
+ {
+ return basic == null;
+ }
+
+ public boolean isStructured()
+ {
+ return basic == Structured;
+ }
+
+ public boolean isDefined()
+ {
+ return this == DefinedType;
+ }
+
+ public Types getBasic()
+ {
+ return basic;
+ }
+
+ public Class<? extends AbstractField> getImplementingClass()
+ {
+ return clz;
+ }
- // basic
- Text(true,null,TextType.class),
- Date(true,null,DateType.class),
- Boolean(true,null,BooleanType.class),
- Integer(true,null,IntegerType.class),
- Real(true,null,RealType.class),
-
- ProperName(true,Text,ProperNameType.class),
- Locale(true,Text,LocaleType.class),
- AgentName(true,Text,AgentNameType.class),
- GUID(true,Text,GUIDType.class),
- XPath(true,Text,XPathType.class),
- Part(true,Text,PartType.class),
- URL(true,Text,URLType.class),
- URI(true,Text,URIType.class),
- Choice(true,Text,ChoiceType.class),
- MIMEType(true,Text,MIMEType.class),
- LangAlt(true,Text,TextType.class),
- RenditionClass(true,Text,RenditionClassType.class),
-
- Layer(false,Structured,LayerType.class),
- Thumbnail(false,Structured,ThumbnailType.class),
- ResourceEvent(false,Structured,ResourceEventType.class),
- ResourceRef(false,Structured,ResourceRefType.class),
- Version(false,Structured,VersionType.class),
- PDFASchema(false,Structured,PDFASchemaType.class),
- PDFAField(false,Structured,PDFAFieldType.class),
- PDFAProperty(false,Structured,PDFAPropertyType.class),
- PDFAType(false,Structured,PDFATypeType.class),
- Job(false,Structured,JobType.class);
-
- // For defined types
-
- private boolean simple;
-
- private Types basic;
-
- private Class<? extends AbstractField> clz;
-
- private Types (boolean s, Types b, Class<? extends AbstractField> c) {
- this.simple = s;
- this.basic = b;
- this.clz = c;
- }
-
- public boolean isSimple() {
- return simple;
- }
-
- public boolean isBasic () {
- return basic==null;
- }
-
- public boolean isStructured () {
- return basic==Structured;
- }
-
- public boolean isDefined() {
- return this==DefinedType;
- }
-
- public Types getBasic () {
- return basic;
- }
-
- public Class<? extends AbstractField> getImplementingClass () {
- return clz;
- }
-
}