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:
parent
b919ad9989
commit
ca0154a793
@ -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 {
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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) +
|
||||
|
Loading…
Reference in New Issue
Block a user