replace "".equals(string) with string.isEmpty() to avoid null strings silently evaluating to false; most code should probably check string for null if it is not already
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aba704b928
commit
5fb4887907
@ -420,7 +420,7 @@ public class Variant
|
|||||||
}
|
}
|
||||||
|
|
||||||
name += numberToName.get(vt);
|
name += numberToName.get(vt);
|
||||||
return !"".equals(name) ? name : "unknown variant type";
|
return !name.isEmpty() ? name : "unknown variant type";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -379,7 +379,7 @@ public class CryptoFunctions {
|
|||||||
// SET Verifier TO 0x0000
|
// SET Verifier TO 0x0000
|
||||||
short verifier = 0;
|
short verifier = 0;
|
||||||
|
|
||||||
if (!"".equals(password)) {
|
if (!password.isEmpty()) {
|
||||||
// FOR EACH PasswordByte IN PasswordArray IN REVERSE ORDER
|
// FOR EACH PasswordByte IN PasswordArray IN REVERSE ORDER
|
||||||
for (int i = arrByteChars.length-1; i >= 0; i--) {
|
for (int i = arrByteChars.length-1; i >= 0; i--) {
|
||||||
// SET Verifier TO Intermediate3 BITWISE XOR PasswordByte
|
// SET Verifier TO Intermediate3 BITWISE XOR PasswordByte
|
||||||
@ -418,7 +418,7 @@ public class CryptoFunctions {
|
|||||||
//Maximum length of the password is 15 chars.
|
//Maximum length of the password is 15 chars.
|
||||||
final int maxPasswordLength = 15;
|
final int maxPasswordLength = 15;
|
||||||
|
|
||||||
if (!"".equals(password)) {
|
if (!password.isEmpty()) {
|
||||||
// Truncate the password to 15 characters
|
// Truncate the password to 15 characters
|
||||||
password = password.substring(0, Math.min(password.length(), maxPasswordLength));
|
password = password.substring(0, Math.min(password.length(), maxPasswordLength));
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ public class DataSpaceMapUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void writeUtf8LPP4(LittleEndianOutput os, String str) {
|
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(str == null ? 0 : 4);
|
||||||
os.writeInt(0);
|
os.writeInt(0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,7 +257,7 @@ public class DrawTextParagraph implements Drawable {
|
|||||||
fact.fixFonts(graphics);
|
fact.fixFonts(graphics);
|
||||||
StringBuilder text = new StringBuilder();
|
StringBuilder text = new StringBuilder();
|
||||||
AttributedString at = getAttributedString(graphics, text);
|
AttributedString at = getAttributedString(graphics, text);
|
||||||
boolean emptyParagraph = ("".equals(text.toString().trim()));
|
boolean emptyParagraph = text.toString().trim().isEmpty();
|
||||||
|
|
||||||
AttributedCharacterIterator it = at.getIterator();
|
AttributedCharacterIterator it = at.getIterator();
|
||||||
LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext());
|
LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext());
|
||||||
|
@ -54,7 +54,7 @@ public final class Countblank extends Fixed1ArgFunction {
|
|||||||
return valueEval == BlankEval.instance ||
|
return valueEval == BlankEval.instance ||
|
||||||
// see https://support.office.com/en-us/article/COUNTBLANK-function-6a92d772-675c-4bee-b346-24af6bd3ac22
|
// 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."
|
// "Cells with formulas that return "" (empty text) are also counted."
|
||||||
(valueEval instanceof StringEval && "".equals(((StringEval)valueEval).getStringValue()));
|
(valueEval instanceof StringEval && ((StringEval)valueEval).getStringValue().isEmpty());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class FractionFormat extends Format {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if whole part has to go into the numerator
|
//if whole part has to go into the numerator
|
||||||
if ("".equals(wholePartFormatString)){
|
if (wholePartFormatString.isEmpty()){
|
||||||
int trueNum = (fract.getDenominator()*(int)wholePart)+fract.getNumerator();
|
int trueNum = (fract.getDenominator()*(int)wholePart)+fract.getNumerator();
|
||||||
sb.append(trueNum).append("/").append(fract.getDenominator());
|
sb.append(trueNum).append("/").append(fract.getDenominator());
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
@ -348,7 +348,7 @@ public class StringUtil {
|
|||||||
* @see <a href="http://www.alanwood.net/demos/symbol.html">Symbol font - Unicode alternatives for Greek and special characters in HTML</a>
|
* @see <a href="http://www.alanwood.net/demos/symbol.html">Symbol font - Unicode alternatives for Greek and special characters in HTML</a>
|
||||||
*/
|
*/
|
||||||
public static String mapMsCodepointString(String string) {
|
public static String mapMsCodepointString(String string) {
|
||||||
if (string == null || "".equals(string)) return string;
|
if (string == null || string.isEmpty()) return string;
|
||||||
initMsCodepointMap();
|
initMsCodepointMap();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -242,7 +242,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
|||||||
*/
|
*/
|
||||||
public static OPCPackage open(String path, PackageAccess access)
|
public static OPCPackage open(String path, PackageAccess access)
|
||||||
throws InvalidFormatException, InvalidOperationException {
|
throws InvalidFormatException, InvalidOperationException {
|
||||||
if (path == null || "".equals(path.trim())) {
|
if (path == null || path.trim().isEmpty()) {
|
||||||
throw new IllegalArgumentException("'path' must be given");
|
throw new IllegalArgumentException("'path' must be given");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
|||||||
try {
|
try {
|
||||||
l.writeLock().lock();
|
l.writeLock().lock();
|
||||||
if (this.originalPackagePath != null
|
if (this.originalPackagePath != null
|
||||||
&& !"".equals(this.originalPackagePath.trim())) {
|
&& !this.originalPackagePath.trim().isEmpty()) {
|
||||||
File targetFile = new File(this.originalPackagePath);
|
File targetFile = new File(this.originalPackagePath);
|
||||||
if (!targetFile.exists()
|
if (!targetFile.exists()
|
||||||
|| !(this.originalPackagePath
|
|| !(this.originalPackagePath
|
||||||
|
@ -260,7 +260,7 @@ public final class PackagePartName implements Comparable<PackagePartName> {
|
|||||||
+ partUri.getPath());
|
+ partUri.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("".equals(seg.replaceAll("\\\\.", ""))) {
|
if (seg.replaceAll("\\\\.", "").isEmpty()) {
|
||||||
// Normally will never been invoked with the previous
|
// Normally will never been invoked with the previous
|
||||||
// implementation rule [M1.9]
|
// implementation rule [M1.9]
|
||||||
throw new InvalidFormatException(
|
throw new InvalidFormatException(
|
||||||
|
@ -430,7 +430,7 @@ public final class ZipPackage extends OPCPackage {
|
|||||||
// Flush the package
|
// Flush the package
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
if (this.originalPackagePath == null || "".equals(this.originalPackagePath)) {
|
if (this.originalPackagePath == null || this.originalPackagePath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class OOXMLURIDereferencer implements URIDereferencer, SignatureConfigura
|
|||||||
LOG.log(POILogger.DEBUG, "dereference", uri);
|
LOG.log(POILogger.DEBUG, "dereference", uri);
|
||||||
|
|
||||||
String path = uri.getPath();
|
String path = uri.getPath();
|
||||||
if (path == null || "".equals(path)) {
|
if (path == null || path.isEmpty()) {
|
||||||
LOG.log(POILogger.DEBUG, "illegal part name (expected)", uri);
|
LOG.log(POILogger.DEBUG, "illegal part name (expected)", uri);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public class RelationshipTransformService extends TransformService {
|
|||||||
String id = el.getAttribute("Id");
|
String id = el.getAttribute("Id");
|
||||||
if (sourceIds.contains(id)) {
|
if (sourceIds.contains(id)) {
|
||||||
String targetMode = el.getAttribute("TargetMode");
|
String targetMode = el.getAttribute("TargetMode");
|
||||||
if ("".equals(targetMode)) {
|
if (targetMode.isEmpty()) {
|
||||||
el.setAttribute("TargetMode", "Internal");
|
el.setAttribute("TargetMode", "Internal");
|
||||||
}
|
}
|
||||||
rsList.put(id, el);
|
rsList.put(id, el);
|
||||||
|
@ -138,14 +138,14 @@ public class EmbeddedExtractor implements Iterable<EmbeddedExtractor> {
|
|||||||
String extension = (filename == null || filename.lastIndexOf('.') == -1) ? ".bin" : filename.substring(filename.lastIndexOf('.'));
|
String extension = (filename == null || filename.lastIndexOf('.') == -1) ? ".bin" : filename.substring(filename.lastIndexOf('.'));
|
||||||
|
|
||||||
// try to find an alternative name
|
// 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();
|
filename = shape.getShapeName();
|
||||||
if (filename != null) {
|
if (filename != null) {
|
||||||
filename += extension;
|
filename += extension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// default to dummy name
|
// default to dummy name
|
||||||
if (filename == null || "".equals(filename)) {
|
if (filename == null || filename.isEmpty()) {
|
||||||
filename = "picture_" + embeddings.size() + extension;
|
filename = "picture_" + embeddings.size() + extension;
|
||||||
}
|
}
|
||||||
filename = filename.trim();
|
filename = filename.trim();
|
||||||
|
@ -51,7 +51,7 @@ public class XSLFHyperlink implements Hyperlink<XSLFShape,XSLFTextParagraph> {
|
|||||||
@Override
|
@Override
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
String id = _link.getId();
|
String id = _link.getId();
|
||||||
if (id == null || "".equals(id)) {
|
if (id == null || id.isEmpty()) {
|
||||||
return _link.getAction();
|
return _link.getAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,4 +163,4 @@ public class XSLFHyperlink implements Hyperlink<XSLFShape,XSLFTextParagraph> {
|
|||||||
_link.setId("");
|
_link.setId("");
|
||||||
_link.setAction("ppaction://hlinkshowjump?jump="+jump);
|
_link.setAction("ppaction://hlinkshowjump?jump="+jump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ public class XSLFTextRun implements TextRun {
|
|||||||
}
|
}
|
||||||
// SYMBOL is missing
|
// SYMBOL is missing
|
||||||
|
|
||||||
if (font == null || !font.isSetTypeface() || "".equals(font.getTypeface())) {
|
if (font == null || !font.isSetTypeface() || font.getTypeface().isEmpty()) {
|
||||||
font = coll.getLatin();
|
font = coll.getLatin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
|||||||
|
|
||||||
pivotField.setAxis(STAxis.AXIS_COL);
|
pivotField.setAxis(STAxis.AXIS_COL);
|
||||||
pivotField.setShowAll(false);
|
pivotField.setShowAll(false);
|
||||||
if (valueFormat != null && !"".equals(valueFormat.trim())) {
|
if (valueFormat != null && !valueFormat.trim().isEmpty()) {
|
||||||
DataFormat df = parentSheet.getWorkbook().createDataFormat();
|
DataFormat df = parentSheet.getWorkbook().createDataFormat();
|
||||||
pivotField.setNumFmtId(df.getFormat(valueFormat));
|
pivotField.setNumFmtId(df.getFormat(valueFormat));
|
||||||
}
|
}
|
||||||
@ -440,7 +440,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
|
|||||||
cell.setCellType(CellType.STRING);
|
cell.setCellType(CellType.STRING);
|
||||||
dataField.setName(valueFieldName);
|
dataField.setName(valueFieldName);
|
||||||
dataField.setFld(columnIndex);
|
dataField.setFld(columnIndex);
|
||||||
if (valueFormat != null && !"".equals(valueFormat.trim())) {
|
if (valueFormat != null && !valueFormat.trim().isEmpty()) {
|
||||||
DataFormat df = parentSheet.getWorkbook().createDataFormat();
|
DataFormat df = parentSheet.getWorkbook().createDataFormat();
|
||||||
dataField.setNumFmtId(df.getFormat(valueFormat));
|
dataField.setNumFmtId(df.getFormat(valueFormat));
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public final class XSSFPasswordHelper {
|
|||||||
|
|
||||||
|
|
||||||
private static QName getAttrName(String prefix, String name) {
|
private static QName getAttrName(String prefix, String name) {
|
||||||
if (prefix == null || "".equals(prefix)) {
|
if (prefix == null || prefix.isEmpty()) {
|
||||||
return new QName(name);
|
return new QName(name);
|
||||||
} else {
|
} else {
|
||||||
return new QName(prefix+Character.toUpperCase(name.charAt(0))+name.substring(1));
|
return new QName(prefix+Character.toUpperCase(name.charAt(0))+name.substring(1));
|
||||||
|
@ -230,7 +230,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
|||||||
if(sh instanceof HSLFTextShape){
|
if(sh instanceof HSLFTextShape){
|
||||||
HSLFTextShape hsh = (HSLFTextShape)sh;
|
HSLFTextShape hsh = (HSLFTextShape)sh;
|
||||||
final String text = hsh.getText();
|
final String text = hsh.getText();
|
||||||
if (text == null || "".equals(text) || "*".equals(text)) {
|
if (text == null || text.isEmpty() || "*".equals(text)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class HSLFFontInfo implements FontInfo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTypeface(String typeface){
|
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");
|
throw new IllegalArgumentException("typeface can't be null nor empty");
|
||||||
}
|
}
|
||||||
this.typeface = typeface;
|
this.typeface = typeface;
|
||||||
|
@ -323,7 +323,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = name.replace("adj", "");
|
name = name.replace("adj", "");
|
||||||
if ("".equals(name)) {
|
if (name.isEmpty()) {
|
||||||
name = "1";
|
name = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,4 +727,4 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
protected void setHyperlink(HSLFHyperlink link) {
|
protected void setHyperlink(HSLFHyperlink link) {
|
||||||
_hyperlink = link;
|
_hyperlink = link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user