pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1636417 - /pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java
Date Mon, 03 Nov 2014 19:14:30 GMT
Author: tilman
Date: Mon Nov  3 19:14:29 2014
New Revision: 1636417

URL: http://svn.apache.org/r1636417
Log:
PDFBOX-2477: avoid NPE in ResourceRef with no child elements; minor code cleanup

Modified:
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java

Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java?rev=1636417&r1=1636416&r2=1636417&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java Mon Nov  3 19:14:29
2014
@@ -342,8 +342,11 @@ public class DomXmpParser
                 if (DomHelper.isParseTypeResource(property))
                 {
                     AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property),
property);
-                    ast.setPrefix(prefix);
-                    container.addProperty(ast);
+                    if (ast != null)
+                    {
+                        ast.setPrefix(prefix);
+                        container.addProperty(ast);
+                    }
                 }
                 else
                 {
@@ -757,12 +760,14 @@ public class DomXmpParser
      */
     private void removeComments(Node root)
     {
-        if (root.getChildNodes().getLength()<=1) {
+        if (root.getChildNodes().getLength()<=1) 
+        {
             // There is only one node so we do not remove it
             return;
         }
         NodeList nl = root.getChildNodes();
-        for (int i=0; i < nl.getLength() ; i ++) {
+        for (int i=0; i < nl.getLength() ; i ++) 
+        {
             Node node = nl.item(i);
             if (node instanceof Comment)
             {
@@ -771,7 +776,7 @@ public class DomXmpParser
             }
             else if (node instanceof Text)
             {
-                if (node.getTextContent().trim().length() == 0)
+                if (node.getTextContent().trim().isEmpty())
                 {
                         root.removeChild(node);
                 }
@@ -837,7 +842,7 @@ public class DomXmpParser
     protected class NamespaceFinder
     {
 
-        private Stack<Map<String, String>> stack = new Stack<Map<String,
String>>();
+        private final Stack<Map<String, String>> stack = new Stack<Map<String,
String>>();
 
         protected void push(Element description)
         {



Mime
View raw message