diff --git a/src/java/org/apache/poi/hpsf/Variant.java b/src/java/org/apache/poi/hpsf/Variant.java index b93419545..87acdc066 100644 --- a/src/java/org/apache/poi/hpsf/Variant.java +++ b/src/java/org/apache/poi/hpsf/Variant.java @@ -420,7 +420,7 @@ public class Variant } name += numberToName.get(vt); - return !"".equals(name) ? name : "unknown variant type"; + return !name.isEmpty() ? name : "unknown variant type"; } /** diff --git a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java index af829839f..9273f53e0 100644 --- a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java +++ b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java @@ -379,7 +379,7 @@ public class CryptoFunctions { // SET Verifier TO 0x0000 short verifier = 0; - if (!"".equals(password)) { + if (!password.isEmpty()) { // FOR EACH PasswordByte IN PasswordArray IN REVERSE ORDER for (int i = arrByteChars.length-1; i >= 0; i--) { // SET Verifier TO Intermediate3 BITWISE XOR PasswordByte @@ -418,7 +418,7 @@ public class CryptoFunctions { //Maximum length of the password is 15 chars. final int maxPasswordLength = 15; - if (!"".equals(password)) { + if (!password.isEmpty()) { // Truncate the password to 15 characters password = password.substring(0, Math.min(password.length(), maxPasswordLength)); diff --git a/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java b/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java index 620b168eb..38f0b533c 100644 --- a/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java +++ b/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java @@ -356,7 +356,7 @@ public class DataSpaceMapUtils { } public static void writeUtf8LPP4(LittleEndianOutput os, String str) { - if (str == null || "".equals(str)) { + if (str == null || str.isEmpty()) { os.writeInt(str == null ? 0 : 4); os.writeInt(0); } else { diff --git a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java index bec5d898f..e93a3a5fb 100644 --- a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java +++ b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java @@ -257,7 +257,7 @@ public class DrawTextParagraph implements Drawable { fact.fixFonts(graphics); StringBuilder text = new StringBuilder(); AttributedString at = getAttributedString(graphics, text); - boolean emptyParagraph = ("".equals(text.toString().trim())); + boolean emptyParagraph = text.toString().trim().isEmpty(); AttributedCharacterIterator it = at.getIterator(); LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext()); diff --git a/src/java/org/apache/poi/ss/formula/functions/Countblank.java b/src/java/org/apache/poi/ss/formula/functions/Countblank.java index 348a23e12..af2016f80 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Countblank.java +++ b/src/java/org/apache/poi/ss/formula/functions/Countblank.java @@ -54,7 +54,7 @@ public final class Countblank extends Fixed1ArgFunction { return valueEval == BlankEval.instance || // see https://support.office.com/en-us/article/COUNTBLANK-function-6a92d772-675c-4bee-b346-24af6bd3ac22 // "Cells with formulas that return "" (empty text) are also counted." - (valueEval instanceof StringEval && "".equals(((StringEval)valueEval).getStringValue())); + (valueEval instanceof StringEval && ((StringEval)valueEval).getStringValue().isEmpty()); } }; } diff --git a/src/java/org/apache/poi/ss/usermodel/FractionFormat.java b/src/java/org/apache/poi/ss/usermodel/FractionFormat.java index e4e7d61f3..76834a7ed 100644 --- a/src/java/org/apache/poi/ss/usermodel/FractionFormat.java +++ b/src/java/org/apache/poi/ss/usermodel/FractionFormat.java @@ -150,7 +150,7 @@ public class FractionFormat extends Format { } //if whole part has to go into the numerator - if ("".equals(wholePartFormatString)){ + if (wholePartFormatString.isEmpty()){ int trueNum = (fract.getDenominator()*(int)wholePart)+fract.getNumerator(); sb.append(trueNum).append("/").append(fract.getDenominator()); return sb.toString(); diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java index b9b904d66..32b5acf9a 100644 --- a/src/java/org/apache/poi/util/StringUtil.java +++ b/src/java/org/apache/poi/util/StringUtil.java @@ -348,7 +348,7 @@ public class StringUtil { * @see Symbol font - Unicode alternatives for Greek and special characters in HTML */ public static String mapMsCodepointString(String string) { - if (string == null || "".equals(string)) return string; + if (string == null || string.isEmpty()) return string; initMsCodepointMap(); StringBuilder sb = new StringBuilder(); diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java index 5c9a02e86..901829d0f 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java @@ -242,7 +242,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { */ public static OPCPackage open(String path, PackageAccess access) throws InvalidFormatException, InvalidOperationException { - if (path == null || "".equals(path.trim())) { + if (path == null || path.trim().isEmpty()) { throw new IllegalArgumentException("'path' must be given"); } @@ -459,7 +459,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { try { l.writeLock().lock(); if (this.originalPackagePath != null - && !"".equals(this.originalPackagePath.trim())) { + && !this.originalPackagePath.trim().isEmpty()) { File targetFile = new File(this.originalPackagePath); if (!targetFile.exists() || !(this.originalPackagePath diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java index 099382d3b..7658e6259 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java @@ -260,7 +260,7 @@ public final class PackagePartName implements Comparable { + partUri.getPath()); } - if ("".equals(seg.replaceAll("\\\\.", ""))) { + if (seg.replaceAll("\\\\.", "").isEmpty()) { // Normally will never been invoked with the previous // implementation rule [M1.9] throw new InvalidFormatException( diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java index 16285615d..7dcf8b5f9 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -430,7 +430,7 @@ public final class ZipPackage extends OPCPackage { // Flush the package flush(); - if (this.originalPackagePath == null || "".equals(this.originalPackagePath)) { + if (this.originalPackagePath == null || this.originalPackagePath.isEmpty()) { return; } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/OOXMLURIDereferencer.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/OOXMLURIDereferencer.java index 07711d2b8..6a9cf7685 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/OOXMLURIDereferencer.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/OOXMLURIDereferencer.java @@ -112,7 +112,7 @@ public class OOXMLURIDereferencer implements URIDereferencer, SignatureConfigura LOG.log(POILogger.DEBUG, "dereference", uri); String path = uri.getPath(); - if (path == null || "".equals(path)) { + if (path == null || path.isEmpty()) { LOG.log(POILogger.DEBUG, "illegal part name (expected)", uri); return null; } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java index 79c2b4968..c4d767fac 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java @@ -205,7 +205,7 @@ public class RelationshipTransformService extends TransformService { String id = el.getAttribute("Id"); if (sourceIds.contains(id)) { String targetMode = el.getAttribute("TargetMode"); - if ("".equals(targetMode)) { + if (targetMode.isEmpty()) { el.setAttribute("TargetMode", "Internal"); } rsList.put(id, el); diff --git a/src/ooxml/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java b/src/ooxml/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java index 5c235267c..1b2fa0e48 100644 --- a/src/ooxml/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java +++ b/src/ooxml/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java @@ -138,14 +138,14 @@ public class EmbeddedExtractor implements Iterable { String extension = (filename == null || filename.lastIndexOf('.') == -1) ? ".bin" : filename.substring(filename.lastIndexOf('.')); // try to find an alternative name - if (filename == null || "".equals(filename) || filename.startsWith("MBD") || filename.startsWith("Root Entry")) { + if (filename == null || filename.isEmpty() || filename.startsWith("MBD") || filename.startsWith("Root Entry")) { filename = shape.getShapeName(); if (filename != null) { filename += extension; } } // default to dummy name - if (filename == null || "".equals(filename)) { + if (filename == null || filename.isEmpty()) { filename = "picture_" + embeddings.size() + extension; } filename = filename.trim(); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java index d5d0d4c6c..e806861d2 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java @@ -51,7 +51,7 @@ public class XSLFHyperlink implements Hyperlink { @Override public String getAddress() { String id = _link.getId(); - if (id == null || "".equals(id)) { + if (id == null || id.isEmpty()) { return _link.getAction(); } @@ -163,4 +163,4 @@ public class XSLFHyperlink implements Hyperlink { _link.setId(""); _link.setAction("ppaction://hlinkshowjump?jump="+jump); } -} \ No newline at end of file +} diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java index ea5336008..a1a3065a1 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java @@ -845,7 +845,7 @@ public class XSLFTextRun implements TextRun { } // SYMBOL is missing - if (font == null || !font.isSetTypeface() || "".equals(font.getTypeface())) { + if (font == null || !font.isSetTypeface() || font.getTypeface().isEmpty()) { font = coll.getLatin(); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java index c0e0fc855..e60c4fca1 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java @@ -312,7 +312,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { pivotField.setAxis(STAxis.AXIS_COL); pivotField.setShowAll(false); - if (valueFormat != null && !"".equals(valueFormat.trim())) { + if (valueFormat != null && !valueFormat.trim().isEmpty()) { DataFormat df = parentSheet.getWorkbook().createDataFormat(); pivotField.setNumFmtId(df.getFormat(valueFormat)); } @@ -440,7 +440,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { cell.setCellType(CellType.STRING); dataField.setName(valueFieldName); dataField.setFld(columnIndex); - if (valueFormat != null && !"".equals(valueFormat.trim())) { + if (valueFormat != null && !valueFormat.trim().isEmpty()) { DataFormat df = parentSheet.getWorkbook().createDataFormat(); dataField.setNumFmtId(df.getFormat(valueFormat)); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPasswordHelper.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPasswordHelper.java index 46e47f688..471a48c71 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPasswordHelper.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPasswordHelper.java @@ -127,7 +127,7 @@ public final class XSSFPasswordHelper { private static QName getAttrName(String prefix, String name) { - if (prefix == null || "".equals(prefix)) { + if (prefix == null || prefix.isEmpty()) { return new QName(name); } else { return new QName(prefix+Character.toUpperCase(name.charAt(0))+name.substring(1)); diff --git a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java index cf5d74b18..dcdf9c699 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java @@ -230,7 +230,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { if(sh instanceof HSLFTextShape){ HSLFTextShape hsh = (HSLFTextShape)sh; final String text = hsh.getText(); - if (text == null || "".equals(text) || "*".equals(text)) { + if (text == null || text.isEmpty() || "*".equals(text)) { continue; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFontInfo.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFontInfo.java index f2cc64c51..57c473173 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFontInfo.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFontInfo.java @@ -125,7 +125,7 @@ public class HSLFFontInfo implements FontInfo { @Override public void setTypeface(String typeface){ - if (typeface == null || "".equals(typeface)) { + if (typeface == null || typeface.isEmpty()) { throw new IllegalArgumentException("typeface can't be null nor empty"); } this.typeface = typeface; diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java index 6152920ad..13b2806cd 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java @@ -323,7 +323,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape