Author: onealj
Date: Wed Oct 18 08:41:25 2017
New Revision: 1812475

URL: http://svn.apache.org/viewvc?rev=1812475&view=rev
Log:
prefer literal.equals(variable) over variable.equals(literal)

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=1812475&r1=1812474&r2=1812475&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java 
Wed Oct 18 08:41:25 2017
@@ -163,8 +163,8 @@ public class XSSFExportToXml implements
                         mapCellOnNode(cell,currentNode);
                         
                         //remove nodes which are empty in order to keep the 
output xml valid
-                        if("".equals(currentNode.getTextContent()) && 
currentNode.getParentNode() != null) {
-                               
currentNode.getParentNode().removeChild(currentNode);
+                        if (currentNode.getTextContent().isEmpty() && 
currentNode.getParentNode() != null) {
+                            
currentNode.getParentNode().removeChild(currentNode);
                         }
                     }
                 }
@@ -440,14 +440,11 @@ public class XSSFExportToXml implements
 
         for(int i=0; i< list.getLength();i++) {
             Node node = list.item(i);
-            if (node instanceof Element) {
-                if (node.getLocalName().equals("element")) {
-                    Node element = getNameOrRefElement(node);
-                    if 
(element.getNodeValue().equals(removeNamespace(elementName))) {
-                        indexOf = i;
-                        break;
-                    }
-
+            if (node instanceof Element && 
"element".equals(node.getLocalName())) {
+                Node element = getNameOrRefElement(node);
+                if 
(element.getNodeValue().equals(removeNamespace(elementName))) {
+                    indexOf = i;
+                    break;
                 }
             }
         }
@@ -470,7 +467,7 @@ public class XSSFExportToXml implements
 
         // Note: we expect that all the complex types are defined at root level
         Node complexTypeNode = null;
-        if (!"".equals(complexTypeName)) {
+        if (!complexTypeName.isEmpty()) {
             complexTypeNode = getComplexTypeNodeFromSchemaChildren(xmlSchema, 
null, complexTypeName);
         }
 
@@ -488,15 +485,13 @@ public class XSSFExportToXml implements
 
         for(int i=0; i< list.getLength();i++) {
             Node node = list.item(i);
-            if ( node instanceof Element) {
-                if (node.getLocalName().equals("element")) {
-                    Node nameAttribute = getNameOrRefElement(node);
-                    if 
(nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {
-                        Node complexTypeAttribute = 
node.getAttributes().getNamedItem("type");
-                        if (complexTypeAttribute!=null) {
-                            complexTypeName = 
complexTypeAttribute.getNodeValue();
-                            break;
-                        }
+            if ( node instanceof Element && 
"element".equals(node.getLocalName())) {
+                Node nameAttribute = getNameOrRefElement(node);
+                if 
(nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {
+                    Node complexTypeAttribute = 
node.getAttributes().getNamedItem("type");
+                    if (complexTypeAttribute!=null) {
+                        complexTypeName = complexTypeAttribute.getNodeValue();
+                        break;
                     }
                 }
             }
@@ -510,7 +505,7 @@ public class XSSFExportToXml implements
         for(int i=0; i< complexTypeList.getLength();i++) {
             Node node = complexTypeList.item(i);
             if ( node instanceof Element) {
-                if (node.getLocalName().equals("complexType")) {
+                if ("complexType".equals(node.getLocalName())) {
                     Node nameAttribute = getNameOrRefElement(node);
                     if (nameAttribute.getNodeValue().equals(complexTypeName)) {
 
@@ -519,7 +514,8 @@ public class XSSFExportToXml implements
                             Node sequence = complexTypeChildList.item(j);
 
                             if ( sequence instanceof Element) {
-                                if (sequence.getLocalName().equals("sequence") 
|| sequence.getLocalName().equals("all")) {
+                                final String localName = 
sequence.getLocalName();
+                                if ("sequence".equals(localName) || 
"all".equals(localName)) {
                                     complexTypeNode = sequence;
                                     break;
                                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to