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 [5/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/AbstractComplexProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractComplexProperty.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractComplexProperty.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractComplexProperty.java Wed Mar 6 15:57:44 2013
@@ -27,87 +27,100 @@ import java.util.Map;
import org.apache.xmpbox.XMPMetadata;
-public abstract class AbstractComplexProperty extends AbstractField {
+public abstract class AbstractComplexProperty extends AbstractField
+{
- private ComplexPropertyContainer container;
-
- private Map<String,String> namespaceToPrefix;
-
-
- public AbstractComplexProperty(XMPMetadata metadata, String propertyName) {
- super(metadata, propertyName);
- container = new ComplexPropertyContainer();
- this.namespaceToPrefix = new HashMap<String, String>();
- }
-
- public void addNamespace (String namespace, String prefix) {
- this.namespaceToPrefix.put(namespace, prefix);
- }
-
- public String getNamespacePrefix (String namespace) {
- return this.namespaceToPrefix.get(namespace);
- }
-
- public Map<String, String> getAllNamespacesWithPrefix () {
- return this.namespaceToPrefix;
- }
-
- /**
- * Add a property to the current structure
- *
- * @param obj the property to add
- */
- public final void addProperty(AbstractField obj) {
- container.addProperty(obj);
- }
-
- /**
- * Remove a property
- *
- * @param property
- * The property to remove
- */
- public final void removeProperty(AbstractField property) {
- container.removeProperty(property);
- }
-
-// /**
-// * Return the container of this Array
-// *
-// * @return The complex property container that represents content of this
-// * property
-// */
- public final ComplexPropertyContainer getContainer() {
- return container;
- }
-
- public final List<AbstractField> getAllProperties() {
- return container.getAllProperties();
- }
-
- public final AbstractField getProperty (String fieldName) {
- List<AbstractField> list = container.getPropertiesByLocalName(fieldName);
- // return null if no property
- if (list==null) {
- return null;
- }
- // return the first element of the list
- return list.get(0);
- }
-
- public final ArrayProperty getArrayProperty (String fieldName) {
- List<AbstractField> list = container.getPropertiesByLocalName(fieldName);
- // return null if no property
- if (list==null) {
- return null;
- }
- // return the first element of the list
- return (ArrayProperty)list.get(0);
- }
-
- protected final AbstractField getFirstEquivalentProperty(String localName,
- Class<? extends AbstractField> type) {
- return container.getFirstEquivalentProperty(localName, type);
- }
+ private ComplexPropertyContainer container;
+
+ private Map<String, String> namespaceToPrefix;
+
+ public AbstractComplexProperty(XMPMetadata metadata, String propertyName)
+ {
+ super(metadata, propertyName);
+ container = new ComplexPropertyContainer();
+ this.namespaceToPrefix = new HashMap<String, String>();
+ }
+
+ public void addNamespace(String namespace, String prefix)
+ {
+ this.namespaceToPrefix.put(namespace, prefix);
+ }
+
+ public String getNamespacePrefix(String namespace)
+ {
+ return this.namespaceToPrefix.get(namespace);
+ }
+
+ public Map<String, String> getAllNamespacesWithPrefix()
+ {
+ return this.namespaceToPrefix;
+ }
+
+ /**
+ * Add a property to the current structure
+ *
+ * @param obj
+ * the property to add
+ */
+ public final void addProperty(AbstractField obj)
+ {
+ container.addProperty(obj);
+ }
+
+ /**
+ * Remove a property
+ *
+ * @param property
+ * The property to remove
+ */
+ public final void removeProperty(AbstractField property)
+ {
+ container.removeProperty(property);
+ }
+
+ // /**
+ // * Return the container of this Array
+ // *
+ // * @return The complex property container that represents content of this
+ // * property
+ // */
+ public final ComplexPropertyContainer getContainer()
+ {
+ return container;
+ }
+
+ public final List<AbstractField> getAllProperties()
+ {
+ return container.getAllProperties();
+ }
+
+ public final AbstractField getProperty(String fieldName)
+ {
+ List<AbstractField> list = container.getPropertiesByLocalName(fieldName);
+ // return null if no property
+ if (list == null)
+ {
+ return null;
+ }
+ // return the first element of the list
+ return list.get(0);
+ }
+
+ public final ArrayProperty getArrayProperty(String fieldName)
+ {
+ List<AbstractField> list = container.getPropertiesByLocalName(fieldName);
+ // return null if no property
+ if (list == null)
+ {
+ return null;
+ }
+ // return the first element of the list
+ return (ArrayProperty) list.get(0);
+ }
+
+ protected final AbstractField getFirstEquivalentProperty(String localName, Class<? extends AbstractField> type)
+ {
+ return container.getFirstEquivalentProperty(localName, type);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractField.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractField.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractField.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractField.java Wed Mar 6 15:57:44 2013
@@ -26,130 +26,141 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.xml.XMLConstants;
-
import org.apache.xmpbox.XMPMetadata;
/**
- * Astract Object representation of a XMP 'field' (-> Properties and specific
- * Schemas)
+ * Astract Object representation of a XMP 'field' (-> Properties and specific Schemas)
*
* @author a183132
*
*/
-public abstract class AbstractField {
+public abstract class AbstractField
+{
+
+ private XMPMetadata metadata;
+
+ private String propertyName;
- private XMPMetadata metadata;
+ private Map<String, Attribute> attributes;
- private String propertyName;
-
- private Map<String, Attribute> attributes;
-
- /**
- * Constructor of a XMP Field
- *
- * @param metadata
- * The metadata to attach to this field
- * @param namespaceURI
- * the namespace URI
- * @param prefix
- * the prefix to set for this field
- * @param propertyName
- * the local name to set for this field
- */
- public AbstractField(XMPMetadata metadata, String propertyName) {
- this.metadata = metadata;
- this.propertyName = propertyName;
- attributes = new HashMap<String, Attribute>();
- }
-
- /**
- * Get the propertyName (or localName)
- *
- * @return the local Name
- */
- public final String getPropertyName() {
- return propertyName;
- }
-
- public final void setPropertyName (String value) {
- this.propertyName = value;
- }
-
- /**
- * Set a new attribute for this entity
- *
- * @param value
- * The Attribute property to add
- */
- public final void setAttribute(Attribute value) {
- if (attributes.containsKey(value.getName())) {
- // if same name in element, attribute will be replaced
- attributes.remove(value.getName());
- }
- if (value.getNamespace() == null) {
- attributes.put(value.getName(), value);
- } else {
- attributes.put(value.getName(), value);
- }
- }
-
- /**
- * Check if an attribute is declared for this entity
- *
- * @param qualifiedName
- * the full qualified name of the attribute concerned
- * @return true if attribute is present
- */
- public final boolean containsAttribute(String qualifiedName) {
- return attributes.containsKey(qualifiedName);
- }
-
- /**
- * Get an attribute with its name in this entity
- *
- * @param qualifiedName
- * the full qualified name of the attribute wanted
- * @return The attribute property
- */
- public final Attribute getAttribute(String qualifiedName) {
- return attributes.get(qualifiedName);
- }
-
- /**
- * Get attributes list defined for this entity
- *
- * @return Attributes list
- */
- public final List<Attribute> getAllAttributes() {
- return new ArrayList<Attribute>(attributes.values());
- }
-
- /**
- * Remove an attribute of this entity
- *
- * @param qualifiedName
- * the full qualified name of the attribute wanted
- */
- public final void removeAttribute(String qualifiedName) {
- if (containsAttribute(qualifiedName)) {
- attributes.remove(qualifiedName);
- }
-
- }
-
- public final XMPMetadata getMetadata() {
- return metadata;
- }
-
- public abstract String getNamespace();
-
- /**
- * Get the prefix of this entity
- *
- * @return the prefix specified
- */
- public abstract String getPrefix();
+ /**
+ * Constructor of a XMP Field
+ *
+ * @param metadata
+ * The metadata to attach to this field
+ * @param namespaceURI
+ * the namespace URI
+ * @param prefix
+ * the prefix to set for this field
+ * @param propertyName
+ * the local name to set for this field
+ */
+ public AbstractField(XMPMetadata metadata, String propertyName)
+ {
+ this.metadata = metadata;
+ this.propertyName = propertyName;
+ attributes = new HashMap<String, Attribute>();
+ }
+
+ /**
+ * Get the propertyName (or localName)
+ *
+ * @return the local Name
+ */
+ public final String getPropertyName()
+ {
+ return propertyName;
+ }
+
+ public final void setPropertyName(String value)
+ {
+ this.propertyName = value;
+ }
+
+ /**
+ * Set a new attribute for this entity
+ *
+ * @param value
+ * The Attribute property to add
+ */
+ public final void setAttribute(Attribute value)
+ {
+ if (attributes.containsKey(value.getName()))
+ {
+ // if same name in element, attribute will be replaced
+ attributes.remove(value.getName());
+ }
+ if (value.getNamespace() == null)
+ {
+ attributes.put(value.getName(), value);
+ }
+ else
+ {
+ attributes.put(value.getName(), value);
+ }
+ }
+
+ /**
+ * Check if an attribute is declared for this entity
+ *
+ * @param qualifiedName
+ * the full qualified name of the attribute concerned
+ * @return true if attribute is present
+ */
+ public final boolean containsAttribute(String qualifiedName)
+ {
+ return attributes.containsKey(qualifiedName);
+ }
+
+ /**
+ * Get an attribute with its name in this entity
+ *
+ * @param qualifiedName
+ * the full qualified name of the attribute wanted
+ * @return The attribute property
+ */
+ public final Attribute getAttribute(String qualifiedName)
+ {
+ return attributes.get(qualifiedName);
+ }
+
+ /**
+ * Get attributes list defined for this entity
+ *
+ * @return Attributes list
+ */
+ public final List<Attribute> getAllAttributes()
+ {
+ return new ArrayList<Attribute>(attributes.values());
+ }
+
+ /**
+ * Remove an attribute of this entity
+ *
+ * @param qualifiedName
+ * the full qualified name of the attribute wanted
+ */
+ public final void removeAttribute(String qualifiedName)
+ {
+ if (containsAttribute(qualifiedName))
+ {
+ attributes.remove(qualifiedName);
+ }
+
+ }
+
+ public final XMPMetadata getMetadata()
+ {
+ return metadata;
+ }
+
+ public abstract String getNamespace();
+
+ /**
+ * Get the prefix of this entity
+ *
+ * @return the prefix specified
+ */
+ public abstract String getPrefix();
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java Wed Mar 6 15:57:44 2013
@@ -29,78 +29,80 @@ import org.apache.xmpbox.XMPMetadata;
* @author a183132
*
*/
-public abstract class AbstractSimpleProperty extends AbstractField {
+public abstract class AbstractSimpleProperty extends AbstractField
+{
-
- private String namespace;
-
- private String prefix;
-
- /**
- * Property specific type constructor (namespaceURI is given)
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespaceURI
- * the specified namespace URI associated 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 give
- */
- public AbstractSimpleProperty(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, propertyName);
- setValue(value);
- this.namespace = namespaceURI;
- this.prefix = prefix;
-
- }
-
- /**
- * Check and set new property value (in Element and in its Object
- * Representation)
- *
- * @param value
- * Object value to set
- */
- public abstract void setValue(Object value);
-
- /**
- * Return the property value
- *
- * @return a string
- */
- public abstract String getStringValue();
-
- public abstract Object getValue();
-
-
- public String toString () {
- StringBuilder sb = new StringBuilder ();
- sb.append("[").append(this.getClass().getSimpleName()).append(":");
- sb.append(getStringValue()).append("]");
- return sb.toString();
- }
-
- /**
- * Get the namespace URI of this entity
- *
- * @return the namespace URI
- */
- public final String getNamespace() {
- return namespace;
- }
-
- /**
- * Get the prefix of this entity
- *
- * @return the prefix specified
- */
- public String getPrefix() {
- return prefix;
- }
+ private String namespace;
+
+ private String prefix;
+
+ /**
+ * Property specific type constructor (namespaceURI is given)
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespaceURI
+ * the specified namespace URI associated 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 give
+ */
+ public AbstractSimpleProperty(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName,
+ Object value)
+ {
+ super(metadata, propertyName);
+ setValue(value);
+ this.namespace = namespaceURI;
+ this.prefix = prefix;
+
+ }
+
+ /**
+ * Check and set new property value (in Element and in its Object Representation)
+ *
+ * @param value
+ * Object value to set
+ */
+ public abstract void setValue(Object value);
+
+ /**
+ * Return the property value
+ *
+ * @return a string
+ */
+ public abstract String getStringValue();
+
+ public abstract Object getValue();
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[").append(this.getClass().getSimpleName()).append(":");
+ sb.append(getStringValue()).append("]");
+ return sb.toString();
+ }
+
+ /**
+ * Get the namespace URI of this entity
+ *
+ * @return the namespace URI
+ */
+ public final String getNamespace()
+ {
+ return namespace;
+ }
+
+ /**
+ * Get the prefix of this entity
+ *
+ * @return the prefix specified
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractStructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractStructuredType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractStructuredType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractStructuredType.java Wed Mar 6 15:57:44 2013
@@ -25,114 +25,139 @@ import java.util.Calendar;
import org.apache.xmpbox.XMPMetadata;
-public abstract class AbstractStructuredType extends AbstractComplexProperty {
+public abstract class AbstractStructuredType extends AbstractComplexProperty
+{
+
+ protected static final String STRUCTURE_ARRAY_NAME = "li";
+
+ private String namespace;
+
+ private String preferedPrefix;
+
+ private String prefix;
+
+ public AbstractStructuredType(XMPMetadata metadata)
+ {
+ this(metadata, null, null, null);
+ }
+
+ public AbstractStructuredType(XMPMetadata metadata, String namespaceURI)
+ {
+ this(metadata, namespaceURI, null, null);
+ StructuredType st = this.getClass().getAnnotation(StructuredType.class);
+ if (st != null)
+ {
+ // init with annotation
+ this.namespace = st.namespace();
+ this.preferedPrefix = st.preferedPrefix();
+ }
+ else
+ {
+ throw new IllegalArgumentException(" StructuredType annotation cannot be null");
+ }
+ this.prefix = this.preferedPrefix;
+ }
+
+ public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName)
+ {
+ super(metadata, propertyName);
+ StructuredType st = this.getClass().getAnnotation(StructuredType.class);
+ if (st != null)
+ {
+ // init with annotation
+ this.namespace = st.namespace();
+ this.preferedPrefix = st.preferedPrefix();
+ }
+ else
+ {
+ // init with parameters
+ if (namespaceURI == null)
+ {
+ throw new IllegalArgumentException(
+ "Both StructuredType annotation and namespace parameter cannot be null");
+ }
+ this.namespace = namespaceURI;
+ this.preferedPrefix = fieldPrefix;
+ }
+ this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix;
+ }
+
+ /**
+ * Get the namespace URI of this entity
+ *
+ * @return the namespace URI
+ */
+ public final String getNamespace()
+ {
+ return namespace;
+ }
+
+ public final void setNamespace(String ns)
+ {
+ this.namespace = ns;
+ }
+
+ /**
+ * Get the prefix of this entity
+ *
+ * @return the prefix specified
+ */
+ public final String getPrefix()
+ {
+ return prefix;
+ }
+
+ public final void setPrefix(String pf)
+ {
+ this.prefix = pf;
+ }
+
+ public final String getPreferedPrefix()
+ {
+ return prefix;
+ }
+
+ protected void addSimpleProperty(String propertyName, Object value)
+ {
+ TypeMapping tm = getMetadata().getTypeMapping();
+ AbstractSimpleProperty asp = tm.instanciateSimpleField(getClass(), null, getPrefix(), propertyName, value);
+ addProperty(asp);
+ }
+
+ protected String getPropertyValueAsString(String fieldName)
+ {
+ AbstractSimpleProperty absProp = (AbstractSimpleProperty) getProperty(fieldName);
+ if (absProp == null)
+ {
+ return null;
+ }
+ else
+ {
+ return absProp.getStringValue();
+ }
+ }
+
+ protected Calendar getDatePropertyAsCalendar(String fieldName)
+ {
+ DateType absProp = (DateType) getFirstEquivalentProperty(fieldName, DateType.class);
+ if (absProp != null)
+ {
+ return absProp.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public TextType createTextType(String propertyName, String value)
+ {
+ return getMetadata().getTypeMapping().createText(getNamespace(), getPrefix(), propertyName, value);
+ }
+
+ public ArrayProperty createArrayProperty(String propertyName, Cardinality type)
+ {
+ return getMetadata().getTypeMapping().createArrayProperty(getNamespace(), getPrefix(), propertyName, type);
+ }
- protected static final String STRUCTURE_ARRAY_NAME = "li";
-
- private String namespace;
-
- private String preferedPrefix;
-
- private String prefix;
-
- public AbstractStructuredType(XMPMetadata metadata) {
- this(metadata,null,null,null);
- }
-
- public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) {
- this(metadata, namespaceURI,null,null);
- StructuredType st = this.getClass().getAnnotation(StructuredType.class);
- if (st!=null) {
- // init with annotation
- this.namespace = st.namespace();
- this.preferedPrefix = st.preferedPrefix();
- } else {
- throw new IllegalArgumentException(" StructuredType annotation cannot be null");
- }
- this.prefix = this.preferedPrefix;
- }
-
- public AbstractStructuredType(XMPMetadata metadata, String namespaceURI,
- String fieldPrefix, String propertyName) {
- super(metadata, propertyName);
- StructuredType st = this.getClass().getAnnotation(StructuredType.class);
- if (st!=null) {
- // init with annotation
- this.namespace = st.namespace();
- this.preferedPrefix = st.preferedPrefix();
- } else {
- // init with parameters
- if (namespaceURI==null) {
- throw new IllegalArgumentException("Both StructuredType annotation and namespace parameter cannot be null");
- }
- this.namespace = namespaceURI;
- this.preferedPrefix = fieldPrefix;
- }
- this.prefix = fieldPrefix==null?this.preferedPrefix:fieldPrefix;
- }
-
-
- /**
- * Get the namespace URI of this entity
- *
- * @return the namespace URI
- */
- public final String getNamespace() {
- return namespace;
- }
-
- public final void setNamespace (String ns) {
- this.namespace = ns;
- }
-
- /**
- * Get the prefix of this entity
- *
- * @return the prefix specified
- */
- public final String getPrefix() {
- return prefix;
- }
-
- public final void setPrefix (String pf) {
- this.prefix = pf;
- }
-
- public final String getPreferedPrefix() {
- return prefix;
- }
-
- protected void addSimpleProperty (String propertyName, Object value) {
- TypeMapping tm = getMetadata().getTypeMapping();
- AbstractSimpleProperty asp = tm.instanciateSimpleField(getClass(), null,getPrefix(),propertyName, value);
- addProperty(asp);
- }
-
- protected String getPropertyValueAsString (String fieldName) {
- AbstractSimpleProperty absProp = (AbstractSimpleProperty)getProperty(fieldName);
- if (absProp == null) {
- return null;
- } else {
- return absProp.getStringValue();
- }
- }
-
- protected Calendar getDatePropertyAsCalendar(String fieldName) {
- DateType absProp = (DateType)getFirstEquivalentProperty(fieldName,DateType.class);
- if (absProp != null) {
- return absProp.getValue();
- } else {
- return null;
- }
- }
-
-
- public TextType createTextType (String propertyName, String value) {
- return getMetadata().getTypeMapping().createText(getNamespace(), getPrefix(), propertyName, value);
- }
-
- public ArrayProperty createArrayProperty (String propertyName, Cardinality type) {
- return getMetadata().getTypeMapping().createArrayProperty(getNamespace(), getPrefix(), propertyName, type);
- }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AgentNameType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AgentNameType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AgentNameType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/AgentNameType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class AgentNameType extends TextType {
+public class AgentNameType extends TextType
+{
- public AgentNameType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public AgentNameType(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/ArrayProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java Wed Mar 6 15:57:44 2013
@@ -29,78 +29,80 @@ import java.util.List;
import org.apache.xmpbox.XMPMetadata;
/**
- * Object representation of a Complex XMP Property (Represents Ordered,
- * Unordered and Alternative Arrays builder)
+ * Object representation of a Complex XMP Property (Represents Ordered, Unordered and Alternative Arrays builder)
*
* @author a183132
*
*/
-public class ArrayProperty extends AbstractComplexProperty {
+public class ArrayProperty extends AbstractComplexProperty
+{
- private Cardinality arrayType;
+ private Cardinality arrayType;
- private String namespace;
-
- private String prefix;
-
- /**
- * Contructor of a complex property
- *
- * @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 property
- * @param type
- * type of complexProperty (Bag, Seq, Alt)
- */
- public ArrayProperty(XMPMetadata metadata, String namespace,
- String prefix, String propertyName, Cardinality type) {
- super(metadata, propertyName);
- this.arrayType = type;
- this.namespace = namespace;
- this.prefix = prefix;
- }
-
- public Cardinality getArrayType() {
- return arrayType;
- }
-
-
- public List<String> getElementsAsString() {
- List<String> retval = null;
- retval = new ArrayList<String>();
- Iterator<AbstractField> it = getContainer()
- .getAllProperties().iterator();
- AbstractSimpleProperty tmp;
- while (it.hasNext()) {
- tmp = (AbstractSimpleProperty) it.next();
- retval.add(tmp.getStringValue());
- }
- retval = Collections.unmodifiableList(retval);
- return retval;
- }
-
- /**
- * Get the namespace URI of this entity
- *
- * @return the namespace URI
- */
- public final String getNamespace() {
- return namespace;
- }
-
- /**
- * Get the prefix of this entity
- *
- * @return the prefix specified
- */
- public String getPrefix() {
- return prefix;
- }
+ private String namespace;
+
+ private String prefix;
+
+ /**
+ * Contructor of a complex property
+ *
+ * @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 property
+ * @param type
+ * type of complexProperty (Bag, Seq, Alt)
+ */
+ public ArrayProperty(XMPMetadata metadata, String namespace, String prefix, String propertyName, Cardinality type)
+ {
+ super(metadata, propertyName);
+ this.arrayType = type;
+ this.namespace = namespace;
+ this.prefix = prefix;
+ }
+
+ public Cardinality getArrayType()
+ {
+ return arrayType;
+ }
+
+ public List<String> getElementsAsString()
+ {
+ List<String> retval = null;
+ retval = new ArrayList<String>();
+ Iterator<AbstractField> it = getContainer().getAllProperties().iterator();
+ AbstractSimpleProperty tmp;
+ while (it.hasNext())
+ {
+ tmp = (AbstractSimpleProperty) it.next();
+ retval.add(tmp.getStringValue());
+ }
+ retval = Collections.unmodifiableList(retval);
+ return retval;
+ }
+
+ /**
+ * Get the namespace URI of this entity
+ *
+ * @return the namespace URI
+ */
+ public final String getNamespace()
+ {
+ return namespace;
+ }
+
+ /**
+ * Get the prefix of this entity
+ *
+ * @return the prefix specified
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java Wed Mar 6 15:57:44 2013
@@ -27,93 +27,102 @@ package org.apache.xmpbox.type;
* @author a183132
*
*/
-public class Attribute {
+public class Attribute
+{
- private String nsURI;
+ private String nsURI;
- private String name;
+ private String name;
- private String value;
+ private String value;
+
+ /**
+ * Constructor of a new Attribute
+ *
+ * @param nsURI
+ * namespaceURI of this attribute (could be null)
+ * @param prefix
+ * prefix of this attribute
+ * @param localName
+ * localName of this attribute
+ * @param value
+ * value given to this attribute
+ */
+ public Attribute(String nsURI, String localName, String value)
+ {
+ this.nsURI = nsURI;
+ this.name = localName;
+ this.value = value;
+ }
+
+ /**
+ * Get the localName of this attribute
+ *
+ * @return local name of this attribute
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Set the localName of this attribute
+ *
+ * @param lname
+ * the local name to set
+ */
+ public void setName(String lname)
+ {
+ name = lname;
+ }
+
+ /**
+ * Get the namespace URI of this attribute
+ *
+ * @return the namespace URI associated to this attribute (could be null)
+ */
+ public String getNamespace()
+ {
+ return nsURI;
+ }
+
+ /**
+ * Set the namespace URI of this attribute
+ *
+ * @param nsURI
+ * the namespace URI to set
+ */
+ public void setNsURI(String nsURI)
+ {
+ this.nsURI = nsURI;
+ }
+
+ /**
+ * Get value of this attribute
+ *
+ * @return value of this attribute
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set value of this attribute
+ *
+ * @param value
+ * the value to set for this attribute
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder(80);
+ sb.append("[attr:{").append(nsURI).append("}").append(name).append("=").append(value).append("]");
+ return sb.toString();
+ }
- /**
- * Constructor of a new Attribute
- *
- * @param nsURI
- * namespaceURI of this attribute (could be null)
- * @param prefix
- * prefix of this attribute
- * @param localName
- * localName of this attribute
- * @param value
- * value given to this attribute
- */
- public Attribute(String nsURI, String localName, String value) {
- this.nsURI = nsURI;
- this.name = localName;
- this.value = value;
- }
-
- /**
- * Get the localName of this attribute
- *
- * @return local name of this attribute
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set the localName of this attribute
- *
- * @param lname
- * the local name to set
- */
- public void setName(String lname) {
- name = lname;
- }
-
- /**
- * Get the namespace URI of this attribute
- *
- * @return the namespace URI associated to this attribute (could be null)
- */
- public String getNamespace() {
- return nsURI;
- }
-
- /**
- * Set the namespace URI of this attribute
- *
- * @param nsURI
- * the namespace URI to set
- */
- public void setNsURI(String nsURI) {
- this.nsURI = nsURI;
- }
-
- /**
- * Get value of this attribute
- *
- * @return value of this attribute
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Set value of this attribute
- *
- * @param value
- * the value to set for this attribute
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString () {
- StringBuilder sb = new StringBuilder(80);
- sb.append("[attr:{").append(nsURI).append("}").append(name).append("=").append(value).append("]");
- return sb.toString();
- }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BadFieldValueException.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BadFieldValueException.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BadFieldValueException.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BadFieldValueException.java Wed Mar 6 15:57:44 2013
@@ -22,43 +22,44 @@
package org.apache.xmpbox.type;
/**
- * Exception thrown when Value found to set/get property content is not
- * compatible with object specifications (typically when trying to have a
- * property in a type that is not compatible with specified original type of
- * property concerned)
+ * Exception thrown when Value found to set/get property content is not compatible with object specifications (typically
+ * when trying to have a property in a type that is not compatible with specified original type of property concerned)
*
* @author a183132
*
*/
-public class BadFieldValueException extends Exception {
+public class BadFieldValueException extends Exception
+{
- /**
- *
- */
- private static final long serialVersionUID = 8100277682314632644L;
-
- /**
- * Create an instance of BadFieldValueException
- *
- * @param message
- * a description of the encountered problem
- */
- public BadFieldValueException(String message) {
- super(message);
-
- }
-
- /**
- * Create an instance of BadFieldValueException
- *
- * @param message
- * a description of the encountered problem
- * @param cause
- * the cause of the exception
- */
- public BadFieldValueException(String message, Throwable cause) {
- super(message, cause);
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8100277682314632644L;
+
+ /**
+ * Create an instance of BadFieldValueException
+ *
+ * @param message
+ * a description of the encountered problem
+ */
+ public BadFieldValueException(String message)
+ {
+ super(message);
+
+ }
+
+ /**
+ * Create an instance of BadFieldValueException
+ *
+ * @param message
+ * a description of the encountered problem
+ * @param cause
+ * the cause of the exception
+ */
+ public BadFieldValueException(String message, Throwable cause)
+ {
+ super(message, cause);
- }
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BooleanType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BooleanType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BooleanType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/BooleanType.java Wed Mar 6 15:57:44 2013
@@ -29,76 +29,86 @@ import org.apache.xmpbox.XMPMetadata;
* @author a183132
*
*/
-public class BooleanType extends AbstractSimpleProperty {
+public class BooleanType extends AbstractSimpleProperty
+{
- public static final String TRUE = "True";
+ public static final String TRUE = "True";
- public static final String FALSE = "False";
-
- private boolean booleanValue;
-
- /**
- * Property Boolean 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 give
- */
- public BooleanType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
-
- /**
- * return the property value
- *
- * @return boolean the property value
- */
- public Boolean getValue() {
- return booleanValue;
- }
-
- /**
- * Set value of this property BooleanTypeObject accept String value or a
- * boolean
- *
- * @param value
- * The value to set
- *
- */
- public void setValue(Object value) {
- if (value instanceof Boolean) {
- booleanValue = ((Boolean)value).booleanValue();
- } else if (value instanceof String) {
- // NumberFormatException is thrown (sub of InvalidArgumentException)
- String s = value.toString().trim().toUpperCase();
- if ("TRUE".equals(s)) {
- booleanValue = true;
- } else if ("FALSE".equals(s)) {
- booleanValue = false;
- } else {
- // unknown value
- throw new IllegalArgumentException("Not a valid boolean value : '"+value+"'");
- }
- } else {
- // invalid type of value
- throw new IllegalArgumentException("Value given is not allowed for the Boolean type.");
- }
- }
-
-
- @Override
- public String getStringValue() {
- return booleanValue?TRUE:FALSE;
- }
+ public static final String FALSE = "False";
+ private boolean booleanValue;
+ /**
+ * Property Boolean 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 give
+ */
+ public BooleanType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ /**
+ * return the property value
+ *
+ * @return boolean the property value
+ */
+ public Boolean getValue()
+ {
+ return booleanValue;
+ }
+
+ /**
+ * Set value of this property BooleanTypeObject accept String value or a boolean
+ *
+ * @param value
+ * The value to set
+ *
+ */
+ public void setValue(Object value)
+ {
+ if (value instanceof Boolean)
+ {
+ booleanValue = ((Boolean) value).booleanValue();
+ }
+ else if (value instanceof String)
+ {
+ // NumberFormatException is thrown (sub of InvalidArgumentException)
+ String s = value.toString().trim().toUpperCase();
+ if ("TRUE".equals(s))
+ {
+ booleanValue = true;
+ }
+ else if ("FALSE".equals(s))
+ {
+ booleanValue = false;
+ }
+ else
+ {
+ // unknown value
+ throw new IllegalArgumentException("Not a valid boolean value : '" + value + "'");
+ }
+ }
+ else
+ {
+ // invalid type of value
+ throw new IllegalArgumentException("Value given is not allowed for the Boolean type.");
+ }
+ }
+
+ @Override
+ public String getStringValue()
+ {
+ return booleanValue ? TRUE : FALSE;
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Cardinality.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Cardinality.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Cardinality.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/Cardinality.java Wed Mar 6 15:57:44 2013
@@ -21,21 +21,21 @@
package org.apache.xmpbox.type;
-public enum Cardinality {
+public enum Cardinality
+{
+
+ Simple(false), Bag(true), Seq(true), Alt(true);
+
+ private boolean array;
+
+ private Cardinality(boolean a)
+ {
+ this.array = a;
+ }
+
+ public boolean isArray()
+ {
+ return this.array;
+ }
- Simple(false),
- Bag(true),
- Seq(true),
- Alt(true);
-
- private boolean array;
-
- private Cardinality (boolean a) {
- this.array = a;
- }
-
- public boolean isArray () {
- return this.array;
- }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ChoiceType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ChoiceType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ChoiceType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ChoiceType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class ChoiceType extends TextType {
+public class ChoiceType extends TextType
+{
- public ChoiceType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public ChoiceType(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/ComplexPropertyContainer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ComplexPropertyContainer.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ComplexPropertyContainer.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/ComplexPropertyContainer.java Wed Mar 6 15:57:44 2013
@@ -26,224 +26,247 @@ import java.util.Iterator;
import java.util.List;
/**
- * Object representation for arrays content This Class could be used to define
- * directly a property with more than one field (structure) and also schemas
+ * Object representation for arrays content This Class could be used to define directly a property with more than one
+ * field (structure) and also schemas
*
* @author a183132
*
*/
-public class ComplexPropertyContainer /*extends AbstractField*/ {
+public class ComplexPropertyContainer /* extends AbstractField */
+{
+ private List<AbstractField> properties;
- private List<AbstractField> properties;
+ // private Map<String, Attribute> attributes;
-// private Map<String, Attribute> attributes;
-
-
-
- /**
- * Complex Property 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
- */
- public ComplexPropertyContainer() {
- properties = new ArrayList<AbstractField>();
-// attributes = new HashMap<String, Attribute>();
- }
-
-// /**
-// * Get an attribute with its name in this entity
-// *
-// * @param qualifiedName
-// * the full qualified name of the attribute wanted
-// * @return The attribute property
-// */
-// public Attribute getAttribute(String qualifiedName) {
-// return attributes.get(qualifiedName);
-// }
-
-// /**
-// * Get attributes list defined for this entity
-// *
-// * @return Attributes list
-// */
-// public List<Attribute> getAllAttributes() {
-// return new ArrayList<Attribute>(attributes.values());
-// }
-
-// /**
-// * Set a new attribute for this entity
-// *
-// * @param value
-// * The Attribute property to add
-// */
-// public void setAttribute(Attribute value) {
-// if (attributes.containsKey(value.getQualifiedName())) {
-// // if same name in element, attribute will be replaced
-// attributes.remove(value.getQualifiedName());
-// }
-// if (value.getNamespace() == null) {
-// attributes.put(value.getQualifiedName(), value);
-// } else {
-// attributes.put(value.getQualifiedName(), value);
-// }
-// }
-
-// /**
-// * Remove an attribute of this entity
-// *
-// * @param qualifiedName
-// * the full qualified name of the attribute wanted
-// */
-// public void removeAttribute(String qualifiedName) {
-// if (containsAttribute(qualifiedName)) {
-// attributes.remove(qualifiedName);
-// }
-//
-// }
-
-// /**
-// * Check if an attribute is declared for this entity
-// *
-// * @param qualifiedName
-// * the full qualified name of the attribute concerned
-// * @return true if attribute is present
-// */
-// public boolean containsAttribute(String qualifiedName) {
-// return attributes.containsKey(qualifiedName);
-// }
-
- /**
- * Give the first property found in this container with type and localname
- * expected
- *
- * @param localName
- * the localname of property wanted
- * @param type
- * the property type of property wanted
- * @return the property wanted
- */
- protected AbstractField getFirstEquivalentProperty(String localName,
- Class<? extends AbstractField> type) {
- List<AbstractField> list = getPropertiesByLocalName(localName);
- if (list != null) {
- for (AbstractField abstractField : list) {
- if (abstractField.getClass().equals(type)) {
- return abstractField;
- }
- }
- }
- return null;
- }
-
- /**
- * Add a property to the current structure
- *
- * @param obj the property to add
- */
- public void addProperty(AbstractField obj) {
- if (containsProperty(obj)) {
- removeProperty(obj);
- }
- properties.add(obj);
- }
-
- /**
- * Return all children associated to this property
- *
- * @return All Properties contained in this container
- */
- public List<AbstractField> getAllProperties() {
- return properties;
- }
-
- /**
- * Return all properties with this specified localName
- *
- * @param localName
- * the local name wanted
- * @return All properties with local name which match with localName given
- */
- public List<AbstractField> getPropertiesByLocalName(String localName) {
- List<AbstractField> absFields = getAllProperties();
- if (absFields != null) {
- List<AbstractField> list = new ArrayList<AbstractField>();
- for (AbstractField abstractField : absFields) {
- if (abstractField.getPropertyName().equals(localName)) {
- list.add(abstractField);
- }
- }
- if (list.size()==0) {
- return null;
- } else {
- return list;
- }
- }
- return null;
-
- }
-
- /**
- * Check if two property are similar
- *
- * @param prop1
- * First property
- * @param prop2
- * Second property
- * @return True if these properties are equals
- */
- public boolean isSameProperty(AbstractField prop1, AbstractField prop2) {
-
- if (prop1.getClass().equals(prop2.getClass())) {
- String pn1 = prop1.getPropertyName();
- String pn2 = prop2.getPropertyName();
- if (pn1==null) {
- return pn2==null;
- } else {
- if (pn1.equals(pn2)) {
- return prop1.equals(prop2);
- }
- }
- }
- return false;
- }
-
- /**
- * Check if a XMPFieldObject is in the complex property
- *
- * @param property
- * The property to check
- * @return True if property is present in this container
- */
- public boolean containsProperty(AbstractField property) {
- Iterator<AbstractField> it = getAllProperties().iterator();
- AbstractField tmp;
- while (it.hasNext()) {
- tmp = it.next();
- if (isSameProperty(tmp, property)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Remove a property
- *
- * @param property
- * The property to remove
- */
- public void removeProperty(AbstractField property) {
- if (containsProperty(property)) {
- properties.remove(property);
- }
- }
+ /**
+ * Complex Property 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
+ */
+ public ComplexPropertyContainer()
+ {
+ properties = new ArrayList<AbstractField>();
+ // attributes = new HashMap<String, Attribute>();
+ }
+
+ // /**
+ // * Get an attribute with its name in this entity
+ // *
+ // * @param qualifiedName
+ // * the full qualified name of the attribute wanted
+ // * @return The attribute property
+ // */
+ // public Attribute getAttribute(String qualifiedName) {
+ // return attributes.get(qualifiedName);
+ // }
+
+ // /**
+ // * Get attributes list defined for this entity
+ // *
+ // * @return Attributes list
+ // */
+ // public List<Attribute> getAllAttributes() {
+ // return new ArrayList<Attribute>(attributes.values());
+ // }
+
+ // /**
+ // * Set a new attribute for this entity
+ // *
+ // * @param value
+ // * The Attribute property to add
+ // */
+ // public void setAttribute(Attribute value) {
+ // if (attributes.containsKey(value.getQualifiedName())) {
+ // // if same name in element, attribute will be replaced
+ // attributes.remove(value.getQualifiedName());
+ // }
+ // if (value.getNamespace() == null) {
+ // attributes.put(value.getQualifiedName(), value);
+ // } else {
+ // attributes.put(value.getQualifiedName(), value);
+ // }
+ // }
+
+ // /**
+ // * Remove an attribute of this entity
+ // *
+ // * @param qualifiedName
+ // * the full qualified name of the attribute wanted
+ // */
+ // public void removeAttribute(String qualifiedName) {
+ // if (containsAttribute(qualifiedName)) {
+ // attributes.remove(qualifiedName);
+ // }
+ //
+ // }
+
+ // /**
+ // * Check if an attribute is declared for this entity
+ // *
+ // * @param qualifiedName
+ // * the full qualified name of the attribute concerned
+ // * @return true if attribute is present
+ // */
+ // public boolean containsAttribute(String qualifiedName) {
+ // return attributes.containsKey(qualifiedName);
+ // }
+
+ /**
+ * Give the first property found in this container with type and localname expected
+ *
+ * @param localName
+ * the localname of property wanted
+ * @param type
+ * the property type of property wanted
+ * @return the property wanted
+ */
+ protected AbstractField getFirstEquivalentProperty(String localName, Class<? extends AbstractField> type)
+ {
+ List<AbstractField> list = getPropertiesByLocalName(localName);
+ if (list != null)
+ {
+ for (AbstractField abstractField : list)
+ {
+ if (abstractField.getClass().equals(type))
+ {
+ return abstractField;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a property to the current structure
+ *
+ * @param obj
+ * the property to add
+ */
+ public void addProperty(AbstractField obj)
+ {
+ if (containsProperty(obj))
+ {
+ removeProperty(obj);
+ }
+ properties.add(obj);
+ }
+
+ /**
+ * Return all children associated to this property
+ *
+ * @return All Properties contained in this container
+ */
+ public List<AbstractField> getAllProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Return all properties with this specified localName
+ *
+ * @param localName
+ * the local name wanted
+ * @return All properties with local name which match with localName given
+ */
+ public List<AbstractField> getPropertiesByLocalName(String localName)
+ {
+ List<AbstractField> absFields = getAllProperties();
+ if (absFields != null)
+ {
+ List<AbstractField> list = new ArrayList<AbstractField>();
+ for (AbstractField abstractField : absFields)
+ {
+ if (abstractField.getPropertyName().equals(localName))
+ {
+ list.add(abstractField);
+ }
+ }
+ if (list.size() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return list;
+ }
+ }
+ return null;
+
+ }
+
+ /**
+ * Check if two property are similar
+ *
+ * @param prop1
+ * First property
+ * @param prop2
+ * Second property
+ * @return True if these properties are equals
+ */
+ public boolean isSameProperty(AbstractField prop1, AbstractField prop2)
+ {
+
+ if (prop1.getClass().equals(prop2.getClass()))
+ {
+ String pn1 = prop1.getPropertyName();
+ String pn2 = prop2.getPropertyName();
+ if (pn1 == null)
+ {
+ return pn2 == null;
+ }
+ else
+ {
+ if (pn1.equals(pn2))
+ {
+ return prop1.equals(prop2);
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if a XMPFieldObject is in the complex property
+ *
+ * @param property
+ * The property to check
+ * @return True if property is present in this container
+ */
+ public boolean containsProperty(AbstractField property)
+ {
+ Iterator<AbstractField> it = getAllProperties().iterator();
+ AbstractField tmp;
+ while (it.hasNext())
+ {
+ tmp = it.next();
+ if (isSameProperty(tmp, property))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Remove a property
+ *
+ * @param property
+ * The property to remove
+ */
+ public void removeProperty(AbstractField property)
+ {
+ if (containsProperty(property))
+ {
+ properties.remove(property);
+ }
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DateType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DateType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DateType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DateType.java Wed Mar 6 15:57:44 2013
@@ -27,18 +27,17 @@ import java.util.Calendar;
import org.apache.xmpbox.DateConverter;
import org.apache.xmpbox.XMPMetadata;
-
/**
* Object representation of a Date XMP type
*
* @author a183132
*
*/
-public class DateType extends AbstractSimpleProperty {
+public class DateType extends AbstractSimpleProperty
+{
+
+ private Calendar dateValue;
- private Calendar dateValue;
-
-
/**
* Property Date type constructor (namespaceURI is given)
*
@@ -53,8 +52,8 @@ public class DateType extends AbstractSi
* @param value
* The value to set for this property
*/
- public DateType(XMPMetadata metadata, String namespaceURI, String prefix,
- String propertyName, Object value) {
+ public DateType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
super(metadata, namespaceURI, prefix, propertyName, value);
}
@@ -65,7 +64,8 @@ public class DateType extends AbstractSi
* the new Calendar element value
* @throws InappropriateTypeException
*/
- private void setValueFromCalendar(Calendar value) {
+ private void setValueFromCalendar(Calendar value)
+ {
dateValue = value;
}
@@ -74,7 +74,8 @@ public class DateType extends AbstractSi
*
* @return boolean
*/
- public Calendar getValue() {
+ public Calendar getValue()
+ {
return dateValue;
}
@@ -85,14 +86,21 @@ public class DateType extends AbstractSi
* Object value to check
* @return True if types are compatibles
*/
- private boolean isGoodType(Object value) {
- if (value instanceof Calendar) {
+ private boolean isGoodType(Object value)
+ {
+ if (value instanceof Calendar)
+ {
return true;
- } else if (value instanceof String) {
- try {
+ }
+ else if (value instanceof String)
+ {
+ try
+ {
DateConverter.toCalendar((String) value);
return true;
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
return false;
}
}
@@ -105,15 +113,21 @@ public class DateType extends AbstractSi
* @param value
* The value to set
*/
- public void setValue(Object value) {
- if (!isGoodType(value)) {
- throw new IllegalArgumentException(
- "Value given is not allowed for the Date type : "+value.getClass());
- } else {
+ public void setValue(Object value)
+ {
+ if (!isGoodType(value))
+ {
+ throw new IllegalArgumentException("Value given is not allowed for the Date type : " + value.getClass());
+ }
+ else
+ {
// if string object
- if (value instanceof String) {
+ if (value instanceof String)
+ {
setValueFromString((String) value);
- } else {
+ }
+ else
+ {
// if Calendar
setValueFromCalendar((Calendar) value);
}
@@ -122,22 +136,25 @@ public class DateType extends AbstractSi
}
- public String getStringValue() {
- return DateConverter.toISO8601(dateValue);
- }
+ public String getStringValue()
+ {
+ return DateConverter.toISO8601(dateValue);
+ }
-
-
/**
* Set the property value with a String
*
* @param value
* The String value
*/
- private void setValueFromString(String value) {
- try {
+ private void setValueFromString(String value)
+ {
+ try
+ {
setValueFromCalendar(DateConverter.toCalendar((String) value));
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// SHOULD NEVER HAPPEN
// STRING HAS BEEN CHECKED BEFORE
throw new IllegalArgumentException(e);
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DefinedStructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DefinedStructuredType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DefinedStructuredType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/DefinedStructuredType.java Wed Mar 6 15:57:44 2013
@@ -26,30 +26,31 @@ import java.util.Map;
import org.apache.xmpbox.XMPMetadata;
-public class DefinedStructuredType extends AbstractStructuredType {
+public class DefinedStructuredType extends AbstractStructuredType
+{
- private Map<String, PropertyType> definedProperties = null;
-
- public DefinedStructuredType(XMPMetadata metadata, String namespaceURI,
- String fieldPrefix, String propertyName) {
- super(metadata, namespaceURI, fieldPrefix, propertyName);
- this.definedProperties = new HashMap<String, PropertyType>();
- }
-
- public DefinedStructuredType(XMPMetadata metadata) {
- super(metadata);
- this.definedProperties = new HashMap<String, PropertyType>();
- }
-
-
- public void addProperty (String name, PropertyType type) {
- definedProperties.put(name, type);
- }
-
- public Map<String, PropertyType> getDefinedProperties() {
- return definedProperties;
- }
+ private Map<String, PropertyType> definedProperties = null;
+ public DefinedStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName)
+ {
+ super(metadata, namespaceURI, fieldPrefix, propertyName);
+ this.definedProperties = new HashMap<String, PropertyType>();
+ }
+
+ public DefinedStructuredType(XMPMetadata metadata)
+ {
+ super(metadata);
+ this.definedProperties = new HashMap<String, PropertyType>();
+ }
+
+ public void addProperty(String name, PropertyType type)
+ {
+ definedProperties.put(name, type);
+ }
+
+ public Map<String, PropertyType> getDefinedProperties()
+ {
+ return definedProperties;
+ }
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/GUIDType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/GUIDType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/GUIDType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/GUIDType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class GUIDType extends TextType {
+public class GUIDType extends TextType
+{
- public GUIDType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public GUIDType(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/IntegerType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/IntegerType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/IntegerType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/IntegerType.java Wed Mar 6 15:57:44 2013
@@ -29,64 +29,69 @@ import org.apache.xmpbox.XMPMetadata;
* @author a183132
*
*/
-public class IntegerType extends AbstractSimpleProperty {
+public class IntegerType extends AbstractSimpleProperty
+{
+ private int integerValue;
- private int integerValue;
-
- /**
- * Property Integer 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 IntegerType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
-
- }
-
- /**
- * return the property value
- *
- * @return the property value
- */
- public Integer getValue() {
- return integerValue;
- }
-
- /**
- * Set the property value
- *
- * @param value
- * The value to set
- */
- public void setValue(Object value) {
- if (value instanceof Integer) {
- integerValue = ((Integer)value).intValue();
- } else if (value instanceof String) {
- integerValue = Integer.valueOf((String)value);
- // NumberFormatException is thrown (sub of InvalidArgumentException)
- } else {
- // invalid type of value
- throw new IllegalArgumentException("Value given is not allowed for the Integer type.");
- }
- }
-
- @Override
- public String getStringValue() {
- return Integer.toString(integerValue);
- }
-
-
-
+ /**
+ * Property Integer 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 IntegerType(XMPMetadata metadata, String namespaceURI, String prefix, String propertyName, Object value)
+ {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+
+ }
+
+ /**
+ * return the property value
+ *
+ * @return the property value
+ */
+ public Integer getValue()
+ {
+ return integerValue;
+ }
+
+ /**
+ * Set the property value
+ *
+ * @param value
+ * The value to set
+ */
+ public void setValue(Object value)
+ {
+ if (value instanceof Integer)
+ {
+ integerValue = ((Integer) value).intValue();
+ }
+ else if (value instanceof String)
+ {
+ integerValue = Integer.valueOf((String) value);
+ // NumberFormatException is thrown (sub of InvalidArgumentException)
+ }
+ else
+ {
+ // invalid type of value
+ throw new IllegalArgumentException("Value given is not allowed for the Integer type.");
+ }
+ }
+
+ @Override
+ public String getStringValue()
+ {
+ return Integer.toString(integerValue);
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/JobType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/JobType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/JobType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/JobType.java Wed Mar 6 15:57:44 2013
@@ -23,8 +23,9 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="stJob",namespace="http://ns.adobe.com/xap/1.0/sType/Job#")
-public class JobType extends AbstractStructuredType {
+@StructuredType(preferedPrefix = "stJob", namespace = "http://ns.adobe.com/xap/1.0/sType/Job#")
+public class JobType extends AbstractStructuredType
+{
@PropertyType(type = Types.Text, card = Cardinality.Simple)
public static final String ID = "id";
@@ -35,38 +36,45 @@ public class JobType extends AbstractStr
@PropertyType(type = Types.URL, card = Cardinality.Simple)
public static final String URL = "url";
-
- public JobType(XMPMetadata metadata) {
- this(metadata, null);
+ public JobType(XMPMetadata metadata)
+ {
+ this(metadata, null);
}
- public JobType(XMPMetadata metadata, String fieldPrefix) {
+ public JobType(XMPMetadata metadata, String fieldPrefix)
+ {
super(metadata, fieldPrefix);
addNamespace(getNamespace(), getPrefix());
}
- public void setId(String id) {
- addSimpleProperty(ID, id);
+ public void setId(String id)
+ {
+ addSimpleProperty(ID, id);
}
- public void setName( String name) {
- addSimpleProperty(NAME, name);
+ public void setName(String name)
+ {
+ addSimpleProperty(NAME, name);
}
- public void setUrl(String name) {
- addSimpleProperty(URL, name);
+ public void setUrl(String name)
+ {
+ addSimpleProperty(URL, name);
}
- public String getId() {
- return getPropertyValueAsString(ID);
+ public String getId()
+ {
+ return getPropertyValueAsString(ID);
}
- public String getName() {
- return getPropertyValueAsString(NAME);
+ public String getName()
+ {
+ return getPropertyValueAsString(NAME);
}
- public String getUrl() {
- return getPropertyValueAsString(URL);
+ public String getUrl()
+ {
+ return getPropertyValueAsString(URL);
}
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LayerType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LayerType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LayerType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LayerType.java Wed Mar 6 15:57:44 2013
@@ -24,75 +24,80 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.XmpConstants;
-@StructuredType(preferedPrefix="photoshop",namespace="http://ns.adobe.com/photoshop/1.0/")
-public class LayerType extends AbstractStructuredType {
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String LAYER_NAME = "LayerName";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String LAYER_TEXT = "LayerText";
-
-
- public LayerType(XMPMetadata metadata) {
- super(metadata);
- setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "parseType", "Resource"));
- }
-
- /**
- * Get The LayerName data
- *
- * @return the LayerName
- */
- public String getLayerName() {
- AbstractField absProp = getFirstEquivalentProperty(LAYER_NAME,
- TextType.class);
- if (absProp != null) {
- return ((TextType) absProp).getStringValue();
- }
- return null;
- }
-
- /**
- * Set LayerName
- *
- * @param prefix
- * the prefix of LayerName property to set
- * @param name
- * the name of LayerName property to set
- * @param image
- * the value of LayerName property to set
- */
- public void setLayerName(String image) {
- this.addProperty(createTextType ( LAYER_NAME, image));
- }
-
- /**
- * Get The LayerText data
- *
- * @return the LayerText
- */
- public String getLayerText() {
- AbstractField absProp = getFirstEquivalentProperty(LAYER_TEXT,
- TextType.class);
- if (absProp != null) {
- return ((TextType) absProp).getStringValue();
- }
- return null;
- }
-
- /**
- * Set LayerText
- *
- * @param prefix
- * the prefix of LayerText property to set
- * @param name
- * the name of LayerText property to set
- * @param image
- * the value of LayerText property to set
- */
- public void setLayerText(String image) {
- this.addProperty(createTextType ( LAYER_TEXT, image));
- }
+@StructuredType(preferedPrefix = "photoshop", namespace = "http://ns.adobe.com/photoshop/1.0/")
+public class LayerType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String LAYER_NAME = "LayerName";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String LAYER_TEXT = "LayerText";
+
+ public LayerType(XMPMetadata metadata)
+ {
+ super(metadata);
+ setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "parseType", "Resource"));
+ }
+
+ /**
+ * Get The LayerName data
+ *
+ * @return the LayerName
+ */
+ public String getLayerName()
+ {
+ AbstractField absProp = getFirstEquivalentProperty(LAYER_NAME, TextType.class);
+ if (absProp != null)
+ {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+ /**
+ * Set LayerName
+ *
+ * @param prefix
+ * the prefix of LayerName property to set
+ * @param name
+ * the name of LayerName property to set
+ * @param image
+ * the value of LayerName property to set
+ */
+ public void setLayerName(String image)
+ {
+ this.addProperty(createTextType(LAYER_NAME, image));
+ }
+
+ /**
+ * Get The LayerText data
+ *
+ * @return the LayerText
+ */
+ public String getLayerText()
+ {
+ AbstractField absProp = getFirstEquivalentProperty(LAYER_TEXT, TextType.class);
+ if (absProp != null)
+ {
+ return ((TextType) absProp).getStringValue();
+ }
+ return null;
+ }
+
+ /**
+ * Set LayerText
+ *
+ * @param prefix
+ * the prefix of LayerText property to set
+ * @param name
+ * the name of LayerText property to set
+ * @param image
+ * the value of LayerText property to set
+ */
+ public void setLayerText(String image)
+ {
+ this.addProperty(createTextType(LAYER_TEXT, image));
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LocaleType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LocaleType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LocaleType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/LocaleType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class LocaleType extends TextType {
+public class LocaleType extends TextType
+{
- public LocaleType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public LocaleType(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/MIMEType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/MIMEType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/MIMEType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/MIMEType.java Wed Mar 6 15:57:44 2013
@@ -23,11 +23,12 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-public class MIMEType extends TextType {
+public class MIMEType extends TextType
+{
- public MIMEType(XMPMetadata metadata, String namespaceURI,
- String prefix, String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
+ public MIMEType(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/PDFAFieldType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAFieldType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAFieldType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAFieldType.java Wed Mar 6 15:57:44 2013
@@ -23,37 +23,40 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="pdfaField",namespace="http://www.aiim.org/pdfa/ns/field#")
-public class PDFAFieldType extends AbstractStructuredType {
+@StructuredType(preferedPrefix = "pdfaField", namespace = "http://www.aiim.org/pdfa/ns/field#")
+public class PDFAFieldType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String NAME = "name";
+
+ @PropertyType(type = Types.Choice, card = Cardinality.Simple)
+ public static final String VALUETYPE = "valueType";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String DESCRIPTION = "description";
+
+ public PDFAFieldType(XMPMetadata metadata)
+ {
+ super(metadata);
+ }
+
+ public String getName()
+ {
+ TextType tt = (TextType) getProperty(NAME);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getValueType()
+ {
+ TextType tt = (TextType) getProperty(VALUETYPE);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getDescription()
+ {
+ TextType tt = (TextType) getProperty(DESCRIPTION);
+ return tt == null ? null : tt.getStringValue();
+ }
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String NAME = "name";
-
- @PropertyType(type = Types.Choice, card = Cardinality.Simple)
- public static final String VALUETYPE = "valueType";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String DESCRIPTION = "description";
-
- public PDFAFieldType(XMPMetadata metadata) {
- super(metadata);
- }
-
- public String getName () {
- TextType tt = (TextType) getProperty(NAME);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getValueType () {
- TextType tt = (TextType) getProperty(VALUETYPE);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getDescription () {
- TextType tt = (TextType) getProperty(DESCRIPTION);
- return tt == null ? null : tt.getStringValue();
- }
-
-
-
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAPropertyType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAPropertyType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAPropertyType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFAPropertyType.java Wed Mar 6 15:57:44 2013
@@ -23,44 +23,49 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="pdfaProperty",namespace="http://www.aiim.org/pdfa/ns/property#")
-public class PDFAPropertyType extends AbstractStructuredType {
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String NAME = "name";
-
- @PropertyType(type = Types.Choice, card = Cardinality.Simple)
- public static final String VALUETYPE = "valueType";
-
- @PropertyType(type = Types.Choice, card = Cardinality.Simple)
- public static final String CATEGORY = "category";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String DESCRIPTION = "description";
-
-
- public PDFAPropertyType(XMPMetadata metadata) {
- super(metadata);
- }
-
- public String getName () {
- TextType tt = (TextType) getProperty(NAME);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getValueType () {
- ChoiceType tt = (ChoiceType) getProperty(VALUETYPE);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getDescription () {
- TextType tt = (TextType) getProperty(DESCRIPTION);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getCategory () {
- ChoiceType tt = (ChoiceType) getProperty(CATEGORY);
- return tt == null ? null : tt.getStringValue();
- }
+@StructuredType(preferedPrefix = "pdfaProperty", namespace = "http://www.aiim.org/pdfa/ns/property#")
+public class PDFAPropertyType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String NAME = "name";
+
+ @PropertyType(type = Types.Choice, card = Cardinality.Simple)
+ public static final String VALUETYPE = "valueType";
+
+ @PropertyType(type = Types.Choice, card = Cardinality.Simple)
+ public static final String CATEGORY = "category";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String DESCRIPTION = "description";
+
+ public PDFAPropertyType(XMPMetadata metadata)
+ {
+ super(metadata);
+ }
+
+ public String getName()
+ {
+ TextType tt = (TextType) getProperty(NAME);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getValueType()
+ {
+ ChoiceType tt = (ChoiceType) getProperty(VALUETYPE);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getDescription()
+ {
+ TextType tt = (TextType) getProperty(DESCRIPTION);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getCategory()
+ {
+ ChoiceType tt = (ChoiceType) getProperty(CATEGORY);
+ return tt == null ? null : tt.getStringValue();
+ }
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFASchemaType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFASchemaType.java?rev=1453395&r1=1453394&r2=1453395&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFASchemaType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/type/PDFASchemaType.java Wed Mar 6 15:57:44 2013
@@ -23,46 +23,50 @@ package org.apache.xmpbox.type;
import org.apache.xmpbox.XMPMetadata;
-@StructuredType(preferedPrefix="pdfaSchema",namespace="http://www.aiim.org/pdfa/ns/schema#")
-public class PDFASchemaType extends AbstractStructuredType {
+@StructuredType(preferedPrefix = "pdfaSchema", namespace = "http://www.aiim.org/pdfa/ns/schema#")
+public class PDFASchemaType extends AbstractStructuredType
+{
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String SCHEMA = "schema";
+
+ @PropertyType(type = Types.URI, card = Cardinality.Simple)
+ public static final String NAMESPACE_URI = "namespaceURI";
+
+ @PropertyType(type = Types.Text, card = Cardinality.Simple)
+ public static final String PREFIX = "prefix";
+
+ @PropertyType(type = Types.PDFAProperty, card = Cardinality.Seq)
+ public static final String PROPERTY = "property";
+
+ @PropertyType(type = Types.PDFAType, card = Cardinality.Seq)
+ public static final String VALUE_TYPE = "valueType";
+
+ public PDFASchemaType(XMPMetadata metadata)
+ {
+ super(metadata);
+ }
+
+ public String getNamespaceURI()
+ {
+ URIType tt = (URIType) getProperty(NAMESPACE_URI);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public String getPrefixValue()
+ {
+ TextType tt = (TextType) getProperty(PREFIX);
+ return tt == null ? null : tt.getStringValue();
+ }
+
+ public ArrayProperty getProperty()
+ {
+ return (ArrayProperty) getArrayProperty(PROPERTY);
+ }
+
+ public ArrayProperty getValueType()
+ {
+ return (ArrayProperty) getArrayProperty(VALUE_TYPE);
+ }
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String SCHEMA = "schema";
-
- @PropertyType(type = Types.URI, card = Cardinality.Simple)
- public static final String NAMESPACE_URI = "namespaceURI";
-
- @PropertyType(type = Types.Text, card = Cardinality.Simple)
- public static final String PREFIX = "prefix";
-
- @PropertyType(type = Types.PDFAProperty, card = Cardinality.Seq)
- public static final String PROPERTY = "property";
-
- @PropertyType(type = Types.PDFAType, card = Cardinality.Seq)
- public static final String VALUE_TYPE = "valueType";
-
- public PDFASchemaType(XMPMetadata metadata) {
- super(metadata);
- }
-
- public String getNamespaceURI() {
- URIType tt = (URIType) getProperty(NAMESPACE_URI);
- return tt == null ? null : tt.getStringValue();
- }
-
- public String getPrefixValue() {
- TextType tt = (TextType) getProperty(PREFIX);
- return tt == null ? null : tt.getStringValue();
- }
-
- public ArrayProperty getProperty() {
- return (ArrayProperty) getArrayProperty(PROPERTY);
- }
-
- public ArrayProperty getValueType() {
- return (ArrayProperty) getArrayProperty(VALUE_TYPE);
- }
-
-
-
}