diff --git a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java index a7ef6d2ba..a9099f575 100644 --- a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java @@ -387,7 +387,7 @@ public class AddDimensionedImage { if( sURL.endsWith(".png") ) { imageType = Workbook.PICTURE_TYPE_PNG; } - else if( sURL.endsWith("jpg") || sURL.endsWith(".jpeg") ) { + else if( sURL.endsWith(".jpg") || sURL.endsWith(".jpeg") ) { imageType = Workbook.PICTURE_TYPE_JPEG; } else { diff --git a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java index a0da336d7..ad3be2fb4 100644 --- a/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java +++ b/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java @@ -69,7 +69,9 @@ public final class AnalysisToolPak implements UDFFinder { public FreeRefFunction findFunction(String name) { // functions that are available in Excel 2007+ have a prefix _xlfn. // if you save such a .xlsx workbook as .xls - if(name.startsWith("_xlfn.")) name = name.substring(6); + final String prefix = "_xlfn."; + // case-sensitive + if(name.startsWith(prefix)) name = name.substring(prefix.length()); // FIXME: inconsistent case-sensitivity return _functionsByName.get(name.toUpperCase(Locale.ROOT)); diff --git a/src/java/org/apache/poi/ss/util/CellReference.java b/src/java/org/apache/poi/ss/util/CellReference.java index 6adc53007..c07ee5bf9 100644 --- a/src/java/org/apache/poi/ss/util/CellReference.java +++ b/src/java/org/apache/poi/ss/util/CellReference.java @@ -17,6 +17,8 @@ package org.apache.poi.ss.util; +import static org.apache.poi.util.StringUtil.endsWithIgnoreCase; + import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -104,7 +106,7 @@ public class CellReference { * delimited and escaped as per normal syntax rules for formulas. */ public CellReference(String cellRef) { - if(cellRef.toUpperCase(Locale.ROOT).endsWith("#REF!")) { + if(endsWithIgnoreCase(cellRef, "#REF!")) { throw new IllegalArgumentException("Cell reference invalid: " + cellRef); } diff --git a/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java b/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java index 960c9799e..00b82d07a 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java @@ -16,6 +16,8 @@ ==================================================================== */ package org.apache.poi.hsmf.extractor; +import static org.apache.poi.util.StringUtil.startsWithIgnoreCase; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -130,7 +132,7 @@ public class OutlookTextExtactor extends POIOLE2TextExtractor { // Failing that try via the raw headers String[] headers = msg.getHeaders(); for(String header: headers) { - if(header.toLowerCase(Locale.ROOT).startsWith("date:")) { + if(startsWithIgnoreCase(header, "date:")) { s.append( "Date:" + header.substring(header.indexOf(':')+1) +