You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2012/09/02 20:31:45 UTC
svn commit: r1380021 - 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/
test/java/org/apach...
Author: gbailleul
Date: Sun Sep 2 18:31:44 2012
New Revision: 1380021
URL: http://svn.apache.org/viewvc?rev=1380021&view=rev
Log:
PDFBOX-1343: use helper to create property, removed unused class
Removed:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeUtil.java
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/StructuredPropertyParser.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/parser/XmpSerializer.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/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/XMPSchema.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/ArrayProperty.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Attribute.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BooleanType.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/ResourceRefType.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TypeMapping.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/AbstractXMPSchemaTest.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AttributeTest.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/StructuredPropertyParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/StructuredPropertyParser.java?rev=1380021&r1=1380020&r2=1380021&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/StructuredPropertyParser.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/StructuredPropertyParser.java Sun Sep 2 18:31:44 2012
@@ -198,8 +198,10 @@ public class StructuredPropertyParser {
String arrayType = metadata.getTypeMapping().getArrayType(ptype);
String typeInArray = ptype.substring(pos+1);
TypeDescription<AbstractStructuredType> tclass = metadata.getTypeMapping().getStructuredDescription(typeInArray);
- ArrayProperty cp = new ArrayProperty(metadata,null,
- eltName.getPrefix(), eltName.getLocalPart(),
+ ArrayProperty cp = property.getMetadata().getTypeMapping().createArrayProperty(
+ null,
+ eltName.getPrefix(),
+ eltName.getLocalPart(),
arrayType);
property.getContainer().addProperty(cp);
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -584,10 +584,10 @@ public class XMPDocumentBuilder {
boolean added = false;
String schemaNamespace = schema.getNamespace();
String prefix = schema.getPrefix();
- String type = metadata.getTypeMapping().getSpecifiedPropertyType(schemaNamespace, new QName(schemaNamespace, attr.getLocalName()));
+ String type = metadata.getTypeMapping().getSpecifiedPropertyType(schemaNamespace, new QName(schemaNamespace, attr.getName()));
if (type != null) {
- AbstractSimpleProperty prop = metadata.getTypeMapping().instanciateSimpleProperty(null, prefix, attr.getLocalName(), attr.getValue(), type);
+ AbstractSimpleProperty prop = metadata.getTypeMapping().instanciateSimpleProperty(null, prefix, attr.getName(), attr.getValue(), type);
schema.addProperty(prop);
added = true;
}
@@ -776,7 +776,7 @@ public class XMPDocumentBuilder {
throws XmpUnexpectedTypeException, XmpParsingException,
XMLStreamException, XmpUnknownPropertyTypeException,
XmpPropertyFormatException {
- ArrayProperty cp = new ArrayProperty(metadata,null,
+ ArrayProperty cp = metadata.getTypeMapping().createArrayProperty(null,
name.getPrefix(), name.getLocalPart(),
ctype);
container.addProperty(cp);
@@ -804,7 +804,7 @@ public class XMPDocumentBuilder {
throws XmpUnexpectedTypeException, XmpParsingException,
XMLStreamException, XmpUnknownPropertyTypeException,
XmpPropertyFormatException {
- ArrayProperty cp = new ArrayProperty(metadata,null,
+ ArrayProperty cp = metadata.getTypeMapping().createArrayProperty(null,
name.getPrefix(), name.getLocalPart(),
ctype);
container.addProperty(cp);
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -140,11 +140,11 @@ public class XmpSerializer {
List<Attribute> attributes = property.getAllAttributes();
for (Attribute attribute : attributes) {
if (target.getNamespaceURI().equals(attribute.getNamespace())) {
- target.setAttribute(attribute.getLocalName(), attribute.getValue());
+ target.setAttribute(attribute.getName(), attribute.getValue());
} else if (XmpConstants.RDF_NAMESPACE.equals(attribute.getNamespace())) {
- target.setAttribute("rdf"+":"+attribute.getLocalName(), attribute.getValue());
+ target.setAttribute("rdf"+":"+attribute.getName(), attribute.getValue());
} else {
- target.setAttribute(attribute.getQualifiedName(), attribute.getValue());
+ target.setAttribute(attribute.getName(), attribute.getValue());
}
}
for (Map.Entry<String, String> ns : property.getAllNamespacesWithPrefix().entrySet()) {
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -77,7 +77,7 @@ public class AdobePDFSchema extends XMPS
*/
public void setKeywords(String value) {
TextType keywords;
- keywords = new TextType(getMetadata(), null,getPrefix(), KEYWORDS, value);
+ keywords = createTextType ( KEYWORDS, value);
addProperty(keywords);
}
@@ -99,7 +99,7 @@ public class AdobePDFSchema extends XMPS
*/
public void setPDFVersion(String value) {
TextType version;
- version = new TextType(getMetadata(), null,getPrefix(), PDF_VERSION, value);
+ version = createTextType ( PDF_VERSION, value);
addProperty(version);
}
@@ -122,7 +122,7 @@ public class AdobePDFSchema extends XMPS
*/
public void setProducer(String value) {
TextType producer;
- producer = new TextType(getMetadata(),null, getPrefix(), PRODUCER, value);
+ producer = createTextType ( PRODUCER, value);
addProperty(producer);
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -132,7 +132,7 @@ public class DublinCoreSchema extends XM
* Value to set
*/
public void setCoverage(String text) {
- addProperty(new TextType(getMetadata(), null, getPrefix(), COVERAGE, text));
+ addProperty(createTextType ( COVERAGE, text));
}
/**
@@ -218,7 +218,7 @@ public class DublinCoreSchema extends XM
* Value to set
*/
public void setFormat(String mimeType) {
- addProperty(new TextType(getMetadata(), null, getPrefix(), FORMAT, mimeType));
+ addProperty(createTextType ( FORMAT, mimeType));
}
/**
@@ -228,7 +228,7 @@ public class DublinCoreSchema extends XM
* Value to set
*/
public void setIdentifier(String text) {
- addProperty(new TextType(getMetadata(), null, getPrefix(), IDENTIFIER, text));
+ addProperty(createTextType ( IDENTIFIER, text));
}
/**
@@ -326,7 +326,7 @@ public class DublinCoreSchema extends XM
* Value to set
*/
public void setSource(String text) {
- addProperty(new TextType(getMetadata(), null, getPrefix(), SOURCE, text));
+ addProperty(createTextType ( SOURCE, text));
}
/**
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -122,7 +122,7 @@ public class PDFAIdentificationSchema ex
* The amendment identifier value to set
*/
public void setAmd(String value) {
- TextType amd = new TextType(getMetadata(), null, PREFERED_PREFIX, AMD, value);
+ TextType amd = createTextType ( AMD, value);
addProperty(amd);
}
@@ -146,7 +146,7 @@ public class PDFAIdentificationSchema ex
*/
public void setConformance(String value) throws BadFieldValueException {
if (value.equals("A") || value.equals("B")) {
- TextType conf = new TextType(getMetadata(), null, PREFERED_PREFIX, CONFORMANCE, value);
+ TextType conf = createTextType ( CONFORMANCE, value);
addProperty(conf);
} else {
@@ -187,7 +187,7 @@ public class PDFAIdentificationSchema ex
return null;
} else {
for (Attribute attribute : getAllAttributes()) {
- if (attribute.getQualifiedName().equals(PART)) {
+ if (attribute.getName().equals(PART)) {
return Integer.valueOf(attribute.getValue());
}
}
@@ -250,7 +250,7 @@ public class PDFAIdentificationSchema ex
TextType tmp = getAmdProperty();
if (tmp==null) {
for (Attribute attribute : getAllAttributes()) {
- if (attribute.getQualifiedName().equals(AMD)) {
+ if (attribute.getName().equals(AMD)) {
return attribute.getValue();
}
}
@@ -284,7 +284,7 @@ public class PDFAIdentificationSchema ex
TextType tt = getConformanceProperty();
if (tt==null) {
for (Attribute attribute : getAllAttributes()) {
- if (attribute.getQualifiedName().equals(CONFORMANCE)) {
+ if (attribute.getName().equals(CONFORMANCE)) {
return attribute.getValue();
}
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -429,8 +429,7 @@ public class PhotoshopSchema extends XMP
public void addTextLayers(String layerName, String layerText) {
if (seqLayer == null) {
- seqLayer = new ArrayProperty(getMetadata(), null, getPrefix(), TEXT_LAYERS,
- ArrayProperty.ORDERED_ARRAY);
+ seqLayer = createArrayProperty(TEXT_LAYERS, ArrayProperty.ORDERED_ARRAY);
addProperty(seqLayer);
}
LayerType layer = new LayerType(getMetadata());
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -67,8 +67,7 @@ public class XMPBasicJobTicketSchema ext
public void addJob (JobType job) {
// create bag if not existing
if (bagJobs == null) {
- bagJobs = new ArrayProperty(getMetadata(), null, getPrefix(), JOB_REF,
- ArrayProperty.UNORDERED_ARRAY);
+ bagJobs = createArrayProperty(JOB_REF, ArrayProperty.UNORDERED_ARRAY);
addProperty(bagJobs);
}
// add job
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -124,8 +124,7 @@ public class XMPBasicSchema extends XMPS
public void addThumbnails(Integer height, Integer width, String format,
String img) {
if (altThumbs == null) {
- altThumbs = new ArrayProperty(getMetadata(), null, getPrefix(), THUMBNAILS,
- ArrayProperty.ALTERNATIVE_ARRAY);
+ altThumbs = createArrayProperty( THUMBNAILS, ArrayProperty.ALTERNATIVE_ARRAY);
addProperty(altThumbs);
}
ThumbnailType thumb = new ThumbnailType(getMetadata());
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -43,7 +43,6 @@ import org.apache.padaf.xmpbox.type.Date
import org.apache.padaf.xmpbox.type.IntegerType;
import org.apache.padaf.xmpbox.type.TextType;
import org.apache.padaf.xmpbox.type.TypeMapping;
-import org.apache.padaf.xmpbox.type.TypeUtil;
/**
* This class represents a metadata schema that can be stored in an XMP
@@ -124,7 +123,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())) {
+ if (RDFABOUT.equals(about.getName())) {
setAttribute(about);
return;
}
@@ -631,12 +630,11 @@ public class XMPSchema extends AbstractS
private void internalAddBagValue(String qualifiedBagName, String bagValue) {
ArrayProperty bag = (ArrayProperty) getAbstractProperty(qualifiedBagName);
- TextType li = new TextType(getMetadata(),null, "rdf", "li", bagValue);
+ TextType li = createTextType ( "li", bagValue);
if (bag != null) {
bag.getContainer().addProperty(li);
} else {
- ArrayProperty newBag = new ArrayProperty(getMetadata(),null,
- getPrefix(), qualifiedBagName,
+ ArrayProperty newBag = createArrayProperty(qualifiedBagName,
ArrayProperty.UNORDERED_ARRAY);
newBag.getContainer().addProperty(li);
addProperty(newBag);
@@ -656,33 +654,6 @@ public class XMPSchema extends AbstractS
}
/**
- * Generic String List Builder for arrays contents
- *
- * @param qualifiedArrayName
- * the full qualified name of property concerned
- * @return String list which represents content of array property
- */
- private List<String> getArrayListToString(String qualifiedArrayName) {
- ArrayProperty array = (ArrayProperty) getAbstractProperty(qualifiedArrayName);
- return TypeUtil.getArrayListToString(array);
- }
-
- /**
- * Get all the values of the bag property, using the current prefix. This
- * will return a list of java.lang.String objects, this is a read-only list.
- *
- * @param simpleName
- * the local name of property concerned
- *
- *
- * @return All values of the bag property in a list.
- */
- // TODO remove
- public List<String> getBagValueListAsSimple(String simpleName) {
- return getUnqualifiedBagValueList(simpleName);
- }
-
- /**
* Get all the values of the bag property. This will return a list of
* java.lang.String objects, this is a read-only list.
*
@@ -692,8 +663,12 @@ public class XMPSchema extends AbstractS
* @return All values of the bag property in a list.
*/
public List<String> getUnqualifiedBagValueList(String bagName) {
- String qualifiedBagName = bagName;
- return getArrayListToString(qualifiedBagName);
+ ArrayProperty array = (ArrayProperty) getAbstractProperty(bagName);
+ if (array!=null) {
+ return array.getElementsAsString();
+ } else {
+ return null;
+ }
}
/**
@@ -765,13 +740,11 @@ public class XMPSchema extends AbstractS
public void addUnqualifiedSequenceValue(String simpleSeqName, String seqValue) {
String qualifiedSeqName = simpleSeqName;
ArrayProperty seq = (ArrayProperty) getAbstractProperty(qualifiedSeqName);
- TextType li = new TextType(getMetadata(),null, "rdf", "li", seqValue);
+ TextType li = createTextType ( "li", seqValue);
if (seq != null) {
seq.getContainer().addProperty(li);
} else {
- ArrayProperty newSeq = new ArrayProperty(getMetadata(),null,
- getPrefix(), simpleSeqName,
- ArrayProperty.ORDERED_ARRAY);
+ ArrayProperty newSeq = createArrayProperty(simpleSeqName, ArrayProperty.ORDERED_ARRAY);
newSeq.getContainer().addProperty(li);
addProperty(newSeq);
}
@@ -792,9 +765,7 @@ public class XMPSchema extends AbstractS
if (bag != null) {
bag.getContainer().addProperty(seqValue);
} else {
- ArrayProperty newBag = new ArrayProperty(getMetadata(),null,
- getPrefix(),qualifiedSeqName,
- ArrayProperty.UNORDERED_ARRAY);
+ ArrayProperty newBag = createArrayProperty(qualifiedSeqName, ArrayProperty.UNORDERED_ARRAY);
newBag.getContainer().addProperty(seqValue);
addProperty(newBag);
}
@@ -815,9 +786,7 @@ public class XMPSchema extends AbstractS
if (seq != null) {
seq.getContainer().addProperty(seqValue);
} else {
- ArrayProperty newSeq = new ArrayProperty(getMetadata(),null,
- getPrefix(), seqName,
- ArrayProperty.ORDERED_ARRAY);
+ ArrayProperty newSeq = createArrayProperty(seqName, ArrayProperty.ORDERED_ARRAY);
newSeq.getContainer().addProperty(seqValue);
addProperty(newSeq);
}
@@ -833,8 +802,12 @@ public class XMPSchema extends AbstractS
* property does not exist.
*/
public List<String> getUnqualifiedSequenceValueList(String seqName) {
- String qualifiedSeqName = seqName;
- return getArrayListToString(qualifiedSeqName);
+ ArrayProperty array = (ArrayProperty) getAbstractProperty(seqName);
+ if (array!=null) {
+ return array.getElementsAsString();
+ } else {
+ return null;
+ }
}
/**
@@ -892,8 +865,7 @@ public class XMPSchema extends AbstractS
* The date to add to the sequence property.
*/
public void addUnqualifiedSequenceDateValue(String seqName, Calendar date) {
- addUnqualifiedSequenceValue(seqName, new DateType(getMetadata(),null, "rdf", "li",
- date));
+ addUnqualifiedSequenceValue(seqName, getMetadata().getTypeMapping().createDate(null, "rdf", "li", date));
}
/**
@@ -1014,8 +986,7 @@ public class XMPSchema extends AbstractS
} else {
prop.getContainer().removeProperty(tmp);
TextType langValue;
- langValue = new TextType(getMetadata(), null,"rdf", "li",
- value);
+ langValue = createTextType ( "li",value);
langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI,
"lang", language));
@@ -1027,18 +998,16 @@ public class XMPSchema extends AbstractS
}
// if no definition found, we add a new one
TextType langValue;
- langValue = new TextType(getMetadata(),null, "rdf", "li", value);
+ langValue = createTextType ( "li", value);
langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI, "lang",
language));
prop.getContainer().addProperty(langValue);
reorganizeAltOrder(prop.getContainer());
}
} else {
- prop = new ArrayProperty(getMetadata(), null,
- getPrefix(), name,
- ArrayProperty.ALTERNATIVE_ARRAY);
+ prop = createArrayProperty( name,ArrayProperty.ALTERNATIVE_ARRAY);
TextType langValue;
- langValue = new TextType(getMetadata(),null, "rdf", "li", value);
+ langValue = createTextType ( "li", value);
langValue
.setAttribute(new Attribute(XMLConstants.XML_NS_URI, "lang", language));
prop.getContainer().addProperty(langValue);
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -41,7 +41,11 @@ public abstract class AbstractField {
private XMPMetadata metadata;
- private String namespaceURI, prefix, propertyName;
+ private String namespaceURI;
+
+ private String prefix;
+
+ private String propertyName;
private Map<String, Attribute> attributes;
@@ -104,14 +108,14 @@ public abstract class AbstractField {
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 (attributes.containsKey(value.getName())) {
// if same name in element, attribute will be replaced
- attributes.remove(value.getQualifiedName());
+ attributes.remove(value.getName());
}
if (value.getNamespace() == null) {
- attributes.put(value.getQualifiedName(), value);
+ attributes.put(value.getName(), value);
} else {
- attributes.put(value.getQualifiedName(), value);
+ attributes.put(value.getName(), value);
}
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -60,4 +60,12 @@ public abstract class AbstractStructured
}
+ public TextType createTextType (String propertyName, String value) {
+ return getMetadata().getTypeMapping().createText(getNamespace(), getPrefix(), propertyName, value);
+ }
+
+ public ArrayProperty createArrayProperty (String propertyName, String type) {
+ return getMetadata().getTypeMapping().createArrayProperty(getNamespace(), getPrefix(), propertyName, type);
+ }
+
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -21,6 +21,11 @@
package org.apache.padaf.xmpbox.type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.padaf.xmpbox.XMPMetadata;
/**
@@ -64,5 +69,20 @@ public class ArrayProperty extends Abstr
return arrayType;
}
+
+ public List<String> getElementsAsString() {
+ List<String> retval = null;
+ retval = new ArrayList<String>();
+ Iterator<AbstractField> it = getContainer()
+ .getAllProperties().iterator();
+ AbstractSimpleProperty tmp;
+ while (it.hasNext()) {
+ tmp = (AbstractSimpleProperty) it.next();
+ retval.add(tmp.getStringValue());
+ }
+ retval = Collections.unmodifiableList(retval);
+ return retval;
+ }
+
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Attribute.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Attribute.java?rev=1380021&r1=1380020&r2=1380021&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Attribute.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/Attribute.java Sun Sep 2 18:31:44 2012
@@ -29,7 +29,11 @@ package org.apache.padaf.xmpbox.type;
*/
public class Attribute {
- private String nsURI, localName, value;
+ private String nsURI;
+
+ private String name;
+
+ private String value;
/**
* Constructor of a new Attribute
@@ -45,7 +49,7 @@ public class Attribute {
*/
public Attribute(String nsURI, String localName, String value) {
this.nsURI = nsURI;
- this.localName = localName;
+ this.name = localName;
this.value = value;
}
@@ -54,8 +58,8 @@ public class Attribute {
*
* @return local name of this attribute
*/
- public String getLocalName() {
- return localName;
+ public String getName() {
+ return name;
}
/**
@@ -64,8 +68,8 @@ public class Attribute {
* @param lname
* the local name to set
*/
- public void setLocalName(String lname) {
- localName = lname;
+ public void setName(String lname) {
+ name = lname;
}
/**
@@ -88,16 +92,6 @@ public class Attribute {
}
/**
- * Get the attribute qualified Name (prefix+localName)
- *
- * @return the full qualified name of this attribute
- */
- public String getQualifiedName() {
- // TODO remove that method
- return localName;
- }
-
- /**
* Get value of this attribute
*
* @return value of this attribute
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BooleanType.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BooleanType.java?rev=1380021&r1=1380020&r2=1380021&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BooleanType.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/BooleanType.java Sun Sep 2 18:31:44 2012
@@ -56,7 +56,6 @@ public class BooleanType extends Abstrac
super(metadata, namespaceURI, prefix, propertyName, value);
}
-
/**
* return the property value
*
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -67,7 +67,7 @@ public class LayerType extends AbstractS
* the value of LayerName property to set
*/
public void setLayerName(String image) {
- this.addProperty(new TextType(getMetadata(), null,getPrefix(), LAYER_NAME, image));
+ this.addProperty(createTextType ( LAYER_NAME, image));
}
/**
@@ -95,7 +95,7 @@ public class LayerType extends AbstractS
* the value of LayerText property to set
*/
public void setLayerText(String image) {
- this.addProperty(new TextType(getMetadata(), null,getPrefix(), LAYER_TEXT, image));
+ this.addProperty(createTextType ( LAYER_TEXT, image));
}
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -294,7 +294,7 @@ public class ResourceRefType extends Abs
public void addAlternatePath(String value) {
ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class);
if (seq==null) {
- seq = new ArrayProperty(getMetadata(), null,
+ seq = getMetadata().getTypeMapping().createArrayProperty(null,
PREFERRED_PREFIX, ALTERNATE_PATHS,
ArrayProperty.ORDERED_ARRAY);
addProperty(seq);
@@ -321,7 +321,7 @@ public class ResourceRefType extends Abs
public List<String> getAlternatePaths() {
ArrayProperty seq = (ArrayProperty) getFirstEquivalentProperty(ALTERNATE_PATHS, ArrayProperty.class);
if (seq!=null) {
- return TypeUtil.getArrayListToString(seq);
+ return seq.getElementsAsString();
} else {
return null;
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -23,6 +23,7 @@ package org.apache.padaf.xmpbox.type;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -452,5 +453,88 @@ public final class TypeMapping {
}
}
+ public BooleanType createBoolean (String namespaceURI, String prefix,
+ String propertyName, boolean value) {
+ return new BooleanType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public DateType createDate (String namespaceURI, String prefix,
+ String propertyName, Calendar value) {
+ return new DateType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public IntegerType createInteger (String namespaceURI, String prefix,
+ String propertyName, int value) {
+ return new IntegerType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public RealType createReal (String namespaceURI, String prefix,
+ String propertyName, float value) {
+ return new RealType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public TextType createText (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new TextType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public ProperNameType createProperName (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new ProperNameType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public URIType createURI (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new URIType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public URLType createURL (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new URLType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public RenditionClassType createRenditionClass (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new RenditionClassType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public PartType createPart (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new PartType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public MIMEType createMIMEType (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new MIMEType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public LocaleType createLocale (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new LocaleType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public GUIDType createGUID (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new GUIDType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public ChoiceType createChoice (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new ChoiceType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public AgentNameType createAgentName (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new AgentNameType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public XPathType createXPath (String namespaceURI, String prefix,
+ String propertyName, String value) {
+ return new XPathType(metadata, namespaceURI, prefix,propertyName, value);
+ }
+
+ public ArrayProperty createArrayProperty (String namespace, String prefix, String propertyName, String type) {
+ return new ArrayProperty(metadata, namespace, prefix, propertyName, type);
+ }
}
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -58,7 +58,7 @@ public class XMPMetaDataTest {
tmp.addUnqualifiedSequenceValue("SeqContainer", "Value3");
tmp
- .addProperty(new TextType(metadata, null,"test", "simpleProperty",
+ .addProperty(metadata.getTypeMapping().createText(null,"test", "simpleProperty",
"YEP"));
tmp2 = new XMPSchema(metadata, "space", "http://www.space.org/schem/");
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java?rev=1380021&r1=1380020&r2=1380021&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java Sun Sep 2 18:31:44 2012
@@ -306,7 +306,7 @@ public abstract class AbstractXMPSchemaT
String setName = setMethod(property);
String getName = getMethod(property);
- TextType tt = new TextType(metadata, null,schema.getPrefix(), property,
+ TextType tt = metadata.getTypeMapping().createText(null,schema.getPrefix(), property,
(String)value);
Method setMethod = schemaClass.getMethod(setName, TextType.class);
Method getMethod = schemaClass.getMethod(getName);
@@ -321,7 +321,7 @@ public abstract class AbstractXMPSchemaT
String setName = setMethod(property);
String getName = getMethod(property);
- URIType tt = new URIType(metadata, null,schema.getPrefix(), property,
+ URIType tt = metadata.getTypeMapping().createURI(null,schema.getPrefix(), property,
(String)value);
Method setMethod = schemaClass.getMethod(setName, URIType.class);
Method getMethod = schemaClass.getMethod(getName);
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=1380021&r1=1380020&r2=1380021&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 Sun Sep 2 18:31:44 2012
@@ -38,6 +38,7 @@ import org.apache.padaf.xmpbox.type.Bool
import org.apache.padaf.xmpbox.type.DateType;
import org.apache.padaf.xmpbox.type.IntegerType;
import org.apache.padaf.xmpbox.type.TextType;
+import org.apache.padaf.xmpbox.type.TypeMapping;
import org.junit.Before;
import org.junit.Test;
@@ -63,7 +64,8 @@ public class XMPSchemaTest {
String bagName = "BAGTEST";
String value1 = "valueOne";
String value2 = "valueTwo";
- schem.addBagValue(bagName, new TextType(parent, null,"rdf", "li", value1));
+ schem.addBagValue(bagName, schem.getMetadata()
+ .getTypeMapping().createText(null, "rdf", "li", value1));
schem.addQualifiedBagValue(bagName, value2);
List<String> values = schem.getUnqualifiedBagValueList(bagName);
@@ -88,10 +90,12 @@ public class XMPSchemaTest {
@Test
public void testArrayList() throws Exception {
- ArrayProperty newSeq = new ArrayProperty(parent, null, "nsSchem",
+ XMPMetadata meta = XMPMetadata.createXMPMetadata();
+ ArrayProperty newSeq = meta.getTypeMapping().createArrayProperty(null, "nsSchem",
"seqType", ArrayProperty.ORDERED_ARRAY);
- TextType li1 = new TextType(parent,null, "rdf", "li", "valeur1");
- TextType li2 = new TextType(parent,null, "rdf", "li", "valeur2");
+ TypeMapping tm = meta.getTypeMapping();
+ TextType li1 = tm.createText(null, "rdf", "li", "valeur1");
+ TextType li2 =tm.createText(null, "rdf", "li", "valeur2");
newSeq.getContainer().addProperty(li1);
newSeq.getContainer().addProperty(li2);
schem.addProperty(newSeq);
@@ -110,7 +114,7 @@ public class XMPSchemaTest {
@Test
public void testSeqManagement() throws Exception {
Calendar date = Calendar.getInstance();
- BooleanType bool = new BooleanType(parent, null, "rdf", "li", "True");
+ BooleanType bool = parent.getTypeMapping().createBoolean( null, "rdf", "li", true);
String textVal = "seqValue";
String seqName = "SEQNAME";
@@ -180,7 +184,7 @@ public class XMPSchemaTest {
String val = "value";
String val2 = "value2";
schem.setTextPropertyValueAsSimple(prop, val);
- TextType text = new TextType(parent,null, schem.getPrefix(), prop, "value2");
+ TextType text = schem.getMetadata().getTypeMapping().createText(null, schem.getPrefix(), prop, "value2");
schem.setTextProperty(text);
Assert.assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
Assert.assertEquals(text, schem.getUnqualifiedTextProperty(prop));
@@ -278,7 +282,7 @@ public class XMPSchemaTest {
schem.setTextPropertyValue(textProp, textPropVal);
Assert.assertEquals(textPropVal, schem.getUnqualifiedTextPropertyValue(textProp));
- TextType text = new TextType(parent,null, "nsSchem", "textType", "GRINGO");
+ TextType text = parent.getTypeMapping().createText(null, "nsSchem", "textType", "GRINGO");
schem.setTextProperty(text);
Assert.assertEquals(text, schem.getUnqualifiedTextProperty("textType"));
@@ -287,7 +291,7 @@ public class XMPSchemaTest {
schem.setDatePropertyValue(date, dateVal);
Assert.assertEquals(dateVal, schem.getDatePropertyValue(date));
- DateType dateType = new DateType(parent, null, "nsSchem", "dateType",
+ DateType dateType = parent.getTypeMapping().createDate( null, "nsSchem", "dateType",
Calendar.getInstance());
schem.setDateProperty(dateType);
Assert
@@ -299,7 +303,7 @@ public class XMPSchemaTest {
schem.setBooleanPropertyValue(bool, boolVal);
Assert.assertEquals(boolVal, schem.getBooleanPropertyValue(bool));
- BooleanType boolType = new BooleanType(parent, null,"nsSchem", "boolType",
+ BooleanType boolType = parent.getTypeMapping().createBoolean( null,"nsSchem", "boolType",
false);
schem.setBooleanProperty(boolType);
Assert.assertEquals(boolType, schem
@@ -310,7 +314,7 @@ public class XMPSchemaTest {
schem.setIntegerPropertyValue(intProp, intPropVal);
Assert.assertEquals(intPropVal, schem.getIntegerPropertyValue(intProp));
- IntegerType intType = new IntegerType(parent, null, "nsSchem", "intType", 5);
+ IntegerType intType = parent.getTypeMapping().createInteger( null, "nsSchem", "intType", 5);
schem.setIntegerProperty(intType);
Assert.assertEquals(intType, schem
.getIntegerProperty("intType"));
@@ -472,7 +476,7 @@ public class XMPSchemaTest {
public void testListAndContainerAccessor() throws Exception {
String boolname = "bool";
boolean boolVal = true;
- BooleanType bool = new BooleanType(parent, null, schem.getPrefix(),
+ BooleanType bool = parent.getTypeMapping().createBoolean( null, schem.getPrefix(),
boolname, boolVal);
Attribute att = new Attribute(XmpConstants.RDF_NAMESPACE, "test", "vgh");
schem.setAttribute(att);
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AttributeTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AttributeTest.java?rev=1380021&r1=1380020&r2=1380021&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AttributeTest.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AttributeTest.java Sun Sep 2 18:31:44 2012
@@ -37,8 +37,7 @@ public class AttributeTest {
Attribute att = new Attribute(nsUri, localName, value);
Assert.assertEquals(nsUri, att.getNamespace());
- Assert.assertEquals(localName, att.getLocalName());
- Assert.assertEquals(localName, att.getQualifiedName());
+ Assert.assertEquals(localName, att.getName());
Assert.assertEquals(value, att.getValue());
String nsUri2 = "nsUri2";
@@ -47,12 +46,11 @@ public class AttributeTest {
String value2 = "value2";
att.setNsURI(nsUri2);
- att.setLocalName(localName2);
+ att.setName(localName2);
att.setValue(value2);
Assert.assertEquals(nsUri2, att.getNamespace());
- Assert.assertEquals(localName2, att.getLocalName());
- Assert.assertEquals(localName2, att.getQualifiedName());
+ Assert.assertEquals(localName2, att.getName());
Assert.assertEquals(value2, att.getValue());
}
@@ -66,12 +64,10 @@ public class AttributeTest {
Attribute att = new Attribute(nsUri, localName, value);
Assert.assertEquals(nsUri, att.getNamespace());
- Assert.assertEquals(localName, att.getLocalName());
- Assert.assertEquals(localName, att.getQualifiedName());
+ Assert.assertEquals(localName, att.getName());
att = new Attribute(nsUri, localName, value);
Assert.assertEquals(nsUri, att.getNamespace());
- Assert.assertEquals(localName, att.getLocalName());
- Assert.assertEquals(localName, att.getQualifiedName());
+ Assert.assertEquals(localName, att.getName());
}
}
Modified: pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java?rev=1380021&r1=1380020&r2=1380021&view=diff
==============================================================================
--- pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java (original)
+++ pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java Sun Sep 2 18:31:44 2012
@@ -106,12 +106,12 @@ public class TestSimpleMetadataPropertie
int integerv = 1;
float realv = Float.parseFloat("1.69");
String textv = "TEXTCONTENT";
- BooleanType bool = new BooleanType(parent, null, "test", "booleen", boolv);
- DateType date = new DateType(parent, null,"test", "date", datev);
- IntegerType integer = new IntegerType(parent, null, "test", "integer",
+ BooleanType bool = parent.getTypeMapping().createBoolean(null, "test", "booleen", boolv);
+ DateType date = parent.getTypeMapping().createDate( null,"test", "date", datev);
+ IntegerType integer =parent.getTypeMapping().createInteger( null, "test", "integer",
integerv);
- RealType real = new RealType(parent, null, "test", "real", realv);
- TextType text = new TextType(parent, null,"test", "text", textv);
+ RealType real = parent.getTypeMapping().createReal( null, "test", "real", realv);
+ TextType text = parent.getTypeMapping().createText( null,"test", "text", textv);
// Assert.assertEquals(bool.getNamespace(), bool.getElement()
// .getNamespaceURI());
@@ -188,12 +188,12 @@ public class TestSimpleMetadataPropertie
@Test
public void testObjectCreationWithNamespace() throws Exception {
String ns = "http://www.test.org/pdfa/";
- BooleanType bool = new BooleanType(parent, ns, "test", "booleen", true);
- DateType date = new DateType(parent, ns, "test", "date", Calendar
+ BooleanType bool = parent.getTypeMapping().createBoolean( ns, "test", "booleen", true);
+ DateType date = parent.getTypeMapping().createDate( ns, "test", "date", Calendar
.getInstance());
- IntegerType integer = new IntegerType(parent, ns, "test", "integer", 1);
- RealType real = new RealType(parent, ns, "test", "real", (float) 1.6);
- TextType text = new TextType(parent, ns, "test", "text", "TEST");
+ IntegerType integer = parent.getTypeMapping().createInteger( ns, "test", "integer", 1);
+ RealType real = parent.getTypeMapping().createReal( ns, "test", "real", (float) 1.6);
+ TextType text = parent.getTypeMapping().createText( ns, "test", "text", "TEST");
Assert.assertEquals(ns, bool.getNamespace());
Assert.assertEquals(ns, date.getNamespace());
@@ -240,19 +240,19 @@ public class TestSimpleMetadataPropertie
// System.out.println(value.getQualifiedName());
Assert.assertEquals(value, integer.getAttribute(value
- .getQualifiedName()));
- Assert.assertTrue(integer.containsAttribute(value.getQualifiedName()));
+ .getName()));
+ Assert.assertTrue(integer.containsAttribute(value.getName()));
// Replacement check
integer.setAttribute(value2);
Assert.assertEquals(value2, integer.getAttribute(value2
- .getQualifiedName()));
+ .getName()));
- integer.removeAttribute(value2.getQualifiedName());
+ integer.removeAttribute(value2.getName());
Assert
.assertFalse(integer.containsAttribute(value2
- .getQualifiedName()));
+ .getName()));
// Attribute with namespace Creation checking
Attribute valueNS = new Attribute("http://www.tefst2.org/test/",