fix forbidden apis issues

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1719778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-12-13 09:51:22 +00:00
parent ad89fdcaf5
commit 3e8b58e356
4 changed files with 32 additions and 14 deletions

View File

@ -46,7 +46,7 @@ public class ExcelGeneralNumberFormat extends Format {
private final DecimalFormat scientificFormat;
public ExcelGeneralNumberFormat(final Locale locale) {
decimalSymbols = new DecimalFormatSymbols(locale);
decimalSymbols = DecimalFormatSymbols.getInstance(locale);
scientificFormat = new DecimalFormat("0.#####E0", decimalSymbols);
DataFormatter.setExcelStyleRoundingMode(scientificFormat);
integerFormat = new DecimalFormat("#", decimalSymbols);

View File

@ -30,8 +30,8 @@ java.util.Date#toString() @ Do not use methods that depend on the current Local,
java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[], boolean) @ Reflection usage fails with SecurityManagers and likely will not work any more in Java 9
java.lang.reflect.AccessibleObject#setAccessible(boolean) @ Reflection usage fails with SecurityManagers and likely will not work any more in Java 9
java.text.DecimalFormatSymbols#DecimalFormatSymbols() @ use DecimalFormatSymbols.getInstance()
java.text.DecimalFormatSymbols#DecimalFormatSymbols(Locale) @ use DecimalFormatSymbols.getInstance()
java.text.DecimalFormatSymbols#<init>() @ use DecimalFormatSymbols.getInstance()
java.text.DecimalFormatSymbols#<init>(java.util.Locale) @ use DecimalFormatSymbols.getInstance()
# the following are taken from the Elasticsearch source at https://github.com/elastic/elasticsearch/tree/master/buildSrc/src/main/resources/forbidden

View File

@ -17,6 +17,8 @@
package org.apache.poi.hslf.model.textproperties;
import java.util.Locale;
/**
* Definition of a property of some text, or its paragraph. Defines
* how to find out if it's present (via the mask on the paragraph or
@ -111,16 +113,32 @@ public class TextProp implements Cloneable {
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
TextProp other = (TextProp) obj;
if (dataValue != other.dataValue) return false;
if (maskInHeader != other.maskInHeader) return false;
if (dataValue != other.dataValue) {
return false;
}
if (maskInHeader != other.maskInHeader) {
return false;
}
if (propName == null) {
if (other.propName != null) return false;
} else if (!propName.equals(other.propName)) return false;
if (sizeOfDataBlock != other.sizeOfDataBlock) return false;
if (other.propName != null) {
return false;
}
} else if (!propName.equals(other.propName)) {
return false;
}
if (sizeOfDataBlock != other.sizeOfDataBlock) {
return false;
}
return true;
}
@ -132,6 +150,6 @@ public class TextProp implements Cloneable {
case 2: len = 6; break;
default: len = 10; break;
}
return String.format("%s = %d (%0#"+len+"X mask / %d bytes)", propName, dataValue, maskInHeader, sizeOfDataBlock);
return String.format(Locale.ROOT, "%s = %d (%0#"+len+"X mask / %d bytes)", propName, dataValue, maskInHeader, sizeOfDataBlock);
}
}

View File

@ -290,7 +290,7 @@ public final class TestHSSFDataFormatter {
HSSFCell cell = (HSSFCell) it.next();
log(formatter.formatCellValue(cell));
// in some locales the the decimal delimiter is a comma, not a dot
char decimalSeparator = new DecimalFormatSymbols(LocaleUtil.getUserLocale()).getDecimalSeparator();
char decimalSeparator = DecimalFormatSymbols.getInstance(LocaleUtil.getUserLocale()).getDecimalSeparator();
assertEquals("12345678" + decimalSeparator + "9", formatter.formatCellValue(cell));
}
@ -336,7 +336,7 @@ public final class TestHSSFDataFormatter {
// now with a formula evaluator
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
log(formatter.formatCellValue(cell, evaluator) + "\t\t\t (with evaluator)");
char decimalSeparator = new DecimalFormatSymbols(LocaleUtil.getUserLocale()).getDecimalSeparator();
char decimalSeparator = DecimalFormatSymbols.getInstance(LocaleUtil.getUserLocale()).getDecimalSeparator();
assertEquals("24" + decimalSeparator + "50%", formatter.formatCellValue(cell,evaluator));
}