prefer literal.equals(variable) over variable.equals(literal)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-10-18 08:41:25 +00:00
parent 3a2ee5f4d1
commit aba704b928

View File

@ -163,7 +163,7 @@ public class XSSFExportToXml implements Comparator<String>{
mapCellOnNode(cell,currentNode); mapCellOnNode(cell,currentNode);
//remove nodes which are empty in order to keep the output xml valid //remove nodes which are empty in order to keep the output xml valid
if("".equals(currentNode.getTextContent()) && currentNode.getParentNode() != null) { if (currentNode.getTextContent().isEmpty() && currentNode.getParentNode() != null) {
currentNode.getParentNode().removeChild(currentNode); currentNode.getParentNode().removeChild(currentNode);
} }
} }
@ -440,15 +440,12 @@ public class XSSFExportToXml implements Comparator<String>{
for(int i=0; i< list.getLength();i++) { for(int i=0; i< list.getLength();i++) {
Node node = list.item(i); Node node = list.item(i);
if (node instanceof Element) { if (node instanceof Element && "element".equals(node.getLocalName())) {
if (node.getLocalName().equals("element")) {
Node element = getNameOrRefElement(node); Node element = getNameOrRefElement(node);
if (element.getNodeValue().equals(removeNamespace(elementName))) { if (element.getNodeValue().equals(removeNamespace(elementName))) {
indexOf = i; indexOf = i;
break; break;
} }
}
} }
} }
return indexOf; return indexOf;
@ -470,7 +467,7 @@ public class XSSFExportToXml implements Comparator<String>{
// Note: we expect that all the complex types are defined at root level // Note: we expect that all the complex types are defined at root level
Node complexTypeNode = null; Node complexTypeNode = null;
if (!"".equals(complexTypeName)) { if (!complexTypeName.isEmpty()) {
complexTypeNode = getComplexTypeNodeFromSchemaChildren(xmlSchema, null, complexTypeName); complexTypeNode = getComplexTypeNodeFromSchemaChildren(xmlSchema, null, complexTypeName);
} }
@ -488,8 +485,7 @@ public class XSSFExportToXml implements Comparator<String>{
for(int i=0; i< list.getLength();i++) { for(int i=0; i< list.getLength();i++) {
Node node = list.item(i); Node node = list.item(i);
if ( node instanceof Element) { if ( node instanceof Element && "element".equals(node.getLocalName())) {
if (node.getLocalName().equals("element")) {
Node nameAttribute = getNameOrRefElement(node); Node nameAttribute = getNameOrRefElement(node);
if (nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) { if (nameAttribute.getNodeValue().equals(elementNameWithoutNamespace)) {
Node complexTypeAttribute = node.getAttributes().getNamedItem("type"); Node complexTypeAttribute = node.getAttributes().getNamedItem("type");
@ -500,7 +496,6 @@ public class XSSFExportToXml implements Comparator<String>{
} }
} }
} }
}
return complexTypeName; return complexTypeName;
} }
@ -510,7 +505,7 @@ public class XSSFExportToXml implements Comparator<String>{
for(int i=0; i< complexTypeList.getLength();i++) { for(int i=0; i< complexTypeList.getLength();i++) {
Node node = complexTypeList.item(i); Node node = complexTypeList.item(i);
if ( node instanceof Element) { if ( node instanceof Element) {
if (node.getLocalName().equals("complexType")) { if ("complexType".equals(node.getLocalName())) {
Node nameAttribute = getNameOrRefElement(node); Node nameAttribute = getNameOrRefElement(node);
if (nameAttribute.getNodeValue().equals(complexTypeName)) { if (nameAttribute.getNodeValue().equals(complexTypeName)) {
@ -519,7 +514,8 @@ public class XSSFExportToXml implements Comparator<String>{
Node sequence = complexTypeChildList.item(j); Node sequence = complexTypeChildList.item(j);
if ( sequence instanceof Element) { 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; complexTypeNode = sequence;
break; break;
} }