aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-09-01 19:06:53 +0000
committerNick Burch <nick@apache.org>2015-09-01 19:06:53 +0000
commit6b67b0b1e0b4d9866b658cbbbb069b268ec249a7 (patch)
tree0eddd00c854ae462e1a8213d48dedfb506226d02 /src
parent1c21c4efc65d7d16879ae90382b9d1f5bd9d8b8d (diff)
downloadpoi-6b67b0b1e0b4d9866b658cbbbb069b268ec249a7.tar.gz
poi-6b67b0b1e0b4d9866b658cbbbb069b268ec249a7.zip
Fix some Forbidden APIs errors
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700644 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java5
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java5
-rw-r--r--src/java/org/apache/poi/ss/formula/functions/Dec2Hex.java4
-rw-r--r--src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java2
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java4
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java11
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java3
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java3
11 files changed, 34 insertions, 21 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
index 3cc124b67b..cc8ed41307 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel.examples;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.Locale;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@@ -198,7 +199,7 @@ public final class HSSFReadWrite {
}
}
} else if (args.length == 2) {
- if (args[1].toLowerCase().equals("write")) {
+ if (args[1].toLowerCase(Locale.ROOT).equals("write")) {
System.out.println("Write mode");
long time = System.currentTimeMillis();
HSSFReadWrite.testCreateSampleSheet(fileName);
@@ -213,7 +214,7 @@ public final class HSSFReadWrite {
wb.write(stream);
stream.close();
}
- } else if (args.length == 3 && args[2].toLowerCase().equals("modify1")) {
+ } else if (args.length == 3 && args[2].toLowerCase(Locale.ROOT).equals("modify1")) {
// delete row 0-24, row 74 - 99 && change cell 3 on row 39 to string "MODIFIED CELL!!"
HSSFWorkbook wb = HSSFReadWrite.readFile(fileName);
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 6eb493ca92..b4d80420ab 100644
--- a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
+++ b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
@@ -23,6 +23,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
+import java.util.Locale;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -382,7 +383,7 @@ public class AddDimensionedImage {
// the image files location is identified by interrogating the URL passed
// to the method, the images type is identified before it is added to the
// sheet.
- String sURL = imageFile.toString().toLowerCase();
+ String sURL = imageFile.toString().toLowerCase(Locale.ROOT);
if( sURL.endsWith(".png") ) {
imageType = Workbook.PICTURE_TYPE_PNG;
}
@@ -1043,4 +1044,4 @@ public class AddDimensionedImage {
return points / 72D * 25.4;
}
}
-} \ No newline at end of file
+}
diff --git a/src/java/org/apache/poi/ss/formula/functions/Dec2Hex.java b/src/java/org/apache/poi/ss/formula/functions/Dec2Hex.java
index 62462b029d..8bae27b8ac 100644
--- a/src/java/org/apache/poi/ss/formula/functions/Dec2Hex.java
+++ b/src/java/org/apache/poi/ss/formula/functions/Dec2Hex.java
@@ -17,6 +17,8 @@
package org.apache.poi.ss.formula.functions;
+import java.util.Locale;
+
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*;
@@ -119,7 +121,7 @@ public final class Dec2Hex extends Var1or2ArgFunction implements FreeRefFunction
hex = "FF"+ hex.substring(2);
}
- return new StringEval(hex.toUpperCase());
+ return new StringEval(hex.toUpperCase(Locale.ROOT));
}
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) {
diff --git a/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java b/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java
index 6efd260663..c3ae444876 100644
--- a/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java
+++ b/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java
@@ -142,7 +142,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg {
* @return the standard worksheet function index if found, otherwise <tt>FUNCTION_INDEX_EXTERNAL</tt>
*/
protected static short lookupIndex(String name) {
- short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase());
+ short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase(Locale.ROOT));
if (ix < 0) {
return FUNCTION_INDEX_EXTERNAL;
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java
index 3754ce8a9a..805a5172a1 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java
@@ -17,6 +17,8 @@
package org.apache.poi.openxml4j.opc;
+import java.util.Locale;
+
/**
* Open Packaging Convention content types (see Annex F : Standard Namespaces
* and Content Types).
@@ -110,7 +112,7 @@ public final class ContentTypes {
public static String getContentTypeFromFileExtension(String filename) {
String extension = filename.substring(filename.lastIndexOf(".") + 1)
- .toLowerCase();
+ .toLowerCase(Locale.ROOT);
if (extension.equals(EXTENSION_JPG_1)
|| extension.equals(EXTENSION_JPG_2))
return IMAGE_JPEG;
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java
index 9ac6941bc6..78a18e269d 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java
@@ -20,6 +20,7 @@ package org.apache.poi.openxml4j.opc;
import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Locale;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
@@ -479,9 +480,9 @@ public final class PackagePartName implements Comparable<PackagePartName> {
public boolean equals(Object other) {
if (other instanceof PackagePartName) {
// String.equals() is compatible with our compareTo(), but cheaper
- return this.partNameURI.toASCIIString().toLowerCase().equals
+ return this.partNameURI.toASCIIString().toLowerCase(Locale.ROOT).equals
(
- ((PackagePartName) other).partNameURI.toASCIIString().toLowerCase()
+ ((PackagePartName) other).partNameURI.toASCIIString().toLowerCase(Locale.ROOT)
);
} else {
return false;
@@ -490,7 +491,7 @@ public final class PackagePartName implements Comparable<PackagePartName> {
@Override
public int hashCode() {
- return this.partNameURI.toASCIIString().toLowerCase().hashCode();
+ return this.partNameURI.toASCIIString().toLowerCase(Locale.ROOT).hashCode();
}
@Override
@@ -543,8 +544,8 @@ public final class PackagePartName implements Comparable<PackagePartName> {
return compare
(
- obj1.getURI().toASCIIString().toLowerCase(),
- obj2.getURI().toASCIIString().toLowerCase()
+ obj1.getURI().toASCIIString().toLowerCase(Locale.ROOT),
+ obj2.getURI().toASCIIString().toLowerCase(Locale.ROOT)
);
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
index 08d82fbaab..aed9bacb15 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
@@ -20,6 +20,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.Locale;
import java.util.TreeMap;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -343,7 +344,7 @@ public final class PackageRelationshipCollection implements
Attr targetModeAttr = element.getAttributeNode(PackageRelationship.TARGET_MODE_ATTRIBUTE_NAME);
TargetMode targetMode = TargetMode.INTERNAL;
if (targetModeAttr != null) {
- targetMode = targetModeAttr.getValue().toLowerCase()
+ targetMode = targetModeAttr.getValue().toLowerCase(Locale.ROOT)
.equals("internal") ? TargetMode.INTERNAL
: TargetMode.EXTERNAL;
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
index 423485856f..eb569e3a88 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Locale;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -150,7 +151,7 @@ public abstract class ContentTypeManager {
*/
public void addContentType(PackagePartName partName, String contentType) {
boolean defaultCTExists = this.defaultContentType.containsValue(contentType);
- String extension = partName.getExtension().toLowerCase();
+ String extension = partName.getExtension().toLowerCase(Locale.ROOT);
if ((extension.length() == 0)
|| (this.defaultContentType.containsKey(extension) && !defaultCTExists))
this.addOverrideContentType(partName, contentType);
@@ -184,7 +185,7 @@ public abstract class ContentTypeManager {
private void addDefaultContentType(String extension, String contentType) {
// Remark : Originally the latest parameter was :
// contentType.toLowerCase(). Change due to a request ID 1996748.
- defaultContentType.put(extension.toLowerCase(), contentType);
+ defaultContentType.put(extension.toLowerCase(Locale.ROOT), contentType);
}
/**
@@ -327,7 +328,7 @@ public abstract class ContentTypeManager {
&& this.overrideContentType.containsKey(partName))
return this.overrideContentType.get(partName);
- String extension = partName.getExtension().toLowerCase();
+ String extension = partName.getExtension().toLowerCase(Locale.ROOT);
if (this.defaultContentType.containsKey(extension))
return this.defaultContentType.get(extension);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java
index fb430d17d4..b867dc1099 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestThemesTable.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.FileOutputStream;
import java.util.LinkedHashMap;
+import java.util.Locale;
import java.util.Map;
import org.apache.commons.codec.binary.Hex;
@@ -104,7 +105,7 @@ public class TestThemesTable {
ThemeElement themeElem = ThemeElement.byId(expectedThemeIdx);
assertEquals(
"Wrong theme at " + ref + " in " + whatWorkbook,
- themeElem.name.toLowerCase(), cell.getStringCellValue());
+ themeElem.name.toLowerCase(Locale.ROOT), cell.getStringCellValue());
// Fonts are theme-based in their colours
XSSFFont font = cell.getCellStyle().getFont();
@@ -235,7 +236,8 @@ public class TestThemesTable {
}
private static void assertCellContents(String expected, XSSFCell cell) {
assertNotNull(cell);
- assertEquals(expected.toLowerCase(), cell.getStringCellValue().toLowerCase());
+ assertEquals(expected.toLowerCase(Locale.ROOT),
+ cell.getStringCellValue().toLowerCase(Locale.ROOT));
}
@Test
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
index 48330bbeeb..060b1e4d3f 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
@@ -18,6 +18,7 @@
package org.apache.poi.xwpf.extractor;
import java.io.IOException;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -349,7 +350,7 @@ public class TestXWPFWordExtractor extends TestCase {
"endnote_sdt"
};
XWPFWordExtractor ex = new XWPFWordExtractor(doc);
- String s = ex.getText().toLowerCase();
+ String s = ex.getText().toLowerCase(Locale.ROOT);
int hits = 0;
for (String targ : targs) {
@@ -371,7 +372,7 @@ public class TestXWPFWordExtractor extends TestCase {
"test user\n",
};
ex = new XWPFWordExtractor(doc);
- s = ex.getText().toLowerCase();
+ s = ex.getText().toLowerCase(Locale.ROOT);
//At one point in development there were three copies of the text.
//This ensures that there is only one copy.
diff --git a/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java b/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java
index 48c65895cf..677d9a7b1c 100644
--- a/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java
+++ b/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -65,7 +66,7 @@ public abstract class BaseXLSIteratingTest {
String[] files = new File(dir).list(new FilenameFilter() {
@Override
public boolean accept(File arg0, String arg1) {
- return arg1.toLowerCase().endsWith(".xls");
+ return arg1.toLowerCase(Locale.ROOT).endsWith(".xls");
}
});