Author: gbailleul
Date: Sat Aug 18 23:04:44 2012
New Revision: 1374670
URL: http://svn.apache.org/viewvc?rev=1374670&view=rev
Log:
PDFBOX-1343: moved objectValue from abstract simple type to each extending
classes
Modified:
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/BooleanType.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/IntegerType.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/RealType.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TextType.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.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/AbstractStructuredTypeTester.java
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.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/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=1374670&r1=1374669&r2=1374670&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
Sat Aug 18 23:04:44 2012
@@ -31,8 +31,6 @@ import org.apache.padaf.xmpbox.XMPMetada
*/
public abstract class AbstractSimpleProperty extends AbstractField {
- private Object objValue;
-
/**
* Property specific type constructor (namespaceURI is given)
*
@@ -63,10 +61,6 @@ public abstract class AbstractSimpleProp
*/
public abstract void setValue(Object value);
- protected void setObjectValue (Object value) {
- this.objValue = value;
- }
-
/**
* Return the property value
*
@@ -74,14 +68,13 @@ public abstract class AbstractSimpleProp
*/
public abstract String getStringValue();
- public Object getObjectValue () {
- return objValue;
- }
+ public abstract Object getValue();
+
public String toString () {
StringBuilder sb = new StringBuilder ();
sb.append("[").append(this.getClass().getSimpleName()).append(":");
- sb.append(objValue).append("]");
+ sb.append(getStringValue()).append("]");
return sb.toString();
}
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=1374670&r1=1374669&r2=1374670&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
Sat Aug 18 23:04:44 2012
@@ -32,8 +32,11 @@ import org.apache.padaf.xmpbox.XMPMetada
public class BooleanType extends AbstractSimpleProperty {
public static final String TRUE = "True";
+
public static final String FALSE = "False";
+ private boolean booleanValue;
+
/**
* Property Boolean type constructor (namespaceURI is given)
*
@@ -59,8 +62,8 @@ public class BooleanType extends Abstrac
*
* @return boolean the property value
*/
- public boolean getValue() {
- return (Boolean) getObjectValue();
+ public Boolean getValue() {
+ return booleanValue;
}
/**
@@ -73,14 +76,14 @@ public class BooleanType extends Abstrac
*/
public void setValue(Object value) {
if (value instanceof Boolean) {
- setObjectValue(value);
+ booleanValue = ((Boolean)value).booleanValue();
} else if (value instanceof String) {
// NumberFormatException is thrown (sub of
InvalidArgumentException)
String s = value.toString().trim().toUpperCase();
if ("TRUE".equals(s)) {
- setObjectValue(Boolean.TRUE);
+ booleanValue = true;
} else if ("FALSE".equals(s)) {
- setObjectValue(Boolean.FALSE);
+ booleanValue = false;
} else {
// unknown value
throw new IllegalArgumentException("Not a valid
boolean value : '"+value+"'");
@@ -94,7 +97,7 @@ public class BooleanType extends Abstrac
@Override
public String getStringValue() {
- return ((Boolean)getObjectValue()).booleanValue()?TRUE:FALSE;
+ return booleanValue?TRUE:FALSE;
}
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java
Sat Aug 18 23:04:44 2012
@@ -36,7 +36,9 @@ import org.apache.padaf.xmpbox.parser.Da
*/
public class DateType extends AbstractSimpleProperty {
-
+ private Calendar dateValue;
+
+
/**
* Property Date type constructor (namespaceURI is given)
*
@@ -64,7 +66,7 @@ public class DateType extends AbstractSi
* @throws InappropriateTypeException
*/
private void setValueFromCalendar(Calendar value) {
- setObjectValue(value);
+ dateValue = value;
}
/**
@@ -73,7 +75,7 @@ public class DateType extends AbstractSi
* @return boolean
*/
public Calendar getValue() {
- return (Calendar) getObjectValue();
+ return dateValue;
}
/**
@@ -121,8 +123,8 @@ public class DateType extends AbstractSi
}
public String getStringValue() {
- return DateConverter.toISO8601((Calendar)getObjectValue());
- } // TODO should be abstract
+ return DateConverter.toISO8601(dateValue);
+ }
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/IntegerType.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/IntegerType.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/IntegerType.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/IntegerType.java
Sat Aug 18 23:04:44 2012
@@ -32,6 +32,8 @@ import org.apache.padaf.xmpbox.XMPMetada
public class IntegerType extends AbstractSimpleProperty {
+ private int integerValue;
+
/**
* Property Integer type constructor (namespaceURI is given)
*
@@ -57,8 +59,8 @@ public class IntegerType extends Abstrac
*
* @return the property value
*/
- public int getValue() {
- return (Integer) getObjectValue();
+ public Integer getValue() {
+ return integerValue;
}
/**
@@ -69,10 +71,10 @@ public class IntegerType extends Abstrac
*/
public void setValue(Object value) {
if (value instanceof Integer) {
- setObjectValue(value);
+ integerValue = ((Integer)value).intValue();
} else if (value instanceof String) {
+ integerValue = Integer.valueOf((String)value);
// NumberFormatException is thrown (sub of
InvalidArgumentException)
- setObjectValue(Integer.valueOf((String)value));
} else {
// invalid type of value
throw new IllegalArgumentException("Value given is not
allowed for the Integer type.");
@@ -81,7 +83,7 @@ public class IntegerType extends Abstrac
@Override
public String getStringValue() {
- return ((Integer)getObjectValue()).toString();
+ return Integer.toString(integerValue);
}
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/RealType.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/RealType.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/RealType.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/RealType.java
Sat Aug 18 23:04:44 2012
@@ -31,6 +31,7 @@ import org.apache.padaf.xmpbox.XMPMetada
*/
public class RealType extends AbstractSimpleProperty {
+ private float realValue;
/**
* Property Real type constructor (namespaceURI is given)
@@ -57,8 +58,8 @@ public class RealType extends AbstractSi
*
* @return float the property value
*/
- public float getValue() {
- return (Float) getObjectValue();
+ public Float getValue() {
+ return realValue;
}
/**
@@ -69,10 +70,10 @@ public class RealType extends AbstractSi
*/
public void setValue(Object value) {
if (value instanceof Float) {
- setObjectValue(value);
+ realValue = ((Float)value).floatValue();
} else if (value instanceof String) {
// NumberFormatException is thrown (sub of
InvalidArgumentException)
- setObjectValue(Float.valueOf((String)value));
+ realValue = Float.valueOf((String)value);
} else {
// invalid type of value
throw new IllegalArgumentException("Value given is not
allowed for the Real type.");
@@ -81,7 +82,7 @@ public class RealType extends AbstractSi
@Override
public String getStringValue() {
- return ((Float)getObjectValue()).toString();
+ return Float.toString(realValue);
}
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TextType.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TextType.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TextType.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/TextType.java
Sat Aug 18 23:04:44 2012
@@ -31,6 +31,7 @@ import org.apache.padaf.xmpbox.XMPMetada
*/
public class TextType extends AbstractSimpleProperty {
+ private String textValue;
/**
* Property Text type constructor (namespaceURI is given)
@@ -64,14 +65,19 @@ public class TextType extends AbstractSi
"Value given is not allowed for the
Text type : '" + value
+ "'");
} else {
- setObjectValue((String) value);
+ textValue = (String)value;
}
}
@Override
public String getStringValue() {
- return ((String)getObjectValue());
+ return textValue;
+ }
+
+ @Override
+ public Object getValue() {
+ return textValue;
}
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java
Sat Aug 18 23:04:44 2012
@@ -155,7 +155,7 @@ public abstract class AbstractSchemaTest
set.invoke(getSchema(), new Object [] {asp});
// check property set
AbstractSimpleProperty stored =
(AbstractSimpleProperty)getSchema().getProperty(getPropertyQualifiedName(fieldName));
- Assert.assertEquals(value, stored.getObjectValue());
+ Assert.assertEquals(value, stored.getValue());
// check getter
String getter =
TypeTestingHelper.calculateSimpleGetter(fieldName)+"Property";
Method get = getSchemaClass().getMethod(getter, new Class[0]);
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=1374670&r1=1374669&r2=1374670&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
Sat Aug 18 23:04:44 2012
@@ -220,7 +220,7 @@ public class XMPSchemaTest {
schem.addUnqualifiedSequenceValue(seqprop, seqPropVal);
schem.addSequenceDateValueAsSimple(seqdate, dateVal);
- Assert.assertEquals(boolVal, schem.getBooleanProperty(prefSchem
+ bool)
+ Assert.assertEquals(Boolean.valueOf(boolVal),
schem.getBooleanProperty(prefSchem + bool)
.getValue());
Assert.assertEquals(dateVal, schem.getDateProperty(prefSchem +
date)
.getValue());
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java
Sat Aug 18 23:04:44 2012
@@ -121,7 +121,7 @@ public abstract class AbstractStructured
Method set = clz.getMethod(setter, new Class<?>[]
{TypeTestingHelper.getJavaType(td)} );
set.invoke(getStructured(), new Object [] {value});
// check property set
- Assert.assertEquals(value,
getStructured().getProperty(fieldName).getObjectValue());
+ Assert.assertEquals(value,
getStructured().getProperty(fieldName).getValue());
// check getter
Method get =
clz.getMethod(TypeTestingHelper.calculateSimpleGetter(fieldName), new Class[0]);
Object result = get.invoke(getStructured(), new Object [0]);
Modified:
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java?rev=1374670&r1=1374669&r2=1374670&view=diff
==============================================================================
---
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java
(original)
+++
pdfbox/branches/xmpbox-refactoring/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java
Sat Aug 18 23:04:44 2012
@@ -108,8 +108,8 @@ public class TestDerivedType {
public void test1 () throws Exception {
TextType element = instanciate(xmp, null, PREFIX, NAME, VALUE);
Assert.assertNull(element.getNamespace());
- Assert.assertTrue(element.getObjectValue() instanceof String);
- Assert.assertEquals(VALUE, element.getObjectValue());
+ Assert.assertTrue(element.getValue() instanceof String);
+ Assert.assertEquals(VALUE, element.getValue());
}
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=1374670&r1=1374669&r2=1374670&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
Sat Aug 18 23:04:44 2012
@@ -130,7 +130,7 @@ public class TestSimpleMetadataPropertie
// .getNodeName());
Assert.assertEquals(boolv, bool.getValue());
Assert.assertEquals(datev, date.getValue());
- Assert.assertEquals(integerv, integer.getValue());
+ Assert.assertEquals(Integer.valueOf(integerv),
integer.getValue());
Assert.assertEquals(realv, real.getValue(), 0);
Assert.assertEquals(textv, text.getStringValue());