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 2011/12/07 20:14:06 UTC
svn commit: r1211604 [4/4] - in
/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox: ./ parser/
schema/ type/
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java?rev=1211604&r1=1211603&r2=1211604&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/DateType.java Wed Dec 7 19:14:05 2011
@@ -36,125 +36,124 @@ import org.apache.padaf.xmpbox.parser.Da
*/
public class DateType extends AbstractSimpleProperty {
- /**
- * Property Date type constructor (namespaceURI is not given)
- *
- * @param metadata
- * The metadata to attach to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this property
- * @param value
- * The value to set for this property
- */
- public DateType(XMPMetadata metadata, String prefix, String propertyName,
- Object value) {
- super(metadata, prefix, propertyName, value);
-
- }
-
- /**
- * Property Date type constructor (namespaceURI is given)
- *
- * @param metadata
- * The metadata to attach to this property
- * @param namespaceURI
- * the namespace URI to associate to this property
- * @param prefix
- * The prefix to set for this property
- * @param propertyName
- * The local Name of this property
- * @param value
- * The value to set for this property
- */
- public DateType(XMPMetadata metadata, String namespaceURI, String prefix,
- String propertyName, Object value) {
- super(metadata, namespaceURI, prefix, propertyName, value);
- }
-
- /**
- * Set property value
- *
- * @param value
- * the new Calendar element value
- * @throws InappropriateTypeException
- */
- private void setValueFromCalendar(Calendar value) {
- objValue = value;
- element.setTextContent(DateConverter.toISO8601(value));
-
- }
-
- /**
- * return the property value
- *
- * @return boolean
- */
- public Calendar getValue() {
- return (Calendar) objValue;
- }
-
- /**
- * Check if the value has a type which can be understood
- *
- * @param value
- * Object value to check
- * @return True if types are compatibles
- */
- public boolean isGoodType(Object value) {
- if (value instanceof Calendar) {
- return true;
- } else if (value instanceof String) {
- try {
- DateConverter.toCalendar((String) value);
- return true;
- } catch (IOException e) {
- return false;
- }
- }
- return false;
- }
-
- /**
- * Set value of this property
- *
- * @param value
- * The value to set
- */
- public void setValue(Object value) {
- if (!isGoodType(value)) {
- throw new IllegalArgumentException(
- "Value given is not allowed for the Date type.");
- } else {
- // if string object
- if (value instanceof String) {
- setValueFromString((String) value);
- } else {
- // if Calendar
- setValueFromCalendar((Calendar) value);
- }
-
- }
-
- }
-
- /**
- * Set the property value with a String
- *
- * @param value
- * The String value
- */
- private void setValueFromString(String value) {
- try {
- setValueFromCalendar(DateConverter.toCalendar((String) value));
-
- } catch (IOException e) {
- // SHOULD NEVER HAPPEN
- // STRING HAS BEEN CHECKED BEFORE
- throw new IllegalArgumentException(e.getCause());
- }
+ /**
+ * Property Date type constructor (namespaceURI is not given)
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this property
+ * @param value
+ * The value to set for this property
+ */
+ public DateType(XMPMetadata metadata, String prefix, String propertyName,
+ Object value) {
+ super(metadata, prefix, propertyName, value);
+
+ }
+
+ /**
+ * Property Date type constructor (namespaceURI is given)
+ *
+ * @param metadata
+ * The metadata to attach to this property
+ * @param namespaceURI
+ * the namespace URI to associate to this property
+ * @param prefix
+ * The prefix to set for this property
+ * @param propertyName
+ * The local Name of this property
+ * @param value
+ * The value to set for this property
+ */
+ public DateType(XMPMetadata metadata, String namespaceURI, String prefix,
+ String propertyName, Object value) {
+ super(metadata, namespaceURI, prefix, propertyName, value);
+ }
+
+ /**
+ * Set property value
+ *
+ * @param value
+ * the new Calendar element value
+ * @throws InappropriateTypeException
+ */
+ private void setValueFromCalendar(Calendar value) {
+ objValue = value;
+ element.setTextContent(DateConverter.toISO8601(value));
+
+ }
+
+ /**
+ * return the property value
+ *
+ * @return boolean
+ */
+ public Calendar getValue() {
+ return (Calendar) objValue;
+ }
+
+ /**
+ * Check if the value has a type which can be understood
+ *
+ * @param value
+ * Object value to check
+ * @return True if types are compatibles
+ */
+ public boolean isGoodType(Object value) {
+ if (value instanceof Calendar) {
+ return true;
+ } else if (value instanceof String) {
+ try {
+ DateConverter.toCalendar((String) value);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Set value of this property
+ *
+ * @param value
+ * The value to set
+ */
+ public void setValue(Object value) {
+ if (!isGoodType(value)) {
+ throw new IllegalArgumentException(
+ "Value given is not allowed for the Date type.");
+ } else {
+ // if string object
+ if (value instanceof String) {
+ setValueFromString((String) value);
+ } else {
+ // if Calendar
+ setValueFromCalendar((Calendar) value);
+ }
+
+ }
+
+ }
+
+ /**
+ * Set the property value with a String
+ *
+ * @param value
+ * The String value
+ */
+ private void setValueFromString(String value) {
+ try {
+ setValueFromCalendar(DateConverter.toCalendar((String) value));
+ } catch (IOException e) {
+ // SHOULD NEVER HAPPEN
+ // STRING HAS BEEN CHECKED BEFORE
+ throw new IllegalArgumentException(e);
+ }
- }
+ }
}