pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1540811 - /pdfbox/trunk/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchema.java
Date Mon, 11 Nov 2013 19:14:58 GMT
Author: lehmi
Date: Mon Nov 11 19:14:57 2013
New Revision: 1540811

URL: http://svn.apache.org/r1540811
Log:
PDFBOX-823: avoid NPE when setting a dtae property

Modified:
    pdfbox/trunk/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchema.java

Modified: pdfbox/trunk/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchema.java?rev=1540811&r1=1540810&r2=1540811&view=diff
==============================================================================
--- pdfbox/trunk/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchema.java (original)
+++ pdfbox/trunk/jempbox/src/main/java/org/apache/jempbox/xmp/XMPSchema.java Mon Nov 11 19:14:57
2013
@@ -36,7 +36,7 @@ import org.w3c.dom.NodeList;
  * subclasses for access to specific properties.
  * 
  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.8 $
+ * 
  */
 public class XMPSchema
 {
@@ -246,7 +246,15 @@ public class XMPSchema
      */
     public void setDateProperty(String propertyName, Calendar date)
     {
-        setTextProperty(propertyName, DateConverter.toISO8601(date));
+        if (date != null)
+        {
+            setTextProperty(propertyName, DateConverter.toISO8601(date));
+        }
+        else
+        {
+            // remove the value for the given property 
+            setTextProperty(propertyName, null);
+        }
     }
 
     /**
@@ -820,7 +828,8 @@ public class XMPSchema
                     }
                 }
             }
-            else if (property.getChildNodes().getLength() == 1 && Node.TEXT_NODE
== property.getFirstChild().getNodeType())
+            else if (property.getChildNodes().getLength() == 1 
+                    && Node.TEXT_NODE == property.getFirstChild().getNodeType())
             {
                 retval = property.getFirstChild().getNodeValue();
             }



Mime
View raw message