pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbaill...@apache.org
Subject svn commit: r1384755 - in /pdfbox/branches/xmpbox-refactoring/xmpbox/src: main/java/org/apache/padaf/xmpbox/ main/java/org/apache/padaf/xmpbox/parser/ main/java/org/apache/padaf/xmpbox/schema/ main/java/org/apache/padaf/xmpbox/type/ test/java/org/apach...
Date Fri, 14 Sep 2012 13:11:32 GMT
Author: gbailleul
Date: Fri Sep 14 13:11:31 2012
New Revision: 1384755

URL: http://svn.apache.org/viewvc?rev=1384755&view=rev
Log:
PDFBOX-1343: use annotations to define namespace and prefered prefix in structured types and schema, remove reflection to retrieve these values

Added:
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/StructuredType.java
Modified:
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/AdobePDFSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/DublinCoreSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAExtensionSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PhotoshopSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractComplexProperty.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractField.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractSimpleProperty.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractStructuredType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ArrayProperty.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/LayerType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAFieldType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAPropertyType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFASchemaType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFATypeType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceEventType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceRefType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ThumbnailType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/VersionType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/DoubleSameTypeSchemaTest.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/XMPMetadata.java Fri Sep 14 13:11:31 2012
@@ -37,6 +37,7 @@ import org.apache.padaf.xmpbox.schema.XM
 import org.apache.padaf.xmpbox.schema.XMPRightsManagementSchema;
 import org.apache.padaf.xmpbox.schema.XMPSchema;
 import org.apache.padaf.xmpbox.schema.XmpSchemaException;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TypeMapping;
 
 /**
@@ -211,6 +212,11 @@ public class XMPMetadata {
 		return null;
 	}
 
+	public XMPSchema getSchema (Class<? extends XMPSchema> clz) {
+		StructuredType st = clz.getAnnotation(StructuredType.class);
+		return getSchema(st.namespace());
+	}
+	
 	public void clearSchemas () {
 		schemas.clear();
 	}
@@ -249,7 +255,7 @@ public class XMPMetadata {
 	 * @return The schema added in order to work on it
 	 */
 	public XMPSchema createAndAddDefaultSchema(String nsPrefix, String nsURI) {
-		XMPSchema schem = new XMPSchema(this, nsPrefix, nsURI);
+		XMPSchema schem = new XMPSchema(this, nsURI,nsPrefix);
 		schem.setAboutAsSimple("");
 		addSchema(schem);
 		return schem;
@@ -307,7 +313,7 @@ public class XMPMetadata {
 	 * @return The PDFAExtension schema or null if not declared
 	 */
 	public PDFAExtensionSchema getPDFExtensionSchema() {
-		return (PDFAExtensionSchema) getSchema(PDFAExtensionSchema.PDFAEXTENSIONURI);
+		return (PDFAExtensionSchema) getSchema(PDFAExtensionSchema.class);
 	}
 
 	/**
@@ -329,7 +335,7 @@ public class XMPMetadata {
 	 * @return The PDFAIdentificationSchema schema or null if not declared
 	 */
 	public PDFAIdentificationSchema getPDFIdentificationSchema() {
-		return (PDFAIdentificationSchema) getSchema(PDFAIdentificationSchema.IDURI);
+		return (PDFAIdentificationSchema) getSchema(PDFAIdentificationSchema.class);
 	}
 
 	/**
@@ -365,7 +371,7 @@ public class XMPMetadata {
 	 * @return The DublinCoreSchema schema or null if not declared
 	 */
 	public DublinCoreSchema getDublinCoreSchema() {
-		return (DublinCoreSchema) getSchema(DublinCoreSchema.DCURI);
+		return (DublinCoreSchema) getSchema(DublinCoreSchema.class);
 	}
 
 	/**
@@ -374,7 +380,7 @@ public class XMPMetadata {
 	 * @return The XMPBasicJobTicketSchema schema or null if not declared
 	 */
 	public XMPBasicJobTicketSchema getBasicJobTicketSchema() {
-		return (XMPBasicJobTicketSchema) getSchema(XMPBasicJobTicketSchema.JOB_TICKET_URI);
+		return (XMPBasicJobTicketSchema) getSchema(XMPBasicJobTicketSchema.class);
 	}
 
 
@@ -384,7 +390,7 @@ public class XMPMetadata {
 	 * @return The XMPRightsManagementSchema schema or null if not declared
 	 */
 	public XMPRightsManagementSchema getXMPRightsManagementSchema() {
-		return (XMPRightsManagementSchema) getSchema(XMPRightsManagementSchema.XMPRIGHTSURI);
+		return (XMPRightsManagementSchema) getSchema(XMPRightsManagementSchema.class);
 	}
 
 	/**
@@ -415,7 +421,7 @@ public class XMPMetadata {
 	 * @return The XMPBasicSchema schema or null if not declared
 	 */
 	public XMPBasicSchema getXMPBasicSchema() {
-		return (XMPBasicSchema) getSchema(XMPBasicSchema.XMPBASICURI);
+		return (XMPBasicSchema) getSchema(XMPBasicSchema.class);
 	}
 
 	/**
@@ -449,7 +455,7 @@ public class XMPMetadata {
 	 * @return The XMPMediaManagementSchema schema or null if not declared
 	 */
 	public XMPMediaManagementSchema getXMPMediaManagementSchema() {
-		return (XMPMediaManagementSchema) getSchema(XMPMediaManagementSchema.XMPMMURI);
+		return (XMPMediaManagementSchema) getSchema(XMPMediaManagementSchema.class);
 	}
 
 	/**
@@ -471,7 +477,7 @@ public class XMPMetadata {
 	 * @return The AdobePDFSchema schema or null if not declared
 	 */
 	public AdobePDFSchema getAdobePDFSchema() {
-		return (AdobePDFSchema) getSchema(AdobePDFSchema.PDFURI);
+		return (AdobePDFSchema) getSchema(AdobePDFSchema.class);
 	}
 
 	/**

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java Fri Sep 14 13:11:31 2012
@@ -56,6 +56,7 @@ import org.apache.padaf.xmpbox.type.PDFA
 import org.apache.padaf.xmpbox.type.PDFAPropertyType;
 import org.apache.padaf.xmpbox.type.PDFASchemaType;
 import org.apache.padaf.xmpbox.type.PDFATypeType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TypeDescription;
 import org.apache.padaf.xmpbox.type.TypeMapping;
 import org.apache.pdfbox.io.IOUtils;
@@ -191,12 +192,13 @@ public class XMPDocumentBuilder {
 	private void populateSchemaMapping (XMPMetadata meta) 
 			throws XmpRequiredPropertyException,XmpUnknownValueTypeException,XmpUnexpectedNamespacePrefixException {
 		List<XMPSchema> schems = meta.getAllSchemas();
+		StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class);
 		for (XMPSchema xmpSchema : schems) {
-			if (xmpSchema.getNamespace().equals(PDFAExtensionSchema.PDFAEXTENSIONURI)) {
+			if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) {
 				// ensure the prefix is the preferred one (cannot use other definition)
-				if (!xmpSchema.getPrefix().equals(PDFAExtensionSchema.PREFERED_PREFIX)) {
+				if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) {
 					throw new XmpUnexpectedNamespacePrefixException("Found invalid prefix for PDF/A extension, found '"+
-							xmpSchema.getPrefix()+"', should be '"+PDFAExtensionSchema.PREFERED_PREFIX+"'"
+							xmpSchema.getPrefix()+"', should be '"+stPdfaExt.preferedPrefix()+"'"
 							);
 				}
 				// create schema and types
@@ -206,7 +208,7 @@ public class XMPDocumentBuilder {
 					if (af instanceof PDFASchemaType) {
 						PDFASchemaType st = (PDFASchemaType)af;
 						String namespaceUri = st.getNamespaceURI();
-						String prefix = st.getPrefix();
+						String prefix = st.getPrefixValue();
 						ArrayProperty properties = st.getProperty();
 						ArrayProperty valueTypes = st.getValueType();
 						XMPSchemaFactory xsf = meta.getTypeMapping().getSchemaFactory(namespaceUri);
@@ -223,7 +225,7 @@ public class XMPDocumentBuilder {
 									PDFATypeType type = (PDFATypeType)af2;
 									String ttype= type.getType();
 									String tns = type.getNamespaceURI();
-									String tprefix = type.getPrefix();
+									String tprefix = type.getPrefixValue();
 									String tdescription = type.getDescription();
 									ArrayProperty fields = type.getFields();
 									if (ttype==null || tns==null || tprefix==null || tdescription==null) {
@@ -852,8 +854,9 @@ public class XMPDocumentBuilder {
 //		NSMapping nsMap = metadata.getNsMapping();
 		TypeMapping typeMapping = metadata.getTypeMapping();
 		QName propertyName = reader.get().getName();
+		StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class);
 		if (parsingExtension) {
-			if (!propertyName.getNamespaceURI().equals(PDFAExtensionSchema.PDFAEXTENSIONURI)) {
+			if (!propertyName.getNamespaceURI().equals(stPdfaExt.namespace())) {
 				// this schema won't be parsed as extension, skip
 				// XXX skip to end of element
 				skipCurrentElement();

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/AdobePDFSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/AdobePDFSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/AdobePDFSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/AdobePDFSchema.java Fri Sep 14 13:11:31 2012
@@ -24,6 +24,7 @@ package org.apache.padaf.xmpbox.schema;
 import org.apache.padaf.xmpbox.XMPMetadata;
 import org.apache.padaf.xmpbox.type.AbstractField;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 
 /**
@@ -32,12 +33,9 @@ import org.apache.padaf.xmpbox.type.Text
  * @author a183132
  * 
  */
+@StructuredType(preferedPrefix="pdf",namespace="http://ns.adobe.com/pdf/1.3/")
 public class AdobePDFSchema extends XMPSchema {
 
-	public static final String PREFERED_PREFIX = "pdf";
-
-	public static final String PDFURI = "http://ns.adobe.com/pdf/1.3/";
-
 	@PropertyType(propertyType = "Text")
 	public static final String KEYWORDS = "Keywords";
 
@@ -54,7 +52,7 @@ public class AdobePDFSchema extends XMPS
 	 *            The metadata to attach this schema
 	 */
 	public AdobePDFSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, PDFURI);
+		super(metadata);
 	}
 
 	/**
@@ -66,7 +64,7 @@ public class AdobePDFSchema extends XMPS
 	 *            The prefix to assign
 	 */
 	public AdobePDFSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix, PDFURI);
+		super(metadata, ownPrefix);
 	}
 
 	/**

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/DublinCoreSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/DublinCoreSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/DublinCoreSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/DublinCoreSchema.java Fri Sep 14 13:11:31 2012
@@ -28,6 +28,7 @@ import org.apache.padaf.xmpbox.XMPMetada
 import org.apache.padaf.xmpbox.type.ArrayProperty;
 import org.apache.padaf.xmpbox.type.MIMEType;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 
 
@@ -37,12 +38,9 @@ import org.apache.padaf.xmpbox.type.Text
  * @author a183132
  * 
  */
+@StructuredType(preferedPrefix="dc",namespace="http://purl.org/dc/elements/1.1/")
 public class DublinCoreSchema extends XMPSchema {
 
-	public static final String PREFERED_PREFIX = "dc";
-
-	public static final String DCURI = "http://purl.org/dc/elements/1.1/";
-
 	@PropertyType(propertyType = "bag Text")
 	public static final String CONTRIBUTOR = "contributor";
 
@@ -95,7 +93,7 @@ public class DublinCoreSchema extends XM
 	 *            The metadata to attach this schema
 	 */
 	public DublinCoreSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, DCURI);
+		super(metadata);
 	}
 
 	/**
@@ -107,7 +105,7 @@ public class DublinCoreSchema extends XM
 	 *            The prefix to assign
 	 */
 	public DublinCoreSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix, DCURI);
+		super(metadata, ownPrefix);
 	}
 
 	/**

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAExtensionSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAExtensionSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAExtensionSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAExtensionSchema.java Fri Sep 14 13:11:31 2012
@@ -24,6 +24,7 @@ package org.apache.padaf.xmpbox.schema;
 import org.apache.padaf.xmpbox.XMPMetadata;
 import org.apache.padaf.xmpbox.type.ArrayProperty;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 
 /**
  * Representation of a PDF/A Extension schema description schema
@@ -31,12 +32,9 @@ import org.apache.padaf.xmpbox.type.Prop
  * @author a183132
  * 
  */
+@StructuredType(preferedPrefix="pdfaExtension",namespace="http://www.aiim.org/pdfa/ns/extension/")
 public class PDFAExtensionSchema extends XMPSchema {
 
-    public static final String PREFERED_PREFIX = "pdfaExtension";
-    public static final String PDFAEXTENSIONURI = "http://www.aiim.org/pdfa/ns/extension/";
-
-
     @PropertyType(propertyType = "bag PDFASchema")
     public static final String SCHEMAS = "schemas";
 
@@ -49,31 +47,13 @@ public class PDFAExtensionSchema extends
      *            The metadata to attach this schema XMPMetadata
      */
     public PDFAExtensionSchema(XMPMetadata metadata) {
-        this(metadata,PREFERED_PREFIX);
+        super(metadata);
     }
 
     public PDFAExtensionSchema(XMPMetadata metadata, String prefix) {
-        super(metadata, prefix, PDFAEXTENSIONURI);
-    }
-
-    /**
-     * Give the prefix of the PDF/A Extension schema
-     * 
-     * @return prefix value
-     */
-    public String getPrefixValue() {
-        return PREFERED_PREFIX;
-
+        super(metadata, prefix);
     }
 
-    /**
-     * Give the namespace URI of the PDF/A Extension schema
-     * 
-     * @return namespace URI
-     */
-    public String getNamespaceValue() {
-        return PDFAEXTENSIONURI;
-    }
 
 	/**
 	 * 

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PDFAIdentificationSchema.java Fri Sep 14 13:11:31 2012
@@ -27,6 +27,7 @@ import org.apache.padaf.xmpbox.type.Attr
 import org.apache.padaf.xmpbox.type.BadFieldValueException;
 import org.apache.padaf.xmpbox.type.IntegerType;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 
 
@@ -36,12 +37,9 @@ import org.apache.padaf.xmpbox.type.Text
  * @author a183132
  * 
  */
+@StructuredType(preferedPrefix="pdfaid",namespace="http://www.aiim.org/pdfa/ns/id/")
 public class PDFAIdentificationSchema extends XMPSchema {
 
-	public static final String PREFERED_PREFIX = "pdfaid";
-
-	public static final String IDURI = "http://www.aiim.org/pdfa/ns/id/";
-
 	@PropertyType(propertyType = "Integer")
 	public static final String PART = "part";
 
@@ -65,11 +63,11 @@ public class PDFAIdentificationSchema ex
 	 *            The metadata to attach this schema
 	 */
 	public PDFAIdentificationSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, IDURI);
+		super(metadata);
 	}
 
 	public PDFAIdentificationSchema(XMPMetadata metadata, String prefix) {
-		super(metadata, prefix, IDURI);
+		super(metadata, prefix);
 	}
 
 	/**

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PhotoshopSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PhotoshopSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PhotoshopSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/PhotoshopSchema.java Fri Sep 14 13:11:31 2012
@@ -33,17 +33,19 @@ import org.apache.padaf.xmpbox.type.Inte
 import org.apache.padaf.xmpbox.type.LayerType;
 import org.apache.padaf.xmpbox.type.ProperNameType;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 import org.apache.padaf.xmpbox.type.URIType;
 
+@StructuredType(preferedPrefix="photoshop",namespace="http://ns.adobe.com/photoshop/1.0/")
 public class PhotoshopSchema extends XMPSchema {
 
 	public PhotoshopSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, PHOTOSHOPURI);
+		super(metadata);
 	}
 
 	public PhotoshopSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix, PHOTOSHOPURI);
+		super(metadata, ownPrefix);
 	}
 				
 	public static final String PREFERED_PREFIX = "photoshop";

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicJobTicketSchema.java Fri Sep 14 13:11:31 2012
@@ -30,13 +30,11 @@ import org.apache.padaf.xmpbox.type.Arra
 import org.apache.padaf.xmpbox.type.BadFieldValueException;
 import org.apache.padaf.xmpbox.type.JobType;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 
+@StructuredType(preferedPrefix="xmpBJ",namespace="http://ns.adobe.com/xap/1.0/bj/")
 public class XMPBasicJobTicketSchema extends XMPSchema {
 
-    public static final String PREFERED_PREFIX = "xmpBJ";
-
-    public static final String JOB_TICKET_URI = "http://ns.adobe.com/xap/1.0/bj/"; 
-
     @PropertyType(propertyType = "bag Job")
     public static final String JOB_REF = "JobRef";
 
@@ -44,16 +42,18 @@ public class XMPBasicJobTicketSchema ext
 
 
     public XMPBasicJobTicketSchema(XMPMetadata metadata) {
-        this(metadata, PREFERED_PREFIX);
+        this(metadata,null);
     }
 
     public XMPBasicJobTicketSchema(XMPMetadata metadata, String ownPrefix) {
-        super(metadata, ownPrefix, JOB_TICKET_URI);
-        addNamespace(JobType.ELEMENT_NS, JobType.PREFERED_PREFIX);
+        super(metadata, ownPrefix);
+        // TODO why add this ns ?
+        StructuredType st = JobType.class.getAnnotation(StructuredType.class);
+        addNamespace(st.namespace(), st.preferedPrefix());
     }
 
     public void addJob(String id , String name, String url) {
-    	addJob(id,name,url,JobType.PREFERED_PREFIX);
+    	addJob(id,name,url,null);
     }
     
     public void addJob(String id , String name, String url, String fieldPrefix) {

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPBasicSchema.java Fri Sep 14 13:11:31 2012
@@ -33,6 +33,7 @@ import org.apache.padaf.xmpbox.type.BadF
 import org.apache.padaf.xmpbox.type.DateType;
 import org.apache.padaf.xmpbox.type.IntegerType;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 import org.apache.padaf.xmpbox.type.ThumbnailType;
 import org.apache.padaf.xmpbox.type.URLType;
@@ -44,12 +45,9 @@ import org.apache.padaf.xmpbox.type.URLT
  * @author a183132
  * 
  */
+@StructuredType(preferedPrefix="xmp",namespace="http://ns.adobe.com/xap/1.0/")
 public class XMPBasicSchema extends XMPSchema {
 
-	public static final String PREFERED_PREFIX = "xmp";
-
-	public static final String XMPBASICURI = "http://ns.adobe.com/xap/1.0/";
-
 	@PropertyType(propertyType = "bag Xpath")
 	public static final String ADVISORY = "Advisory";
 
@@ -92,7 +90,7 @@ public class XMPBasicSchema extends XMPS
 	 *            The metadata to attach this schema
 	 */
 	public XMPBasicSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, XMPBASICURI);
+		super(metadata);
 
 	}
 
@@ -105,7 +103,7 @@ public class XMPBasicSchema extends XMPS
 	 *            The prefix to assign
 	 */
 	public XMPBasicSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix, XMPBASICURI);
+		super(metadata, ownPrefix);
 
 	}
 

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementSchema.java Fri Sep 14 13:11:31 2012
@@ -29,6 +29,7 @@ import org.apache.padaf.xmpbox.type.Arra
 import org.apache.padaf.xmpbox.type.PropertyType;
 import org.apache.padaf.xmpbox.type.RenditionClassType;
 import org.apache.padaf.xmpbox.type.ResourceRefType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 import org.apache.padaf.xmpbox.type.URIType;
 import org.apache.padaf.xmpbox.type.VersionType;
@@ -40,12 +41,9 @@ import org.apache.padaf.xmpbox.type.Vers
  * @author gbailleul
  * 
  */
+@StructuredType(preferedPrefix="xmpMM",namespace="http://ns.adobe.com/xap/1.0/mm/")
 public class XMPMediaManagementSchema extends XMPSchema {
 
-	public static final String PREFERED_PREFIX = "xmpMM";
-
-	public static final String XMPMMURI = "http://ns.adobe.com/xap/1.0/mm/";
-
 	/**
 	 * Constructor of XMPMediaManagement Schema with preferred prefix
 	 * 
@@ -53,7 +51,7 @@ public class XMPMediaManagementSchema ex
 	 *            The metadata to attach this schema
 	 */
 	public XMPMediaManagementSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, XMPMMURI);
+		super(metadata);
 
 	}
 
@@ -66,7 +64,7 @@ public class XMPMediaManagementSchema ex
 	 *            The prefix to assign
 	 */
 	public XMPMediaManagementSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix, XMPMMURI);
+		super(metadata, ownPrefix);
 
 	}
 

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPRightsManagementSchema.java Fri Sep 14 13:11:31 2012
@@ -27,6 +27,7 @@ import org.apache.padaf.xmpbox.XMPMetada
 import org.apache.padaf.xmpbox.type.ArrayProperty;
 import org.apache.padaf.xmpbox.type.BooleanType;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.apache.padaf.xmpbox.type.TextType;
 import org.apache.padaf.xmpbox.type.URLType;
 
@@ -37,10 +38,8 @@ import org.apache.padaf.xmpbox.type.URLT
  * @author a183132
  * 
  */
+@StructuredType(preferedPrefix="xmpRights",namespace="http://ns.adobe.com/xap/1.0/rights/")
 public class XMPRightsManagementSchema extends XMPSchema {
-	public static final String PREFERED_PREFIX = "xmpRights";
-
-	public static final String XMPRIGHTSURI = "http://ns.adobe.com/xap/1.0/rights/";
 
 	@PropertyType(propertyType = "URL")
 	public static final String CERTIFICATE = "Certificate";
@@ -64,7 +63,7 @@ public class XMPRightsManagementSchema e
 	 *            The metadata to attach this schema
 	 */
 	public XMPRightsManagementSchema(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, XMPRIGHTSURI);
+		super(metadata);
 	}
 
 	/**
@@ -76,7 +75,7 @@ public class XMPRightsManagementSchema e
 	 *            The prefix to assign
 	 */
 	public XMPRightsManagementSchema(XMPMetadata metadata, String ownPrefix) {
-		super(metadata, ownPrefix, XMPRIGHTSURI);
+		super(metadata, ownPrefix);
 	}
 
 	/**

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchema.java Fri Sep 14 13:11:31 2012
@@ -66,11 +66,20 @@ public class XMPSchema extends AbstractS
 	 *            The URI of the namespace, ie "http://ns.adobe.com/pdf/1.3/"
 	 * 
 	 */
-	public XMPSchema(XMPMetadata metadata, String namespaceName, String namespaceURI) {
-		super(metadata, namespaceURI, namespaceName);
-		addNamespace(namespaceURI, namespaceName);
+	public XMPSchema(XMPMetadata metadata, String namespaceURI, String prefix) {
+		super(metadata, namespaceURI, prefix);
+		addNamespace(getNamespace(), getPrefix());
 	}
 
+	public XMPSchema(XMPMetadata metadata) {
+		this(metadata, null, null);
+	}
+
+	public XMPSchema(XMPMetadata metadata, String prefix) {
+		this(metadata, null, prefix);
+	}
+
+	
 	/**
 	 * Retrieve a generic simple type property
 	 * 

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/schema/XMPSchemaFactory.java Fri Sep 14 13:11:31 2012
@@ -121,7 +121,7 @@ public class XMPSchemaFactory {
 
 		if (schemaClass == XMPSchema.class) {
 			argsClass = new Class[] { XMPMetadata.class, String.class, String.class };
-			schemaArgs = new Object[] { metadata, nsName, namespace };
+			schemaArgs = new Object[] { metadata, namespace, nsName };
 		} else if (prefix != null && !"".equals(prefix)) {
 			argsClass = new Class[] { XMPMetadata.class, String.class };
 			schemaArgs = new Object[] { metadata, prefix };

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractComplexProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractComplexProperty.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractComplexProperty.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractComplexProperty.java Fri Sep 14 13:11:31 2012
@@ -34,9 +34,8 @@ public abstract class AbstractComplexPro
 	private Map<String,String> namespaceToPrefix;
 
 	
-	public AbstractComplexProperty(XMPMetadata metadata, String namespaceURI,
-			String prefix, String propertyName) {
-		super(metadata, namespaceURI, prefix, propertyName);
+	public AbstractComplexProperty(XMPMetadata metadata, String propertyName) {
+		super(metadata, propertyName);
 		container = new ComplexPropertyContainer();
 		this.namespaceToPrefix = new HashMap<String, String>();
 	}

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractField.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractField.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractField.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractField.java Fri Sep 14 13:11:31 2012
@@ -41,9 +41,9 @@ public abstract class AbstractField {
 
 	private XMPMetadata metadata;
 
-	private String namespaceURI;
+//	private String namespaceURI;
 	
-	private String prefix;
+//	private String prefix;
 	
 	private String propertyName;
 	
@@ -61,34 +61,13 @@ public abstract class AbstractField {
 	 * @param propertyName
 	 *            the local name to set for this field
 	 */
-	public AbstractField(XMPMetadata metadata, String namespaceURI,
-			String prefix, String propertyName) {
-		this.prefix = prefix;
+	public AbstractField(XMPMetadata metadata, String propertyName) {
 		this.metadata = metadata;
-		this.namespaceURI = namespaceURI;
 		this.propertyName = propertyName;
 		attributes = new HashMap<String, Attribute>();
 	}
 
 	/**
-	 * Get the namespace URI of this entity
-	 * 
-	 * @return the namespace URI
-	 */
-	public final String getNamespace() {
-		return namespaceURI;
-	}
-
-	/**
-	 * Get the prefix of this entity
-	 * 
-	 * @return the prefix specified
-	 */
-	public String getPrefix() {
-		return prefix;
-	}
-
-	/**
 	 * Get the propertyName (or localName)
 	 * 
 	 * @return the local Name
@@ -167,5 +146,14 @@ public abstract class AbstractField {
 		return metadata;
 	}
 
+	public abstract String getNamespace();
+
+	/**
+	 * Get the prefix of this entity
+	 * 
+	 * @return the prefix specified
+	 */
+	public abstract String getPrefix();
+
 	
 }

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractSimpleProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractSimpleProperty.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractSimpleProperty.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractSimpleProperty.java Fri Sep 14 13:11:31 2012
@@ -31,6 +31,11 @@ import org.apache.padaf.xmpbox.XMPMetada
  */
 public abstract class AbstractSimpleProperty extends AbstractField {
 
+	
+	private String namespace;
+	
+	private String prefix;
+
 	/**
 	 * Property specific type constructor (namespaceURI is given)
 	 * 
@@ -47,8 +52,10 @@ public abstract class AbstractSimpleProp
 	 */
 	public AbstractSimpleProperty(XMPMetadata metadata, String namespaceURI,
 			String prefix, String propertyName, Object value) {
-		super(metadata, namespaceURI, prefix, propertyName);
+		super(metadata, propertyName);
 		setValue(value);
+		this.namespace = namespaceURI;
+		this.prefix = prefix;
 
 	}
 
@@ -77,5 +84,23 @@ public abstract class AbstractSimpleProp
 		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/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractStructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractStructuredType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractStructuredType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/AbstractStructuredType.java Fri Sep 14 13:11:31 2012
@@ -29,12 +29,63 @@ public abstract class AbstractStructured
 
 	
 	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);
+	}
+
+	public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) {
+		this(metadata,namespaceURI,null);
+	}
+	
 	public AbstractStructuredType(XMPMetadata metadata, String namespaceURI,
 			String fieldPrefix) {
-		super(metadata, namespaceURI, fieldPrefix, STRUCTURE_ARRAY_NAME);
+		super(metadata, STRUCTURE_ARRAY_NAME);
+		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;
+	}
+
+	/**
+	 * Get the prefix of this entity
+	 * 
+	 * @return the prefix specified
+	 */
+	public final String getPrefix() {
+		return prefix;
+	}
+
+	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);

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ArrayProperty.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ArrayProperty.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ArrayProperty.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ArrayProperty.java Fri Sep 14 13:11:31 2012
@@ -45,6 +45,10 @@ public class ArrayProperty extends Abstr
 	
 	private String arrayType;
 
+	private String namespace;
+	
+	private String prefix;
+
 	/**
 	 * Contructor of a complex property
 	 * 
@@ -61,8 +65,10 @@ public class ArrayProperty extends Abstr
 	 */
 	public ArrayProperty(XMPMetadata metadata, String namespace,
 			String prefix, String propertyName, String type) {
-		super(metadata, namespace, prefix, propertyName);
+		super(metadata, propertyName);
 		this.arrayType = type;
+		this.namespace = namespace;
+		this.prefix = prefix;
 	}
 
 	public String getArrayType() {
@@ -84,5 +90,23 @@ public class ArrayProperty extends Abstr
 		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/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/JobType.java Fri Sep 14 13:11:31 2012
@@ -23,12 +23,9 @@ package org.apache.padaf.xmpbox.type;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="stJob",namespace="http://ns.adobe.com/xap/1.0/sType/Job#")
 public class JobType extends AbstractStructuredType {
 
-    public static final String ELEMENT_NS = "http://ns.adobe.com/xap/1.0/sType/Job#";
-
-    public static final String PREFERED_PREFIX = "stJob";
-    
     @PropertyType(propertyType="Text")
     public static final String ID = "id";
 
@@ -40,12 +37,12 @@ public class JobType extends AbstractStr
 
 
     public JobType(XMPMetadata metadata) {
-    	this(metadata, PREFERED_PREFIX);
+    	this(metadata, null);
     }
 
     public JobType(XMPMetadata metadata, String fieldPrefix) {
-        super(metadata, ELEMENT_NS, fieldPrefix);
-        addNamespace(ELEMENT_NS, fieldPrefix);
+        super(metadata, fieldPrefix);
+        addNamespace(getNamespace(), getPrefix());
     }
 
     public void setId(String id) {

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/LayerType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/LayerType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/LayerType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/LayerType.java Fri Sep 14 13:11:31 2012
@@ -24,11 +24,8 @@ package org.apache.padaf.xmpbox.type;
 import org.apache.padaf.xmpbox.XMPMetadata;
 import org.apache.padaf.xmpbox.XmpConstants;
 
+@StructuredType(preferedPrefix="photoshop",namespace="http://ns.adobe.com/photoshop/1.0/")
 public class LayerType extends AbstractStructuredType {
-
-	public static final String PREFERED_PREFIX = "photoshop";
-	
-	public static final String ELEMENT_NS = "http://ns.adobe.com/photoshop/1.0/";
 	
 	@PropertyType(propertyType="Text")
 	public static final String LAYER_NAME = "LayerName";
@@ -38,7 +35,7 @@ public class LayerType extends AbstractS
 
 	
 	public LayerType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERED_PREFIX);
+		super(metadata);
 		setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "parseType", "Resource"));
 	}
 	

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAFieldType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAFieldType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAFieldType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAFieldType.java Fri Sep 14 13:11:31 2012
@@ -23,12 +23,9 @@ package org.apache.padaf.xmpbox.type;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="pdfaField",namespace="http://www.aiim.org/pdfa/ns/field#")
 public class PDFAFieldType extends AbstractStructuredType {
 
-    public static final String ELEMENT_NS = "http://www.aiim.org/pdfa/ns/field#";
-
-    public static final String PREFERED_PREFIX = "pdfaField";
-
 	@PropertyType(propertyType = "Text")
 	public static final String NAME = "name";
 
@@ -39,7 +36,7 @@ public class PDFAFieldType extends Abstr
 	public static final String DESCRIPTION = "description";
 
 	public PDFAFieldType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERED_PREFIX);
+		super(metadata);
 	}
 
 	public String getName () {

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAPropertyType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAPropertyType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAPropertyType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFAPropertyType.java Fri Sep 14 13:11:31 2012
@@ -23,12 +23,9 @@ package org.apache.padaf.xmpbox.type;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="pdfaProperty",namespace="http://www.aiim.org/pdfa/ns/property#")
 public class PDFAPropertyType extends AbstractStructuredType {
 
-    public static final String ELEMENT_NS = "http://www.aiim.org/pdfa/ns/property#";
-
-    public static final String PREFERED_PREFIX = "pdfaProperty";
-
 	@PropertyType(propertyType = "Text")
 	public static final String NAME = "name";
 
@@ -43,7 +40,7 @@ public class PDFAPropertyType extends Ab
 
 
 	public PDFAPropertyType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERED_PREFIX);
+		super(metadata);
 	}
 
 	public String getName () {

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFASchemaType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFASchemaType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFASchemaType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFASchemaType.java Fri Sep 14 13:11:31 2012
@@ -23,12 +23,9 @@ package org.apache.padaf.xmpbox.type;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="pdfaSchema",namespace="http://www.aiim.org/pdfa/ns/schema#")
 public class PDFASchemaType extends AbstractStructuredType {
 
-    public static final String ELEMENT_NS = "http://www.aiim.org/pdfa/ns/schema#";
-
-    public static final String PREFERED_PREFIX = "pdfaSchema";
-
 	@PropertyType(propertyType = "Text")
 	public static final String SCHEMA = "schema";
 
@@ -45,7 +42,7 @@ public class PDFASchemaType extends Abst
 	public static final String VALUE_TYPE = "valueType";
 
 	public PDFASchemaType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERED_PREFIX);
+		super(metadata);
 	}
 
 	public String getNamespaceURI() {
@@ -53,7 +50,7 @@ public class PDFASchemaType extends Abst
 		return tt == null ? null : tt.getStringValue();
 	}
 
-	public String getPrefix() {
+	public String getPrefixValue() {
 		TextType tt = (TextType) getProperty(PREFIX);
 		return tt == null ? null : tt.getStringValue();
 	}

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFATypeType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFATypeType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFATypeType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/PDFATypeType.java Fri Sep 14 13:11:31 2012
@@ -23,14 +23,10 @@ package org.apache.padaf.xmpbox.type;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="pdfaType",namespace="http://www.aiim.org/pdfa/ns/type#")
 public class PDFATypeType extends AbstractStructuredType {
 
-    public static final String ELEMENT_NS = "http://www.aiim.org/pdfa/ns/type#";
-
-    public static final String PREFERED_PREFIX = "pdfaType";
-
-
-	@PropertyType(propertyType = "Text")
+ 	@PropertyType(propertyType = "Text")
 	public static final String TYPE = "type";
 
 	@PropertyType(propertyType = "URI")
@@ -46,7 +42,7 @@ public class PDFATypeType extends Abstra
 	public static final String FIELD = "field";
 
 	public PDFATypeType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERED_PREFIX);
+		super(metadata);
 	}
 
 	public String getNamespaceURI() {
@@ -59,7 +55,7 @@ public class PDFATypeType extends Abstra
 		return tt == null ? null : tt.getStringValue();
 	}
 
-	public String getPrefix() {
+	public String getPrefixValue() {
 		TextType tt = (TextType) getProperty(PREFIX);
 		return tt == null ? null : tt.getStringValue();
 	}

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceEventType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceEventType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceEventType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceEventType.java Fri Sep 14 13:11:31 2012
@@ -25,12 +25,9 @@ import java.util.Calendar;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="stEvt",namespace="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#")
 public class ResourceEventType extends AbstractStructuredType {
 
-	public static final String ELEMENT_NS = "http://ns.adobe.com/xap/1.0/sType/ResourceEvent#";
-
-	public static final String PREFERRED_PREFIX = "stEvt";
-	
 	@PropertyType(propertyType="Choice")
 	public static final String ACTION = "action";
 
@@ -62,8 +59,8 @@ public class ResourceEventType extends A
 	 *            The local Name of this thumbnail type
 	 */
 	public ResourceEventType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
-		addNamespace(ELEMENT_NS, PREFERRED_PREFIX);
+		super(metadata);
+		addNamespace(getNamespace(), getPreferedPrefix());
 	}
 	
 	

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceRefType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceRefType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceRefType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ResourceRefType.java Fri Sep 14 13:11:31 2012
@@ -26,12 +26,9 @@ import java.util.List;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="stRef",namespace="http://ns.adobe.com/xap/1.0/sType/ResourceRef#")
 public class ResourceRefType extends AbstractStructuredType {
 
-	public static final String ELEMENT_NS = "http://ns.adobe.com/xap/1.0/sType/ResourceRef#";
-
-	public static final String PREFERRED_PREFIX = "stRef";
-	
 	@PropertyType(propertyType = "URI")
 	public static final String DOCUMENT_ID = "documentID";
 
@@ -91,8 +88,8 @@ public class ResourceRefType extends Abs
 	 *            The local Name of this thumbnail type
 	 */
 	public ResourceRefType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
-		addNamespace(ELEMENT_NS, PREFERRED_PREFIX);
+		super(metadata);
+		addNamespace(getNamespace(), getPreferedPrefix());
 		
 	}
 	
@@ -295,7 +292,7 @@ public class ResourceRefType extends Abs
         ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class);
         if (seq==null) {
         	seq = getMetadata().getTypeMapping().createArrayProperty(null,
-                    PREFERRED_PREFIX, ALTERNATE_PATHS,
+                    getPreferedPrefix(), ALTERNATE_PATHS,
                     ArrayProperty.ORDERED_ARRAY);
         	addProperty(seq);
         }

Added: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/StructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/StructuredType.java?rev=1384755&view=auto
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/StructuredType.java (added)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/StructuredType.java Fri Sep 14 13:11:31 2012
@@ -0,0 +1,16 @@
+package org.apache.padaf.xmpbox.type;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface StructuredType {
+
+	String namespace ();
+	
+	String preferedPrefix();
+	
+}

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ThumbnailType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ThumbnailType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ThumbnailType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ThumbnailType.java Fri Sep 14 13:11:31 2012
@@ -30,12 +30,9 @@ import org.apache.padaf.xmpbox.XmpConsta
  * 
  * @author eric
  */
+@StructuredType(preferedPrefix="xmpGImg",namespace="http://ns.adobe.com/xap/1.0/g/img/")
 public class ThumbnailType extends AbstractStructuredType {
 	
-	public static final String ELEMENT_NS = "http://ns.adobe.com/xap/1.0/g/img/";
-	
-	public static final String PREFERRED_PREFIX = "xmpGImg";
-	
 	@PropertyType(propertyType = "Choice")
 	public static final String FORMAT = "format";
 
@@ -60,7 +57,7 @@ public class ThumbnailType extends Abstr
 	 *            The local Name of this thumbnail type
 	 */
 	public ThumbnailType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
+		super(metadata);
 		setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "parseType", "Resource"));
 	}
 

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.java Fri Sep 14 13:11:31 2012
@@ -62,7 +62,7 @@ public final class TypeMapping {
 	private Map<Class<? extends AbstractField>,TypeDescription<AbstractStructuredType>> STRUCTURED_CLASSES;
 
 	private Map<String,TypeDescription<AbstractStructuredType>> STRUCTURED_NAMESPACES;
-	
+
 	private Map<String, String> schemaUriToPrefered;
 
 	private XMPMetadata metadata;
@@ -125,19 +125,19 @@ public final class TypeMapping {
 		addToStructuredMaps(new TypeDescription<AbstractStructuredType>("PDFAProperty",null,PDFAPropertyType.class));
 		addToStructuredMaps(new TypeDescription<AbstractStructuredType>("PDFAType",null,PDFATypeType.class));
 		addToStructuredMaps(new TypeDescription<AbstractStructuredType>("PDFASchema",null,PDFASchemaType.class));
-		
+
 		// schema
 		schemaUriToPrefered = new HashMap<String, String>();
 		schemaMap = new HashMap<String, XMPSchemaFactory>();
-		addNameSpace("http://ns.adobe.com/xap/1.0/", XMPBasicSchema.class);
-		addNameSpace(DublinCoreSchema.DCURI, DublinCoreSchema.class);
-		addNameSpace("http://www.aiim.org/pdfa/ns/extension/", PDFAExtensionSchema.class);
-		addNameSpace("http://ns.adobe.com/xap/1.0/mm/", XMPMediaManagementSchema.class);
-		addNameSpace("http://ns.adobe.com/pdf/1.3/", AdobePDFSchema.class);
-		addNameSpace("http://www.aiim.org/pdfa/ns/id/", PDFAIdentificationSchema.class);
-		addNameSpace("http://ns.adobe.com/xap/1.0/rights/",     XMPRightsManagementSchema.class);
-		addNameSpace(PhotoshopSchema.PHOTOSHOPURI,      PhotoshopSchema.class);
-		addNameSpace(XMPBasicJobTicketSchema.JOB_TICKET_URI,XMPBasicJobTicketSchema.class);
+		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);
 
 	}
 
@@ -151,27 +151,21 @@ public final class TypeMapping {
 		DERIVED_CLASSES.put(td.getTypeClass(), td);
 	}
 
-	public void addToStructuredMaps (TypeDescription<AbstractStructuredType> td) {
-		try {
-			String ns = (String)td.getTypeClass().getField("ELEMENT_NS").get(null);
-			Class<? extends AbstractStructuredType> clz = td.getTypeClass();
-			if (clz!=null) {
-				PropMapping pm = ReflectHelper.initializePropMapping(ns, clz);
-				td.setProperties(pm);
-			} else {
-				PropMapping pm = initializePropMapping(ns, null);
-				td.setProperties(pm);
-			}
-			addToStructuredMaps(td, ns);
-		} catch (IllegalArgumentException e) {
-			throw new IllegalArgumentException("Failed to init structured maps for "+td.getTypeClass(), e);
-		} catch (SecurityException e) {
-			throw new IllegalArgumentException("Failed to init structured maps for "+td.getTypeClass(), e);
-		} catch (IllegalAccessException e) {
-			throw new IllegalArgumentException("Failed to init structured maps for "+td.getTypeClass(), e);
-		} catch (NoSuchFieldException e) {
-			throw new IllegalArgumentException("Failed to init structured maps for "+td.getTypeClass(), e);
-		}
+	private void addToStructuredMaps (TypeDescription<AbstractStructuredType> td) {
+		Class<? extends AbstractStructuredType> clz = td.getTypeClass();
+		StructuredType st = clz.getAnnotation(StructuredType.class);
+		if (st==null) {
+			System.err.println(">> "+clz);
+		}
+		String ns = st.namespace();
+//		if (clz!=null) {
+			PropMapping pm = ReflectHelper.initializePropMapping(ns, clz);
+			td.setProperties(pm);
+//		} else {
+//			PropMapping pm = initializePropMapping(ns, null);
+//			td.setProperties(pm);
+//		}
+		addToStructuredMaps(td, ns);
 	}
 
 	public void addToStructuredMaps (TypeDescription<AbstractStructuredType> td, String ns) {
@@ -240,7 +234,7 @@ public final class TypeMapping {
 		return STRUCTURED_TYPES.get(type);
 	}
 
-	
+
 	public AbstractStructuredType instanciateStructuredType (TypeDescription<AbstractStructuredType> td) throws BadFieldValueException {
 		try {
 			Class<? extends AbstractStructuredType> propertyTypeClass = td.getTypeClass();
@@ -361,28 +355,21 @@ public final class TypeMapping {
 		return STRUCTURED_TYPES.containsKey(type);
 	}
 
-	private static PropMapping initializePropMapping(String ns,
-			DefinedStructuredType dst) {
-		PropMapping propMap = new PropMapping(ns);
-		for (Entry<String, String> entry: dst.getDefinedProperties().entrySet()) {
-			propMap.addNewProperty(entry.getKey(), entry.getValue());
-		}
-		return propMap;
-	}
-
-	private void addNameSpace(String ns, Class<? extends XMPSchema> classSchem) {
+//	private static PropMapping initializePropMapping(String ns,
+//			DefinedStructuredType dst) {
+//		PropMapping propMap = new PropMapping(ns);
+//		for (Entry<String, String> entry: dst.getDefinedProperties().entrySet()) {
+//			propMap.addNewProperty(entry.getKey(), entry.getValue());
+//		}
+//		return propMap;
+//	}
+
+	private void addNameSpace(Class<? extends XMPSchema> classSchem) {
+		StructuredType st = classSchem.getAnnotation(StructuredType.class);
+		String ns = st.namespace();
+		String pp = st.preferedPrefix();
 		schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem,	ReflectHelper.initializePropMapping(ns, classSchem)));
-		try {
-			schemaUriToPrefered.put(ns, classSchem.getField("PREFERED_PREFIX").get(null).toString());
-		} catch (IllegalArgumentException e) {
-			throw new IllegalArgumentException("Failed to init '"+ns+"'", e);
-		} catch (SecurityException e) {
-			throw new IllegalArgumentException("Failed to init '"+ns+"'", e);
-		} catch (IllegalAccessException e) {
-			throw new IllegalArgumentException("Failed to init '"+ns+"'", e);
-		} catch (NoSuchFieldException e) {
-			throw new IllegalArgumentException("Failed to init '"+ns+"'", e);
-		}
+		schemaUriToPrefered.put(ns, pp);
 	}
 
 	public void addNewNameSpace(String ns,String prefered) {
@@ -457,32 +444,32 @@ public final class TypeMapping {
 			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);
@@ -536,5 +523,5 @@ public final class TypeMapping {
 	public ArrayProperty createArrayProperty (String namespace, String prefix, String propertyName, String type) {
 		return new ArrayProperty(metadata, namespace, prefix, propertyName, type);
 	}
-	
+
 }

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/VersionType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/VersionType.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/VersionType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/VersionType.java Fri Sep 14 13:11:31 2012
@@ -25,12 +25,9 @@ import java.util.Calendar;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
+@StructuredType(preferedPrefix="stVer",namespace="http://ns.adobe.com/xap/1.0/sType/Version#")
 public class VersionType extends AbstractStructuredType {
 
-	public static final String ELEMENT_NS = "http://ns.adobe.com/xap/1.0/sType/Version#";
-
-	public static final String PREFERRED_PREFIX = "stVer";
-	
 	@PropertyType(propertyType="Text")
 	public static final String COMMENTS = "comments";
 
@@ -59,8 +56,8 @@ public class VersionType extends Abstrac
 	 *            The local Name of this thumbnail type
 	 */
 	public VersionType(XMPMetadata metadata) {
-		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
-		addNamespace(ELEMENT_NS,PREFERRED_PREFIX);
+		super(metadata);
+		addNamespace(getNamespace(),getPreferedPrefix());
 	}
 	
 	

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java Fri Sep 14 13:11:31 2012
@@ -30,15 +30,13 @@ import org.apache.padaf.xmpbox.schema.Sc
 import org.apache.padaf.xmpbox.schema.XMPSchema;
 import org.apache.padaf.xmpbox.type.Attribute;
 import org.apache.padaf.xmpbox.type.PropertyType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 
 
 @SchemaExtensionDefinition(schema = "Birth-Certificate Schema", valueType_description = "/org/apache/padaf/xmpbox/valueTypeDescription.xml", property_descriptions = "propertiesDescription.xml")
+@StructuredType(preferedPrefix="adn",namespace="http://test.apache.com/xap/adn/")
 public class BirthCertificateSchemaWithXMLDescriptions extends XMPSchema {
 
-	public static final String PREFERED_PREFIX = "adn";
-
-	public static final String NAMESPACE = "http://test.apache.com/xap/adn/";
-
 	@PropertyType(propertyType = "Text")
 	@PropertyExtensionDefinition(propertyCategory = "external")
 	public static final String FIRST_NAME = "firstname";
@@ -64,7 +62,7 @@ public class BirthCertificateSchemaWithX
 //	public static final String MAIL_ADR = "mail";
 
 	public BirthCertificateSchemaWithXMLDescriptions(XMPMetadata metadata) {
-		super(metadata, PREFERED_PREFIX, NAMESPACE);
+		super(metadata);
 		this.setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "madn",
 				"http://test.withfield.com/vt/"));
 		this.setAboutAsSimple("");

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/DoubleSameTypeSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/DoubleSameTypeSchemaTest.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/DoubleSameTypeSchemaTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/DoubleSameTypeSchemaTest.java Fri Sep 14 13:11:31 2012
@@ -28,6 +28,7 @@ import junit.framework.Assert;
 
 import org.apache.padaf.xmpbox.schema.DublinCoreSchema;
 import org.apache.padaf.xmpbox.schema.XMPSchema;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -68,13 +69,15 @@ public class DoubleSameTypeSchemaTest {
 		dc2.addCreator(creators.get(0));
 		dc2.addCreator(creators.get(1));
 
+		StructuredType stDub = DublinCoreSchema.class.getAnnotation(StructuredType.class);
+		
 		// We can't use metadata.getDublinCoreSchema() due to specification of
 		// XMPBox (see Javadoc of XMPMetadata)
 		Assert.assertEquals(format, ((DublinCoreSchema) metadata.getSchema(
-				DublinCoreSchema.PREFERED_PREFIX, DublinCoreSchema.DCURI))
+				stDub.preferedPrefix(), stDub.namespace()))
 				.getFormat());
 		Assert.assertEquals(coverage, ((DublinCoreSchema) metadata.getSchema(
-				ownPrefix, DublinCoreSchema.DCURI)).getCoverage());
+				ownPrefix, stDub.namespace())).getCoverage());
 
 		List<XMPSchema> schems = metadata.getAllSchemas();
 		DublinCoreSchema dc;

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java Fri Sep 14 13:11:31 2012
@@ -48,7 +48,7 @@ public class XMPMetaDataTest {
 	public void init() throws Exception {
 		metadata = XMPMetadata.createXMPMetadata();
 		String tmpNsURI = "http://www.test.org/schem/";
-		tmp = new XMPSchema(metadata, "test", tmpNsURI);
+		tmp = new XMPSchema(metadata, tmpNsURI, "test");
 		tmp.addQualifiedBagValue("BagContainer", "Value1");
 		tmp.addQualifiedBagValue("BagContainer", "Value2");
 		tmp.addQualifiedBagValue("BagContainer", "Value3");
@@ -61,7 +61,7 @@ public class XMPMetaDataTest {
 				.addProperty(metadata.getTypeMapping().createText(null,"test", "simpleProperty",
 						"YEP"));
 
-		tmp2 = new XMPSchema(metadata, "space", "http://www.space.org/schem/");
+		tmp2 = new XMPSchema(metadata, "http://www.space.org/schem/", "space");
 		tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace1");
 		tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace2");
 		tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace3");

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java Fri Sep 14 13:11:31 2012
@@ -31,6 +31,7 @@ import org.apache.padaf.xmpbox.XMPMetada
 import org.apache.padaf.xmpbox.parser.XMPDocumentBuilder;
 import org.apache.padaf.xmpbox.parser.XmpSerializer;
 import org.apache.padaf.xmpbox.type.JobType;
+import org.apache.padaf.xmpbox.type.StructuredType;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -99,13 +100,14 @@ public class BasicJobTicketSchemaTest {
 		XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
 		Assert.assertNotNull(jt);
 		Assert.assertEquals(1, jt.getJobs().size());
+		StructuredType stjob = JobType.class.getAnnotation(StructuredType.class);
 		
 		JobType job = jt.getJobs().get(0);
 		Assert.assertEquals("zeid2", job.getId());
 		Assert.assertEquals("zename2", job.getName());
 		Assert.assertEquals("zeurl2", job.getUrl());
-		Assert.assertEquals(JobType.ELEMENT_NS, job.getNamespace());
-		Assert.assertEquals(JobType.PREFERED_PREFIX, job.getPrefix());
+		Assert.assertEquals(stjob.namespace(), job.getNamespace());
+		Assert.assertEquals(stjob.preferedPrefix(), job.getPrefix());
 	
 	}
 
@@ -132,10 +134,12 @@ public class BasicJobTicketSchemaTest {
 		JobType job = jt.getJobs().get(0);
 //		SaveMetadataHelper.serialize(rxmp, System.out);
 
+		StructuredType stjob = JobType.class.getAnnotation(StructuredType.class);
+
 		Assert.assertEquals("zeid2", job.getId());
 		Assert.assertEquals("zename2", job.getName());
 		Assert.assertEquals("zeurl2", job.getUrl());
-		Assert.assertEquals(JobType.ELEMENT_NS, job.getNamespace());
+		Assert.assertEquals(stjob.namespace(), job.getNamespace());
 		Assert.assertEquals("aaa", job.getPrefix());
 	
 	}

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java?rev=1384755&r1=1384754&r2=1384755&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java Fri Sep 14 13:11:31 2012
@@ -50,7 +50,7 @@ public class XMPSchemaTest {
 	@Before
 	public void resetDocument() throws Exception {
 		parent = XMPMetadata.createXMPMetadata();
-		schem = new XMPSchema(parent, "nsSchem", "nsURI");
+		schem = new XMPSchema(parent, "nsURI", "nsSchem");
 
 	}
 
@@ -441,14 +441,12 @@ public class XMPSchemaTest {
 		String valAltSchem2 = "altvalSchem2";
 		String langAltSchem2 = "fr-fr";
 
-		XMPSchema schem1 = new XMPSchema(parent, "test",
-				"http://www.test.org/schem/");
+		XMPSchema schem1 = new XMPSchema(parent,"http://www.test.org/schem/", "test");
 		schem1.addQualifiedBagValue(bagName, valBagSchem1);
 		schem1.addUnqualifiedSequenceValue(seqName, valSeqSchem1);
 		schem1.setUnqualifiedLanguagePropertyValue(altName, langAltSchem1, valAltSchem1);
 
-		XMPSchema schem2 = new XMPSchema(parent, "test",
-				"http://www.test.org/schem/");
+		XMPSchema schem2 = new XMPSchema(parent, "http://www.test.org/schem/", "test");
 		schem2.addQualifiedBagValue(bagName, valBagSchem2);
 		schem2.addUnqualifiedSequenceValue(seqName, valSeqSchem2);
 		schem2.setUnqualifiedLanguagePropertyValue(altName, langAltSchem2, valAltSchem2);



Mime
View raw message