use case-insensitive string startsWith/endsWith utility function

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1777031 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-01-02 22:23:56 +00:00
parent b919ad9989
commit ca0154a793
4 changed files with 10 additions and 4 deletions

View File

@ -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 {

View File

@ -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));

View File

@ -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);
}

View File

@ -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) +