pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbaill...@apache.org
Subject svn commit: r1379147 - in /pdfbox/branches/xmpbox-refactoring/xmpbox/src: main/java/org/apache/padaf/xmpbox/parser/ main/java/org/apache/padaf/xmpbox/schema/ main/java/org/apache/padaf/xmpbox/type/ test/java/org/apache/padaf/xmpbox/schema/
Date Thu, 30 Aug 2012 21:03:18 GMT
Author: gbailleul
Date: Thu Aug 30 21:03:18 2012
New Revision: 1379147

URL: http://svn.apache.org/viewvc?rev=1379147&view=rev
Log:
PDFBOX-1343: manage attributes and namespaces definition in different way, reduce complexity,
remove duplicate code on attributes

Modified:
    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/parser/XmpSerializer.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/XMPSchema.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/AbstractStructuredType.java
    pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.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/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/VersionType.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/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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -29,10 +29,10 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map.Entry;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 
-import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -668,8 +668,7 @@ public class XMPDocumentBuilder {
 		}
 
 		for (int i = 1; i < cptNS; i++) {
-			schema.setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
-					reader.get().getNamespacePrefix(i), reader.get().getNamespaceURI(i)));
+			schema.addNamespace(reader.get().getNamespaceURI(i), reader.get().getNamespacePrefix(i));
 		}
 		treatDescriptionAttributes(metadata, schema);
 		while (reader.get().nextTag() == XMLStreamReader.START_ELEMENT) {
@@ -733,22 +732,12 @@ public class XMPDocumentBuilder {
 	private String getPropertyDeclarationInNamespaces(XMPSchema schema,
 			QName prop) throws XmpParsingException {
 		NSMapping nsMap = schema.getMetadata().getNsMapping();
-		Iterator<Attribute> it = schema.getAllAttributes().iterator();
-		Attribute tmp;
-		ArrayList<Attribute> list = new ArrayList<Attribute>();
-		while (it.hasNext()) {
-			tmp = it.next();
-			if (tmp.getNamespace() != null) {
-				if (tmp.getNamespace().equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
-					list.add(tmp);
-				}
-			}
-		}
-		it = list.iterator();
+		Iterator<Entry<String, String>> it = schema.getAllNamespacesWithPrefix().entrySet().iterator();
 		String type;
 		StringBuilder unknownNS = new StringBuilder();
 		while (it.hasNext()) {
-			String namespace = it.next().getValue();
+			Entry<String,String> entry = it.next();
+			String namespace = entry.getKey();
 			if (!nsMap.isContainedNamespace(namespace)) {
 				unknownNS.append(" '").append(namespace).append("' ");
 				continue;

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpSerializer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpSerializer.java?rev=1379147&r1=1379146&r2=1379147&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpSerializer.java
(original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XmpSerializer.java
Thu Aug 30 21:03:18 2012
@@ -22,6 +22,7 @@ package org.apache.padaf.xmpbox.parser;
 
 import java.io.OutputStream;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
@@ -38,6 +39,7 @@ import javax.xml.transform.stream.Stream
 import org.apache.padaf.xmpbox.XMPMetadata;
 import org.apache.padaf.xmpbox.XmpConstants;
 import org.apache.padaf.xmpbox.schema.XMPSchema;
+import org.apache.padaf.xmpbox.type.AbstractComplexProperty;
 import org.apache.padaf.xmpbox.type.AbstractField;
 import org.apache.padaf.xmpbox.type.AbstractSimpleProperty;
 import org.apache.padaf.xmpbox.type.AbstractStructuredType;
@@ -71,7 +73,7 @@ public class XmpSerializer {
 			// fill document
 			Element rdf = createRdfElement(doc,metadata, withXpacket);
 			for (XMPSchema schema : metadata.getAllSchemas()) {
-				rdf.appendChild(createSchemaElement(doc, schema));
+				rdf.appendChild(serializeSchema(doc, schema));
 			}
 			// save
 			save(doc, os, "UTF-8");
@@ -84,21 +86,20 @@ public class XmpSerializer {
 
 	}
 
-	protected Element createSchemaElement (Document doc, XMPSchema schema) {
+	protected Element serializeSchema (Document doc, XMPSchema schema) {
 		// prepare schema
 		Element selem = doc.createElementNS(XmpConstants.RDF_NAMESPACE,"rdf:Description");
 		selem.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:"+schema.getPrefix(),
schema.getNamespace());
 		// the other attributes
-		fillElementWithAttributes(selem, schema.getAllAttributes());
+		fillElementWithAttributes(selem, schema);
 		// the content
 		List<AbstractField> fields = schema.getAllProperties();
-		xxxxxxx(doc, selem, fields);
+		serializeFields(doc, selem, fields);
 		// return created schema
 		return selem;
 	}
 
-	// TODO GBL rename method
-	public void xxxxxxx (Document doc, Element parent, List<AbstractField> fields) {
+	public void serializeFields (Document doc, Element parent, List<AbstractField> fields)
{
 		for (AbstractField field : fields) {
 			if (field instanceof AbstractSimpleProperty) {
 				AbstractSimpleProperty simple = (AbstractSimpleProperty)field;
@@ -110,13 +111,13 @@ public class XmpSerializer {
 				Element asimple = doc.createElement(array.getPrefix()+":"+array.getPropertyName());
 				parent.appendChild(asimple);
 				// attributes
-				fillElementWithAttributes(asimple, array.getAllAttributes());
+				fillElementWithAttributes(asimple, array);
 				// the array definition
 				Element econtainer = doc.createElement("rdf"+":"+array.getArrayType()); 
 				asimple.appendChild(econtainer);
 				// for each element of the array
 				List<AbstractField> innerFields = array.getAllProperties();
-				xxxxxxx(doc, econtainer, innerFields);
+				serializeFields(doc, econtainer, innerFields);
 			} else if (field instanceof AbstractStructuredType) {
 				AbstractStructuredType structured = (AbstractStructuredType)field;
 				// element li
@@ -127,7 +128,7 @@ public class XmpSerializer {
 				estructured.appendChild(econtainer);
 				// all properties
 				List<AbstractField> innerFields = structured.getAllProperties();
-				xxxxxxx(doc, econtainer, innerFields);
+				serializeFields(doc, econtainer, innerFields);
 			} else {
 				System.err.println(">> TODO >> "+field.getClass());
 			}
@@ -135,20 +136,20 @@ public class XmpSerializer {
 		
 	}
 	
-	protected void fillElementWithAttributes (Element target, List<Attribute> attributes)
{
+	private void fillElementWithAttributes (Element target, AbstractComplexProperty property
) {
+		List<Attribute> attributes = property.getAllAttributes();
 		for (Attribute attribute : attributes) {
 			if (target.getNamespaceURI().equals(attribute.getNamespace())) {
 				target.setAttribute(attribute.getLocalName(), attribute.getValue());
-			} else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attribute.getNamespace())) {
-				target.setAttribute(XMLConstants.XMLNS_ATTRIBUTE+":"+attribute.getLocalName(), attribute.getValue());
 			} else if (XmpConstants.RDF_NAMESPACE.equals(attribute.getNamespace())) {
 				target.setAttribute("rdf"+":"+attribute.getLocalName(), attribute.getValue());
-//			} else if (attribute.getLocalName().equals("about")) {
-//				target.setAttribute("rdf:about", attribute.getValue());
 			} else {
 				target.setAttribute(attribute.getQualifiedName(), attribute.getValue());
 			}
 		}
+		for (Map.Entry<String, String> ns : property.getAllNamespacesWithPrefix().entrySet())
{
+			target.setAttribute(XMLConstants.XMLNS_ATTRIBUTE+":"+ns.getValue(), ns.getKey());
+		}
 	}
 	
 	protected Element createRdfElement (Document doc, XMPMetadata metadata, boolean withXpacket)
{

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -24,12 +24,9 @@ package org.apache.padaf.xmpbox.schema;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.xml.XMLConstants;
-
 import org.apache.padaf.xmpbox.XMPMetadata;
 import org.apache.padaf.xmpbox.type.AbstractField;
 import org.apache.padaf.xmpbox.type.ArrayProperty;
-import org.apache.padaf.xmpbox.type.Attribute;
 import org.apache.padaf.xmpbox.type.BadFieldValueException;
 import org.apache.padaf.xmpbox.type.JobType;
 import org.apache.padaf.xmpbox.type.PropertyType;
@@ -52,9 +49,7 @@ public class XMPBasicJobTicketSchema ext
 
     public XMPBasicJobTicketSchema(XMPMetadata metadata, String ownPrefix) {
         super(metadata, ownPrefix, JOB_TICKET_URI);
-        getContainer().setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, 
-                JobType.PREFERED_PREFIX, JobType.ELEMENT_NS));
-
+        addNamespace(JobType.ELEMENT_NS, JobType.PREFERED_PREFIX);
     }
 
     public void addJob(String id , String name, String url) {

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -69,8 +69,7 @@ public class XMPSchema extends AbstractS
 	 */
 	public XMPSchema(XMPMetadata metadata, String namespaceName, String namespaceURI) {
 		super(metadata, namespaceURI, namespaceName);
-		getContainer().setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, namespaceName,
namespaceURI));
-
+		addNamespace(namespaceURI, namespaceName);
 	}
 
 	/**
@@ -99,7 +98,7 @@ public class XMPSchema extends AbstractS
 	 * @return The RDF 'about' attribute.
 	 */
 	public Attribute getAboutAttribute() {
-		return getContainer().getAttribute(RDFABOUT);
+		return getAttribute(RDFABOUT);
 	}
 
 	/**
@@ -108,7 +107,7 @@ public class XMPSchema extends AbstractS
 	 * @return The RDF 'about' value.
 	 */
 	public String getAboutValue() {
-		Attribute prop = getContainer().getAttribute(RDFABOUT);
+		Attribute prop = getAttribute(RDFABOUT);
 		if (prop != null) {
 			return prop.getValue();
 		}
@@ -126,7 +125,7 @@ public class XMPSchema extends AbstractS
 	public void setAbout(Attribute about) throws BadFieldValueException {
 		if (XmpConstants.RDF_NAMESPACE.equals(about.getNamespace())) {
 			if (RDFABOUT.equals(about.getLocalName())) {
-				getContainer().setAttribute(about);
+				setAttribute(about);
 				return;
 			}
 		}
@@ -143,9 +142,9 @@ public class XMPSchema extends AbstractS
 	 */
 	public void setAboutAsSimple(String about) {
 		if (about == null) {
-			getContainer().removeAttribute(RDFABOUT);
+			removeAttribute(RDFABOUT);
 		} else {
-			getContainer().setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "about", about));
+			setAttribute(new Attribute(XmpConstants.RDF_NAMESPACE, "about", about));
 
 		}
 	}
@@ -1142,13 +1141,13 @@ public class XMPSchema extends AbstractS
 			throw new IOException("Can only merge schemas of the same type.");
 		}
 
-		Iterator<Attribute> itAtt = xmpSchema.getContainer().getAllAttributes()
+		Iterator<Attribute> itAtt = xmpSchema.getAllAttributes()
 				.iterator();
 		Attribute att;
 		while (itAtt.hasNext()) {
 			att = itAtt.next();
 			if (att.getNamespace().equals(getNamespace())) {
-				getContainer().setAttribute(att);
+				setAttribute(att);
 			}
 		}
 
@@ -1255,25 +1254,6 @@ public class XMPSchema extends AbstractS
 		return null;
 	}
 
-	/**
-	 * Get All attributes defined for this schema
-	 * 
-	 * @return Attributes list defined for this schema
-	 */
-	public List<Attribute> getAllAttributes() {
-		return getContainer().getAllAttributes();
-	}
-
-	/**
-	 * Set a new attribute for this schema
-	 * 
-	 * @param attr
-	 *            The new Attribute to set
-	 */
-	public void setAttribute(Attribute attr) {
-		getContainer().setAttribute(attr);
-	}
-
 	protected AbstractSimpleProperty instanciateSimple (String param, Object value) {
 		TypeMapping tm = getMetadata().getTypeMapping();
 		return tm.instanciateSimpleField(

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -21,7 +21,9 @@
 
 package org.apache.padaf.xmpbox.type;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.padaf.xmpbox.XMPMetadata;
 
@@ -29,12 +31,28 @@ public abstract class AbstractComplexPro
 
 	private ComplexPropertyContainer container;
 	
+	private Map<String,String> namespaceToPrefix;
+
+	
 	public AbstractComplexProperty(XMPMetadata metadata, String namespaceURI,
 			String prefix, String propertyName) {
 		super(metadata, namespaceURI, prefix, 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
 	 * 

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -26,6 +26,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.XMLConstants;
+
 import org.apache.padaf.xmpbox.XMPMetadata;
 
 /**
@@ -97,7 +99,11 @@ public abstract class AbstractField {
 	 * @param value
 	 *            The Attribute property to add
 	 */
-	public void setAttribute(Attribute value) {
+	public final void setAttribute(Attribute value) {
+		// TODO remove when test are OK
+		if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(value.getNamespace())) {
+			throw new Error ("Should not call setAttribute for this "+value.getValue());
+		}
 		if (attributes.containsKey(value.getQualifiedName())) {
 			// if same name in element, attribute will be replaced
 			attributes.remove(value.getQualifiedName());
@@ -116,7 +122,7 @@ public abstract class AbstractField {
 	 *            the full qualified name of the attribute concerned
 	 * @return true if attribute is present
 	 */
-	public boolean containsAttribute(String qualifiedName) {
+	public final boolean containsAttribute(String qualifiedName) {
 		return attributes.containsKey(qualifiedName);
 	}
 
@@ -127,7 +133,7 @@ public abstract class AbstractField {
 	 *            the full qualified name of the attribute wanted
 	 * @return The attribute property
 	 */
-	public Attribute getAttribute(String qualifiedName) {
+	public final Attribute getAttribute(String qualifiedName) {
 		return attributes.get(qualifiedName);
 	}
 
@@ -136,7 +142,7 @@ public abstract class AbstractField {
 	 * 
 	 * @return Attributes list
 	 */
-	public List<Attribute> getAllAttributes() {
+	public final List<Attribute> getAllAttributes() {
 		return new ArrayList<Attribute>(attributes.values());
 	}
 
@@ -146,7 +152,7 @@ public abstract class AbstractField {
 	 * @param qualifiedName
 	 *            the full qualified name of the attribute wanted
 	 */
-	public void removeAttribute(String qualifiedName) {
+	public final void removeAttribute(String qualifiedName) {
 		if (containsAttribute(qualifiedName)) {
 			attributes.remove(qualifiedName);
 		}

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -28,7 +28,6 @@ import org.apache.padaf.xmpbox.XMPMetada
 public abstract class AbstractStructuredType extends AbstractComplexProperty {
 
 	
-	
 	protected static final  String STRUCTURE_ARRAY_NAME = "li"; 
 
 	public AbstractStructuredType(XMPMetadata metadata, String namespaceURI,
@@ -36,17 +35,12 @@ public abstract class AbstractStructured
 		super(metadata, namespaceURI, fieldPrefix, STRUCTURE_ARRAY_NAME);
 	}
 
-	
 	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) {
@@ -66,5 +60,4 @@ public abstract class AbstractStructured
 	}
 
 
-
 }

Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.java?rev=1379147&r1=1379146&r2=1379147&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.java
(original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.java
Thu Aug 30 21:03:18 2012
@@ -22,10 +22,8 @@
 package org.apache.padaf.xmpbox.type;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Object representation for arrays content This Class could be used to define
@@ -39,7 +37,7 @@ public class ComplexPropertyContainer /*
 
 	private List<AbstractField> properties;
 
-	private Map<String, Attribute> attributes;
+//	private Map<String, Attribute> attributes;
 
 
 
@@ -57,70 +55,70 @@ public class ComplexPropertyContainer /*
 	 */
 	public ComplexPropertyContainer() {
 		properties = new ArrayList<AbstractField>();
-		attributes = new HashMap<String, Attribute>();
+//		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);
-	}
+//	/**
+//	 * 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

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -21,8 +21,6 @@
 
 package org.apache.padaf.xmpbox.type;
 
-import javax.xml.XMLConstants;
-
 import org.apache.padaf.xmpbox.XMPMetadata;
 
 public class JobType extends AbstractStructuredType {
@@ -47,7 +45,7 @@ public class JobType extends AbstractStr
 
     public JobType(XMPMetadata metadata, String fieldPrefix) {
         super(metadata, ELEMENT_NS, fieldPrefix);
-		setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, fieldPrefix, ELEMENT_NS));
+        addNamespace(ELEMENT_NS, fieldPrefix);
     }
 
     public void setId(String id) {

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -23,8 +23,6 @@ package org.apache.padaf.xmpbox.type;
 
 import java.util.Calendar;
 
-import javax.xml.XMLConstants;
-
 import org.apache.padaf.xmpbox.XMPMetadata;
 
 public class ResourceEventType extends AbstractStructuredType {
@@ -65,7 +63,7 @@ public class ResourceEventType extends A
 	 */
 	public ResourceEventType(XMPMetadata metadata) {
 		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
-		setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, PREFERRED_PREFIX, ELEMENT_NS));
+		addNamespace(ELEMENT_NS, PREFERRED_PREFIX);
 	}
 	
 	

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -24,8 +24,6 @@ package org.apache.padaf.xmpbox.type;
 import java.util.Calendar;
 import java.util.List;
 
-import javax.xml.XMLConstants;
-
 import org.apache.padaf.xmpbox.XMPMetadata;
 
 public class ResourceRefType extends AbstractStructuredType {
@@ -94,7 +92,8 @@ public class ResourceRefType extends Abs
 	 */
 	public ResourceRefType(XMPMetadata metadata) {
 		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
-		setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, PREFERRED_PREFIX, ELEMENT_NS));
+		addNamespace(ELEMENT_NS, PREFERRED_PREFIX);
+		
 	}
 	
 	public String getDocumentID () {

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -23,8 +23,6 @@ package org.apache.padaf.xmpbox.type;
 
 import java.util.Calendar;
 
-import javax.xml.XMLConstants;
-
 import org.apache.padaf.xmpbox.XMPMetadata;
 
 public class VersionType extends AbstractStructuredType {
@@ -62,7 +60,7 @@ public class VersionType extends Abstrac
 	 */
 	public VersionType(XMPMetadata metadata) {
 		super(metadata, ELEMENT_NS, PREFERRED_PREFIX);
-		setAttribute(new Attribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, PREFERRED_PREFIX, ELEMENT_NS));
+		addNamespace(ELEMENT_NS,PREFERRED_PREFIX);
 	}
 	
 	

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=1379147&r1=1379146&r2=1379147&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
Thu Aug 30 21:03:18 2012
@@ -263,8 +263,7 @@ public class XMPSchemaTest {
 		Assert.assertEquals("nsURI", schem.getNamespace());
 
 		// In real cases, rdf ns will be declared before !
-		schem.setAttribute(new Attribute("http://www.w3.org/2000/xmlns/",
-				"rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
+		schem.addNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#","rdf");
 
 		String aboutVal = "aboutTest";
 		schem.setAboutAsSimple(aboutVal);



Mime
View raw message