string.equals("") -> string.isEmpty() or "".equals(string)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
36dcbd7403
commit
cfac692a6a
@ -32,7 +32,7 @@ Select an Excel file to read.
|
||||
|
||||
<%
|
||||
String filename = request.getParameter("xls_filename");
|
||||
if (filename != null && !filename.equals("")) {
|
||||
if (filename != null && !filename.isEmpty()) {
|
||||
%>
|
||||
<br>You chose the file <%= filename %>.
|
||||
<br><br>It's contents are:
|
||||
|
@ -479,7 +479,7 @@ public class ToHtml {
|
||||
style.getDataFormatString());
|
||||
CellFormatResult result = cf.apply(cell);
|
||||
content = result.text;
|
||||
if (content.equals("")) {
|
||||
if ("".equals(content)) {
|
||||
content = " ";
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ public class EscherGraphics extends Graphics
|
||||
@Override
|
||||
public void drawString(String str, int x, int y)
|
||||
{
|
||||
if (str == null || str.equals(""))
|
||||
if (str == null || str.isEmpty())
|
||||
return;
|
||||
|
||||
Font excelFont = font;
|
||||
|
@ -328,7 +328,7 @@ public class CellFormatPart {
|
||||
*/
|
||||
private CellFormatType formatType(String fdesc) {
|
||||
fdesc = fdesc.trim();
|
||||
if (fdesc.equals("") || fdesc.equalsIgnoreCase("General"))
|
||||
if (fdesc.isEmpty() || fdesc.equalsIgnoreCase("General"))
|
||||
return CellFormatType.GENERAL;
|
||||
|
||||
Matcher m = SPECIFICATION_PAT.matcher(fdesc);
|
||||
|
@ -61,7 +61,7 @@ public final class DGet implements IDStarAlgorithm {
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
} else
|
||||
try {
|
||||
if(OperandResolver.coerceValueToString(OperandResolver.getSingleValue(result, 0, 0)).equals("")) {
|
||||
if(OperandResolver.coerceValueToString(OperandResolver.getSingleValue(result, 0, 0)).isEmpty()) {
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
}
|
||||
else {
|
||||
|
@ -847,7 +847,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||
throw new IllegalArgumentException("partName");
|
||||
}
|
||||
|
||||
if (contentType == null || contentType.equals("")) {
|
||||
if (contentType == null || contentType.isEmpty()) {
|
||||
throw new IllegalArgumentException("contentType");
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public final class PackagePartCollection implements Serializable {
|
||||
PackagingURIHelper.FORWARD_SLASH_STRING);
|
||||
StringBuilder concatSeg = new StringBuilder();
|
||||
for (String seg : segments) {
|
||||
if (!seg.equals(""))
|
||||
if (!seg.isEmpty())
|
||||
concatSeg.append(PackagingURIHelper.FORWARD_SLASH_CHAR);
|
||||
concatSeg.append(seg);
|
||||
if (this.registerPartNameStr.contains(concatSeg.toString())) {
|
||||
|
@ -241,14 +241,14 @@ public final class PackagePartName implements Comparable<PackagePartName> {
|
||||
|
||||
// Split the URI into several part and analyze each
|
||||
String[] segments = partUri.toASCIIString().split("/");
|
||||
if (segments.length <= 1 || !segments[0].equals(""))
|
||||
if (segments.length <= 1 || !segments[0].isEmpty())
|
||||
throw new InvalidFormatException(
|
||||
"A part name shall not have empty segments [M1.3]: "
|
||||
+ partUri.getPath());
|
||||
|
||||
for (int i = 1; i < segments.length; ++i) {
|
||||
String seg = segments[i];
|
||||
if (seg == null || "".equals(seg)) {
|
||||
if (seg == null || seg.isEmpty()) {
|
||||
throw new InvalidFormatException(
|
||||
"A part name shall not have empty segments [M1.3]: "
|
||||
+ partUri.getPath());
|
||||
|
@ -35,6 +35,9 @@ import org.apache.poi.util.POILogger;
|
||||
* @version 0.1
|
||||
*/
|
||||
public final class PackagingURIHelper {
|
||||
// FIXME: this class implements a lot of path joining and splitting logic that
|
||||
// is already implemented in java.nio.file.Path.
|
||||
// This class should heavily leverage Java library code to reduce the number of lines of code that POI has to maintain and test
|
||||
private final static POILogger _logger = POILogFactory.getLogger(PackagingURIHelper.class);
|
||||
|
||||
/**
|
||||
@ -321,13 +324,13 @@ public final class PackagingURIHelper {
|
||||
|
||||
// If we didn't have a good match or at least except a first empty element
|
||||
if ((segmentsTheSame == 0 || segmentsTheSame == 1) &&
|
||||
segmentsSource[0].equals("") && segmentsTarget[0].equals("")) {
|
||||
segmentsSource[0].isEmpty() && segmentsTarget[0].isEmpty()) {
|
||||
for (int i = 0; i < segmentsSource.length - 2; i++) {
|
||||
retVal.append("../");
|
||||
}
|
||||
for (int i = 0; i < segmentsTarget.length; i++) {
|
||||
if (segmentsTarget[i].equals(""))
|
||||
continue;
|
||||
if (segmentsTarget[i].isEmpty())
|
||||
continue;i
|
||||
retVal.append(segmentsTarget[i]);
|
||||
if (i != segmentsTarget.length - 1)
|
||||
retVal.append("/");
|
||||
|
@ -566,7 +566,7 @@ public final class PackagePropertiesPart extends PackagePart implements
|
||||
* Convert a strig value into a Nullable<String>
|
||||
*/
|
||||
private Nullable<String> setStringValue(String s) {
|
||||
if (s == null || s.equals("")) {
|
||||
if (s == null || s.isEmpty()) {
|
||||
return new Nullable<>();
|
||||
}
|
||||
return new Nullable<>(s);
|
||||
@ -579,7 +579,7 @@ public final class PackagePropertiesPart extends PackagePart implements
|
||||
* Throws if the date format isnot valid.
|
||||
*/
|
||||
private Nullable<Date> setDateValue(String dateStr) throws InvalidFormatException {
|
||||
if (dateStr == null || dateStr.equals("")) {
|
||||
if (dateStr == null || dateStr.isEmpty()) {
|
||||
return new Nullable<>();
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ public class XSSFExportToXml implements Comparator<String>{
|
||||
|
||||
private boolean isNamespaceDeclared() {
|
||||
String schemaNamespace = getNamespace();
|
||||
return schemaNamespace!=null && !schemaNamespace.equals("");
|
||||
return schemaNamespace!=null && !schemaNamespace.isEmpty();
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
|
@ -76,7 +76,7 @@ public final class TestXSSFExportToXML {
|
||||
String xml = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xml);
|
||||
assertFalse(xml.equals(""));
|
||||
assertFalse(xml.isEmpty());
|
||||
|
||||
String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
|
||||
String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
|
||||
@ -124,7 +124,7 @@ public final class TestXSSFExportToXML {
|
||||
String xml = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xml);
|
||||
assertFalse(xml.equals(""));
|
||||
assertFalse(xml.isEmpty());
|
||||
|
||||
String docente = xml.split("<DOCENTE>")[1].split("</DOCENTE>")[0].trim();
|
||||
String nome = xml.split("<NOME>")[1].split("</NOME>")[0].trim();
|
||||
@ -256,7 +256,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
String a = xmlData.split("<A>")[1].split("</A>")[0].trim();
|
||||
String b = a.split("<B>")[1].split("</B>")[0].trim();
|
||||
@ -299,7 +299,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
assertEquals("2012-01-13", xmlData.split("<DATE>")[1].split("</DATE>")[0].trim());
|
||||
assertEquals("2012-02-16", xmlData.split("<FORMULA_DATE>")[1].split("</FORMULA_DATE>")[0].trim());
|
||||
@ -333,7 +333,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
String a = xmlData.split("<A>")[1].split("</A>")[0].trim();
|
||||
String doubleValue = a.split("<DOUBLE>")[1].split("</DOUBLE>")[0].trim();
|
||||
@ -372,7 +372,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
String a = xmlData.split("<A>")[1].split("</A>")[0].trim();
|
||||
String euro = a.split("<EUR>")[1].split("</EUR>")[0].trim();
|
||||
@ -397,7 +397,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertTrue(!xmlData.equals(""));
|
||||
assertTrue(!xmlData.isEmpty());
|
||||
|
||||
String a = xmlData.split("<A>")[1].split("</A>")[0].trim();
|
||||
String a_b = a.split("<B>")[1].split("</B>")[0].trim();
|
||||
@ -472,7 +472,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
String a = xmlData.split("<A>")[1].split("</A>")[0].trim();
|
||||
String a_b = a.split("<B>")[1].split("</B>")[0].trim();
|
||||
@ -569,7 +569,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
parseXML(xmlData);
|
||||
|
||||
@ -600,7 +600,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
parseXML(xmlData);
|
||||
|
||||
@ -631,7 +631,7 @@ public final class TestXSSFExportToXML {
|
||||
String xmlData = os.toString("UTF-8");
|
||||
|
||||
assertNotNull(xmlData);
|
||||
assertFalse(xmlData.equals(""));
|
||||
assertFalse(xmlData.isEmpty());
|
||||
|
||||
assertEquals("2014-12-31", xmlData.split("<DATE>")[1].split("</DATE>")[0].trim());
|
||||
assertEquals("12.5", xmlData.split("<REFELEMENT>")[1].split("</REFELEMENT>")[0].trim());
|
||||
|
@ -505,7 +505,7 @@ public abstract class BaseTestCell {
|
||||
assertEquals("abc", cellA1.getStringCellValue());
|
||||
|
||||
fe.evaluateInCell(cellA1);
|
||||
assertFalse("Identified bug with writing back formula result of type string", cellA1.getStringCellValue().equals(""));
|
||||
assertFalse("Identified bug with writing back formula result of type string", cellA1.getStringCellValue().isEmpty());
|
||||
assertEquals("abc", cellA1.getStringCellValue());
|
||||
|
||||
wb.close();
|
||||
|
Loading…
Reference in New Issue
Block a user