]> source.dussan.org Git - poi.git/commitdiff
Fix some Forbidden APIs errors
authorNick Burch <nick@apache.org>
Tue, 1 Sep 2015 21:09:20 +0000 (21:09 +0000)
committerNick Burch <nick@apache.org>
Tue, 1 Sep 2015 21:09:20 +0000 (21:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700670 13f79535-47bb-0310-9956-ffa450edef68

21 files changed:
src/examples/src/org/apache/poi/poifs/poibrowser/Codec.java
src/examples/src/org/apache/poi/ss/examples/formula/SettingExternalFunction.java
src/java/org/apache/poi/ss/formula/FormulaParser.java
src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
src/java/org/apache/poi/ss/formula/functions/TextFunction.java
src/java/org/apache/poi/ss/formula/udf/DefaultUDFFinder.java
src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPaswordHelper.java
src/scratchpad/src/org/apache/poi/hdf/extractor/util/NumberFormatter.java
src/scratchpad/src/org/apache/poi/hdf/model/util/NumberFormatter.java
src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowDumper.java
src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunk.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java
src/scratchpad/src/org/apache/poi/hwpf/converter/NumberFormatter.java
src/testcases/org/apache/poi/hpsf/basic/TestClassID.java
src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java
src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java
src/testcases/org/apache/poi/ss/util/NumberRenderingSpreadsheetGenerator.java
src/testcases/org/apache/poi/ss/util/NumberToTextConversionExamples.java
src/testcases/org/apache/poi/ss/util/TestNumberToTextConverter.java

index 2660f5cc67831a6d7be04aeabf5b3d171aefd220..76ffe3daf0f38c8cca99fd0ab799f03bc24bfcea 100644 (file)
@@ -20,11 +20,10 @@ package org.apache.poi.poifs.poibrowser;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.util.Locale;
 
 import org.apache.poi.hpsf.ClassID;
 
-
-
 /**
  * <p>Provides utility methods for encoding and decoding hexadecimal
  * data.</p>
@@ -181,7 +180,7 @@ public class Codec
                 ("String has odd length " + length);
         byte[] b = new byte[length / 2];
         char[] c = new char[length];
-        s.toUpperCase().getChars(0, length, c, 0);
+        s.toUpperCase(Locale.ROOT).getChars(0, length, c, 0);
         for (int i = 0; i < length; i += 2)
             b[i/2] = (byte) (decodeNibble(c[i]) << 4 & 0xF0 |
                              decodeNibble(c[i+1])    & 0x0F);
index 17f4e0dfa84d0eb9647857f24aefd5f03985fbc5..ae7079436876b00c7e9ef572f82ca710391f5605 100644 (file)
@@ -32,6 +32,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.util.HashMap;\r
+import java.util.Locale;\r
 import java.util.Map;\r
 \r
 /**\r
@@ -66,7 +67,7 @@ public class SettingExternalFunction {
         }\r
 \r
         public FreeRefFunction findFunction(String name) {\r
-            return _functionsByName.get(name.toUpperCase());\r
+            return _functionsByName.get(name.toUpperCase(Locale.ROOT));\r
         }\r
 \r
     }\r
index 53f2dd2f9d39b72b6aeabd3fd66b9bc74bde5b46..18981ec725db27647aefc8446a2c59f5f763de3f 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 import java.util.regex.Pattern;
 
 import org.apache.poi.ss.SpreadsheetVersion;
@@ -907,7 +908,7 @@ public final class FormulaParser {
                         * (b) LOG10 + 1
                         * In (a) LOG10 is a name of a built-in function. In (b) LOG10 is a cell reference
                         */
-                       boolean isFunc = FunctionMetadataRegistry.getFunctionByName(str.toUpperCase()) != null;
+                       boolean isFunc = FunctionMetadataRegistry.getFunctionByName(str.toUpperCase(Locale.ROOT)) != null;
                        if(isFunc){
                                int savePointer = _pointer;
                                resetPointer(_pointer + str.length());
@@ -974,7 +975,7 @@ public final class FormulaParser {
         */
        private ParseNode getFunction(String name, Ptg namePtg, ParseNode[] args) {
 
-               FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
+               FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase(Locale.ROOT));
                int numArgs = args.length;
                if(fm == null) {
                        if (namePtg == null) {
@@ -1313,7 +1314,7 @@ public final class FormulaParser {
 
        private int parseErrorLiteral() {
                Match('#');
-               String part1 = parseUnquotedIdentifier().toUpperCase();
+               String part1 = parseUnquotedIdentifier().toUpperCase(Locale.ROOT);
                if (part1 == null) {
                        throw expected("remainder of error constant literal");
                }
index 66ca17ddd507f3cfd8a5dc19b94587ff573f80c5..2aebf41f432df65c2370e2af61921b7092466164 100644 (file)
@@ -13,6 +13,7 @@ package org.apache.poi.ss.formula.atp;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.TreeSet;
 
@@ -70,7 +71,7 @@ public final class AnalysisToolPak implements UDFFinder {
         // if you save such a .xlsx workbook as .xls
         if(name.startsWith("_xlfn.")) name = name.substring(6);
 
-        return _functionsByName.get(name.toUpperCase());
+        return _functionsByName.get(name.toUpperCase(Locale.ROOT));
     }
 
     private Map<String, FreeRefFunction> createFunctionsMap() {
index eddd7aaa458a0005ef8beace1c0449b10e6da048..76c5fa1bae121875a0736789298e59aa8c41e568 100644 (file)
@@ -368,7 +368,8 @@ public abstract class TextFunction implements Function {
                        if (_isCaseSensitive) {
                                result = haystack.indexOf(needle, startIndex);
                        } else {
-                               result = haystack.toUpperCase().indexOf(needle.toUpperCase(), startIndex);
+                               result = haystack.toUpperCase(Locale.ROOT)
+                       .indexOf(needle.toUpperCase(Locale.ROOT), startIndex);
                        }
                        if (result == -1) {
                                return ErrorEval.VALUE_INVALID;
index b1ad37f8ae6e6d34afa2bc6010a961d5351d3007..724b2657323b2f7cf7db80d869d3c91287196617 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.ss.formula.udf;
 
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.poi.ss.formula.functions.FreeRefFunction;
@@ -38,12 +39,12 @@ public final class DefaultUDFFinder implements UDFFinder {
                }
                HashMap<String, FreeRefFunction> m = new HashMap<String, FreeRefFunction>(nFuncs * 3 / 2);
                for (int i = 0; i < functionImpls.length; i++) {
-                       m.put(functionNames[i].toUpperCase(), functionImpls[i]);
+                       m.put(functionNames[i].toUpperCase(Locale.ROOT), functionImpls[i]);
                }
                _functionsByName = m;
        }
 
        public FreeRefFunction findFunction(String name) {
-               return _functionsByName.get(name.toUpperCase());
+               return _functionsByName.get(name.toUpperCase(Locale.ROOT));
        }
 }
index c887129b6974bd4ee30aa2beab1cd4bda98bfdb9..c910499485aae5a2f2fbdbf45627c836d18b8d8f 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.poi.xssf.usermodel.helpers;
 \r
 import java.security.SecureRandom;\r
 import java.util.Arrays;\r
+import java.util.Locale;\r
 \r
 import javax.xml.bind.DatatypeConverter;\r
 import javax.xml.namespace.QName;\r
@@ -54,7 +55,8 @@ public class XSSFPaswordHelper {
         cur.toFirstContentToken();\r
         if (hashAlgo == null) {\r
             int hash = CryptoFunctions.createXorVerifier1(password);\r
-            cur.insertAttributeWithValue(getAttrName(prefix, "password"), Integer.toHexString(hash).toUpperCase());\r
+            cur.insertAttributeWithValue(getAttrName(prefix, "password"), \r
+                                         Integer.toHexString(hash).toUpperCase(Locale.ROOT));\r
         } else {\r
             SecureRandom random = new SecureRandom(); \r
             byte salt[] = random.generateSeed(16);\r
index dd383acc9981ee31d21972a1c99dab03e2794af7..29ec0d71ce0d7b4960ae97c9a35cfd2520c0937f 100644 (file)
 
 package org.apache.poi.hdf.extractor.util;
 
+import java.util.Locale;
 
 /**
- * Comment me
- *
- * @author Ryan Ackley
+ * TODO Comment me
  */
 @Deprecated
 public final class NumberFormatter
@@ -68,11 +67,11 @@ public final class NumberFormatter
       case ARABIC:
         return _arabic[num - 1];
       case UPPER_ROMAN:
-        return _roman[num-1].toUpperCase();
+        return _roman[num-1].toUpperCase(Locale.ROOT);
       case LOWER_ROMAN:
         return _roman[num-1];
       case UPPER_LETTER:
-        return _letter[num-1].toUpperCase();
+        return _letter[num-1].toUpperCase(Locale.ROOT);
       case LOWER_LETTER:
         return _letter[num-1];
       case ORDINAL:
index 981c4b29c01ab30a6e975db9bcd953c0fcd7e344..eac3b2df9c55de8804ae78569511dacd899517ee 100644 (file)
 
 package org.apache.poi.hdf.model.util;
 
+import java.util.Locale;
 
 /**
- * Comment me
- *
- * @author Ryan Ackley
+ * TODO Comment me
  */
 @Deprecated
 public final class NumberFormatter
@@ -68,11 +67,11 @@ public final class NumberFormatter
       case ARABIC:
         return _arabic[num - 1];
       case UPPER_ROMAN:
-        return _roman[num-1].toUpperCase();
+        return _roman[num-1].toUpperCase(Locale.ROOT);
       case LOWER_ROMAN:
         return _roman[num-1];
       case UPPER_LETTER:
-        return _letter[num-1].toUpperCase();
+        return _letter[num-1].toUpperCase(Locale.ROOT);
       case LOWER_LETTER:
         return _letter[num-1];
       case ORDINAL:
index e098d4083f6371c92af81f00a84cb05c9b3dc04a..298731450806911a101c66b9a3d98ec47c03e856 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.hslf.dev;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Locale;
 
 import org.apache.poi.ddf.DefaultEscherRecordFactory;
 import org.apache.poi.ddf.EscherContainerRecord;
@@ -192,12 +193,12 @@ public final class SlideShowDumper {
 }
 
 public String makeHex(short s) {
-       String hex = Integer.toHexString(s).toUpperCase();
+       String hex = Integer.toHexString(s).toUpperCase(Locale.ROOT);
        if(hex.length() == 1) { return "0" + hex; }
        return hex;
 }
 public String makeHex(int i) {
-       String hex = Integer.toHexString(i).toUpperCase();
+       String hex = Integer.toHexString(i).toUpperCase(Locale.ROOT);
        if(hex.length() == 1) { return "000" + hex; }
        if(hex.length() == 2) { return "00" + hex; }
        if(hex.length() == 3) { return "0" + hex; }
index fc96644b2b329a6feae4be27267ee6e305c6513c..952426f53da7d85153e5e64f5abfe999d83ba0cf 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.hslf.dev;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.Locale;
 
 import org.apache.poi.hslf.record.Record;
 import org.apache.poi.util.HexDump;
@@ -109,7 +110,7 @@ public final class SlideShowRecordDumper {
   }
 
   public String makeHex(int number, int padding) {
-       String hex = Integer.toHexString(number).toUpperCase();
+       String hex = Integer.toHexString(number).toUpperCase(Locale.ROOT);
        while(hex.length() < padding) {
                hex = "0" + hex;
        }
index 24c8108222a0f367e31eeb9a9e7c1d7347135ec4..b6ef90d5a812d0e1cffc24010e4af4175385f21f 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.hsmf.datatypes;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Locale;
 
 import org.apache.poi.hsmf.datatypes.Types.MAPIType;
 
@@ -62,7 +63,8 @@ public abstract class Chunk {
        String chunkId = Integer.toHexString(this.chunkId);
        while(chunkId.length() < 4) chunkId = "0" + chunkId;
 
-       return this.namePrefix + chunkId.toUpperCase() + type.toUpperCase();
+       return this.namePrefix + chunkId.toUpperCase(Locale.ROOT)
+              + type.toUpperCase(Locale.ROOT);
    }
 
    /**
index 4ce85eee3cbc65f5b35d99868a808730f682e527..dc1e87f23341f1263b467f8e4f99dd837a17d2b6 100644 (file)
@@ -30,6 +30,7 @@ import static org.apache.poi.hsmf.datatypes.Types.TIME;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.poi.hsmf.datatypes.Types.MAPIType;
@@ -1060,7 +1061,7 @@ public class MAPIProperty {
    }
    
    public String asFileName() {
-      String str = Integer.toHexString(id).toUpperCase();
+      String str = Integer.toHexString(id).toUpperCase(Locale.ROOT);
       while(str.length() < 4) {
          str = "0" + str;
       }
index ab064b51b87c313d5b1ad9a7bc42e54105a71155..4716cc1c33b4d8d663e805956021ffe9901e7512 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.hsmf.datatypes;
 
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 /**
@@ -138,7 +139,7 @@ public final class Types {
    }
 
    public static String asFileEnding(int type) {
-      String str = Integer.toHexString(type).toUpperCase();
+      String str = Integer.toHexString(type).toUpperCase(Locale.ROOT);
       while(str.length() < 4) {
          str = "0" + str;
       }
index 42a72a9d945b0e998527e6f30cc320163637302f..9e4031751de06bddbcecc5939a106e517e7063b4 100644 (file)
@@ -19,6 +19,8 @@
 
 package org.apache.poi.hwpf.converter;
 
+import java.util.Locale;
+
 import org.apache.poi.util.Beta;
 
 /**
@@ -52,11 +54,11 @@ public final class NumberFormatter
         switch ( style )
         {
         case T_UPPER_ROMAN:
-            return toRoman( num ).toUpperCase();
+            return toRoman( num ).toUpperCase(Locale.ROOT);
         case T_LOWER_ROMAN:
             return toRoman( num );
         case T_UPPER_LETTER:
-            return toLetters( num ).toUpperCase();
+            return toLetters( num ).toUpperCase(Locale.ROOT);
         case T_LOWER_LETTER:
             return toLetters( num );
         case T_ARABIC:
index b908c933a20ddbaca62ef097ee707c3f3aa20761..ed79510f40c11285b7dd14de8ddec3ad0d106508 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.hpsf.basic;
 
+import java.util.Locale;
+
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
@@ -115,7 +117,7 @@ public final class TestClassID extends TestCase {
                           0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}
             , 0
         );
-        Assert.assertEquals(clsidTest.toString().toUpperCase(),
+        Assert.assertEquals(clsidTest.toString().toUpperCase(Locale.ROOT),
                             "{04030201-0605-0807-090A-0B0C0D0E0F10}"
         );
     }
index fbbe0efdbd506cd7a4b00a5a8c00e9095f239a19..7bfab924935ac2bf26234b45d10baf53633ffbb1 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.eval;
 
 import java.io.PrintStream;
 import java.util.Collection;
+import java.util.Locale;
 
 import junit.framework.Assert;
 import junit.framework.AssertionFailedError;
@@ -211,7 +212,7 @@ public final class TestFormulasFromSpreadsheet extends TestCase {
                                        default:
                                                throw new RuntimeException("unexpected result");
                                        case Result.NO_EVALUATIONS_FOUND: // do nothing
-                        String uname = targetFunctionName.toUpperCase();
+                        String uname = targetFunctionName.toUpperCase(Locale.ROOT);
                         if(startRowIndex >= SS.START_FUNCTIONS_ROW_INDEX &&
                                 funcs.contains(uname)) {
                             logger.log(POILogger.WARN, uname + ": function is supported but missing test data");
index a3e810474d3bead3b77dc85725d9fbab39f2bcf9..9e52a4efd7598be35ab15bdcba2bf8c8782446d4 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.eval;
 
 import java.io.PrintStream;
 import java.util.Collection;
+import java.util.Locale;
 
 import junit.framework.Assert;
 import junit.framework.AssertionFailedError;
@@ -201,7 +202,7 @@ public final class TestMultiSheetEval extends TestCase {
                                                default:
                                                        throw new RuntimeException("unexpected result");
                                                case Result.NO_EVALUATIONS_FOUND: // do nothing
-                                                       String uname = targetFunctionName.toUpperCase();
+                                                       String uname = targetFunctionName.toUpperCase(Locale.ROOT);
                                                        if(startRowIndex >= SS.START_FUNCTIONS_ROW_INDEX &&
                                                                        funcs.contains(uname)) {
                                                                logger.log(POILogger.WARN, uname + ": function is supported but missing test data");
index c074c97379dd91050f348429360172ebee739abf..408028d667729a9e775363793b19e1c9709622f7 100644 (file)
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@@ -229,7 +230,7 @@ public class NumberRenderingSpreadsheetGenerator {
                } catch (IOException e) {
                        throw new RuntimeException(e);
                }
-               return "0x" + Long.toHexString(l).toUpperCase();
+               return "0x" + Long.toHexString(l).toUpperCase(Locale.ROOT);
        }
 
        private static boolean isNaNBytes(byte[] fileContent, int offset) {
index 91f9c4142956beb06f5eb04fbffc420acb9bec70..1dcedc97a2ce39e3d3cba92efbac7365f25a099e 100644 (file)
 ==================================================================== */
 
 package org.apache.poi.ss.util;
+
+import java.util.Locale;
+
 /**
  * Contains specific examples of <tt>double</tt> values and their rendering in Excel.
- *
- * @author Josh Micich
  */
 final class NumberToTextConversionExamples {
 
@@ -62,7 +63,7 @@ final class NumberToTextConversionExamples {
                        _doubleValue = d;
                }
                private static String doubleToHexString(double d) {
-                       return "0x" + Long.toHexString(Double.doubleToLongBits(d)).toUpperCase() + "L";
+                       return "0x" + Long.toHexString(Double.doubleToLongBits(d)).toUpperCase(Locale.ROOT) + "L";
                }
                public String getJavaRendering() {
                        return _javaRendering;
index 48fe7a3f8644c19962c06ec51c084106e72fc3ce..f33ece477f7bc6b91c24dff97ff0fe68721dee08 100644 (file)
@@ -21,6 +21,8 @@ import junit.framework.AssertionFailedError;
 import junit.framework.ComparisonFailure;
 import junit.framework.TestCase;
 
+import java.util.Locale;
+
 import org.apache.poi.hssf.record.FormulaRecord;
 import org.apache.poi.ss.formula.constant.ConstantValueParser;
 import org.apache.poi.ss.formula.ptg.NumberPtg;
@@ -74,7 +76,7 @@ public final class TestNumberToTextConverter extends TestCase {
        }
 
        private static String formatExample(ExampleConversion example) {
-               String hexLong = Long.toHexString(example.getRawDoubleBits()).toUpperCase();
+               String hexLong = Long.toHexString(example.getRawDoubleBits()).toUpperCase(Locale.ROOT);
                String longRep = "0x" + "0000000000000000".substring(hexLong.length()) + hexLong+ "L";  
                return "ec(" + longRep + ", \"" + example.getJavaRendering() + "\", \"" + example.getExcelRendering() + "\")";
        }