poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1777031 - in /poi/trunk/src: examples/src/org/apache/poi/ss/examples/ java/org/apache/poi/ss/formula/atp/ java/org/apache/poi/ss/util/ scratchpad/src/org/apache/poi/hsmf/extractor/
Date Mon, 02 Jan 2017 22:23:56 GMT
Author: onealj
Date: Mon Jan  2 22:23:56 2017
New Revision: 1777031

URL: http://svn.apache.org/viewvc?rev=1777031&view=rev
Log:
use case-insensitive string startsWith/endsWith utility function

Modified:
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
    poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
    poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java

Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java?rev=1777031&r1=1777030&r2=1777031&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java Mon Jan
 2 22:23:56 2017
@@ -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  {

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java?rev=1777031&r1=1777030&r2=1777031&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java Mon Jan  2 22:23:56
2017
@@ -69,7 +69,9 @@ public final class AnalysisToolPak imple
     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));

Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java?rev=1777031&r1=1777030&r2=1777031&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java Mon Jan  2 22:23:56 2017
@@ -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);
         }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java?rev=1777031&r1=1777030&r2=1777031&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java Mon
Jan  2 22:23:56 2017
@@ -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
             // 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) +



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message