]> source.dussan.org Git - poi.git/commitdiff
cleanup for r1812475: avoid NPEs from string.isEmpty()
authorJaven O'Neal <onealj@apache.org>
Wed, 18 Oct 2017 14:29:56 +0000 (14:29 +0000)
committerJaven O'Neal <onealj@apache.org>
Wed, 18 Oct 2017 14:29:56 +0000 (14:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812520 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java

index 923f36f88ce2572b3e9332849484be90661c9540..3dac34b6cd05fdbe5f61cde04c9f2dcc45ff33da 100644 (file)
@@ -163,7 +163,8 @@ public class XSSFExportToXml implements Comparator<String>{
                         mapCellOnNode(cell,currentNode);
                         
                         //remove nodes which are empty in order to keep the output xml valid
-                        if (currentNode.getTextContent().isEmpty() && currentNode.getParentNode() != null) {
+                        // FIXME: what should be done if currentNode.getTextContent() is null?
+                        if ("".equals(currentNode.getTextContent()) && currentNode.getParentNode() != null) {
                             currentNode.getParentNode().removeChild(currentNode);
                         }
                     }
@@ -467,7 +468,8 @@ public class XSSFExportToXml implements Comparator<String>{
 
         // Note: we expect that all the complex types are defined at root level
         Node complexTypeNode = null;
-        if (!complexTypeName.isEmpty()) {
+        // FIXME: what should be done if complexTypeName is null?
+        if (!"".equals(complexTypeName)) {
             complexTypeNode = getComplexTypeNodeFromSchemaChildren(xmlSchema, null, complexTypeName);
         }
 
@@ -483,8 +485,7 @@ public class XSSFExportToXml implements Comparator<String>{
         NodeList  list  = localComplexTypeRootNode.getChildNodes();
         String complexTypeName = "";
 
-        for(int i=0; i< list.getLength();i++) {
-            Node node = list.item(i);
+        for(final Node node : list) {
             if ( node instanceof Element && "element".equals(node.getLocalName())) {
                 Node nameAttribute = getNameOrRefElement(node);
                 if (nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {