findbugs fixes

changed UDFFinder to abstract class and moved DEFAULT constant to factory method

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-06-12 00:12:22 +00:00
parent 6da9c4514d
commit e425cd4f14
24 changed files with 126 additions and 131 deletions

View File

@ -48,7 +48,7 @@ public class SettingExternalFunction {
/**
* wrap external functions in a plugin
*/
public static class BloombergAddIn implements UDFFinder {
public static class BloombergAddIn extends UDFFinder {
private final Map<String, FreeRefFunction> _functionsByName;
public BloombergAddIn() {
@ -89,6 +89,7 @@ public class SettingExternalFunction {
wb.write(out);
out.close();
wb.close();
}
}

View File

@ -165,7 +165,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
_complexData = new byte[0];
} else {
short numElements = LittleEndian.getShort(data, offset);
LittleEndian.getShort(data, offset + 2); // numReserved
// LittleEndian.getShort(data, offset + 2); // numReserved
short sizeOfElements = LittleEndian.getShort(data, offset + 4);
int arraySize = getActualSizeOfElements(sizeOfElements) * numElements;

View File

@ -181,7 +181,7 @@ public class EscherColorRef {
}
public void setSysIndexFlag(boolean flag) {
FLAG_SYS_INDEX.setBoolean(colorRef, flag);
colorRef = FLAG_SYS_INDEX.setBoolean(colorRef, flag);
}
public boolean hasSchemeIndexFlag() {
@ -189,7 +189,7 @@ public class EscherColorRef {
}
public void setSchemeIndexFlag(boolean flag) {
FLAG_SCHEME_INDEX.setBoolean(colorRef, flag);
colorRef = FLAG_SCHEME_INDEX.setBoolean(colorRef, flag);
}
public boolean hasSystemRGBFlag() {
@ -197,7 +197,7 @@ public class EscherColorRef {
}
public void setSystemRGBFlag(boolean flag) {
FLAG_SYSTEM_RGB.setBoolean(colorRef, flag);
colorRef = FLAG_SYSTEM_RGB.setBoolean(colorRef, flag);
}
public boolean hasPaletteRGBFlag() {
@ -205,7 +205,7 @@ public class EscherColorRef {
}
public void setPaletteRGBFlag(boolean flag) {
FLAG_PALETTE_RGB.setBoolean(colorRef, flag);
colorRef = FLAG_PALETTE_RGB.setBoolean(colorRef, flag);
}
public boolean hasPaletteIndexFlag() {
@ -213,7 +213,7 @@ public class EscherColorRef {
}
public void setPaletteIndexFlag(boolean flag) {
FLAG_PALETTE_INDEX.setBoolean(colorRef, flag);
colorRef = FLAG_PALETTE_INDEX.setBoolean(colorRef, flag);
}
public int[] getRGB() {

View File

@ -70,7 +70,8 @@ public final class EscherDggRecord extends EscherRecord {
int pos = offset + 8;
int size = 0;
field_1_shapeIdMax = LittleEndian.getInt( data, pos + size );size+=4;
LittleEndian.getInt( data, pos + size );size+=4; // field_2_numIdClusters
// field_2_numIdClusters = LittleEndian.getInt( data, pos + size );
size+=4;
field_3_numShapesSaved = LittleEndian.getInt( data, pos + size );size+=4;
field_4_drawingsSaved = LittleEndian.getInt( data, pos + size );size+=4;
field_5_fileIdClusters = new FileIdCluster[(bytesRemaining-size) / 8]; // Can't rely on field_2_numIdClusters

View File

@ -22,42 +22,34 @@ import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@Internal
class VariantBool
{
private final static POILogger logger = POILogFactory
.getLogger( VariantBool.class );
class VariantBool {
private final static POILogger logger = POILogFactory.getLogger( VariantBool.class );
static final int SIZE = 2;
private boolean _value;
VariantBool( byte[] data, int offset )
{
VariantBool( byte[] data, int offset ) {
short value = LittleEndian.getShort( data, offset );
if ( value == 0x0000 )
{
_value = false;
return;
switch (value) {
case 0:
_value = false;
break;
case -1:
_value = true;
break;
default:
logger.log( POILogger.WARN, "VARIANT_BOOL value '"+value+"' is incorrect" );
_value = true;
break;
}
if ( value == 0xffff )
{
_value = true;
return;
}
logger.log( POILogger.WARN, "VARIANT_BOOL value '",
Short.valueOf( value ), "' is incorrect" );
_value = value != 0;
}
boolean getValue()
{
boolean getValue() {
return _value;
}
void setValue( boolean value )
{
void setValue( boolean value ) {
this._value = value;
}
}

View File

@ -36,22 +36,14 @@ import org.apache.poi.util.LittleEndianOutput;
* https://msdn.microsoft.com/en-us/library/dd924991%28v=office.12%29.aspx
*/
public final class FeatFormulaErr2 implements SharedFeature {
static BitField checkCalculationErrors =
BitFieldFactory.getInstance(0x01);
static BitField checkEmptyCellRef =
BitFieldFactory.getInstance(0x02);
static BitField checkNumbersAsText =
BitFieldFactory.getInstance(0x04);
static BitField checkInconsistentRanges =
BitFieldFactory.getInstance(0x08);
static BitField checkInconsistentFormulas =
BitFieldFactory.getInstance(0x10);
static BitField checkDateTimeFormats =
BitFieldFactory.getInstance(0x20);
static BitField checkUnprotectedFormulas =
BitFieldFactory.getInstance(0x40);
static BitField performDataValidation =
BitFieldFactory.getInstance(0x80);
private static final BitField CHECK_CALCULATION_ERRORS = BitFieldFactory.getInstance(0x01);
private static final BitField CHECK_EMPTY_CELL_REF = BitFieldFactory.getInstance(0x02);
private static final BitField CHECK_NUMBERS_AS_TEXT = BitFieldFactory.getInstance(0x04);
private static final BitField CHECK_INCONSISTENT_RANGES = BitFieldFactory.getInstance(0x08);
private static final BitField CHECK_INCONSISTENT_FORMULAS = BitFieldFactory.getInstance(0x10);
private static final BitField CHECK_DATETIME_FORMATS = BitFieldFactory.getInstance(0x20);
private static final BitField CHECK_UNPROTECTED_FORMULAS = BitFieldFactory.getInstance(0x40);
private static final BitField PERFORM_DATA_VALIDATION = BitFieldFactory.getInstance(0x80);
/**
* What errors we should ignore
@ -93,67 +85,58 @@ public final class FeatFormulaErr2 implements SharedFeature {
}
public boolean getCheckCalculationErrors() {
return checkCalculationErrors.isSet(errorCheck);
return CHECK_CALCULATION_ERRORS.isSet(errorCheck);
}
public void setCheckCalculationErrors(boolean checkCalculationErrors) {
FeatFormulaErr2.checkCalculationErrors.setBoolean(
errorCheck, checkCalculationErrors);
errorCheck = CHECK_CALCULATION_ERRORS.setBoolean(errorCheck, checkCalculationErrors);
}
public boolean getCheckEmptyCellRef() {
return checkEmptyCellRef.isSet(errorCheck);
return CHECK_EMPTY_CELL_REF.isSet(errorCheck);
}
public void setCheckEmptyCellRef(boolean checkEmptyCellRef) {
FeatFormulaErr2.checkEmptyCellRef.setBoolean(
errorCheck, checkEmptyCellRef);
errorCheck = CHECK_EMPTY_CELL_REF.setBoolean(errorCheck, checkEmptyCellRef);
}
public boolean getCheckNumbersAsText() {
return checkNumbersAsText.isSet(errorCheck);
return CHECK_NUMBERS_AS_TEXT.isSet(errorCheck);
}
public void setCheckNumbersAsText(boolean checkNumbersAsText) {
FeatFormulaErr2.checkNumbersAsText.setBoolean(
errorCheck, checkNumbersAsText);
errorCheck = CHECK_NUMBERS_AS_TEXT.setBoolean(errorCheck, checkNumbersAsText);
}
public boolean getCheckInconsistentRanges() {
return checkInconsistentRanges.isSet(errorCheck);
return CHECK_INCONSISTENT_RANGES.isSet(errorCheck);
}
public void setCheckInconsistentRanges(boolean checkInconsistentRanges) {
FeatFormulaErr2.checkInconsistentRanges.setBoolean(
errorCheck, checkInconsistentRanges);
errorCheck = CHECK_INCONSISTENT_RANGES.setBoolean(errorCheck, checkInconsistentRanges);
}
public boolean getCheckInconsistentFormulas() {
return checkInconsistentFormulas.isSet(errorCheck);
return CHECK_INCONSISTENT_FORMULAS.isSet(errorCheck);
}
public void setCheckInconsistentFormulas(
boolean checkInconsistentFormulas) {
FeatFormulaErr2.checkInconsistentFormulas.setBoolean(
errorCheck, checkInconsistentFormulas);
public void setCheckInconsistentFormulas(boolean checkInconsistentFormulas) {
errorCheck = CHECK_INCONSISTENT_FORMULAS.setBoolean(errorCheck, checkInconsistentFormulas);
}
public boolean getCheckDateTimeFormats() {
return checkDateTimeFormats.isSet(errorCheck);
return CHECK_DATETIME_FORMATS.isSet(errorCheck);
}
public void setCheckDateTimeFormats(boolean checkDateTimeFormats) {
FeatFormulaErr2.checkDateTimeFormats.setBoolean(
errorCheck, checkDateTimeFormats);
errorCheck = CHECK_DATETIME_FORMATS.setBoolean(errorCheck, checkDateTimeFormats);
}
public boolean getCheckUnprotectedFormulas() {
return checkUnprotectedFormulas.isSet(errorCheck);
return CHECK_UNPROTECTED_FORMULAS.isSet(errorCheck);
}
public void setCheckUnprotectedFormulas(boolean checkUnprotectedFormulas) {
FeatFormulaErr2.checkUnprotectedFormulas.setBoolean(
errorCheck, checkUnprotectedFormulas);
errorCheck = CHECK_UNPROTECTED_FORMULAS.setBoolean(errorCheck, checkUnprotectedFormulas);
}
public boolean getPerformDataValidation() {
return performDataValidation.isSet(errorCheck);
return PERFORM_DATA_VALIDATION.isSet(errorCheck);
}
public void setPerformDataValidation(boolean performDataValidation) {
FeatFormulaErr2.performDataValidation.setBoolean(
errorCheck, performDataValidation);
errorCheck = PERFORM_DATA_VALIDATION.setBoolean(errorCheck, performDataValidation);
}
}

View File

@ -181,7 +181,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
* The locator of user-defined functions.
* By default includes functions from the Excel Analysis Toolpack
*/
private UDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.DEFAULT);
private UDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.getDefault());
public static HSSFWorkbook create(InternalWorkbook book) {
return new HSSFWorkbook(book);

View File

@ -44,7 +44,7 @@ import org.apache.poi.ss.formula.udf.UDFFinder;
/**
* Analysis Toolpack Function Definitions
*/
public final class AnalysisToolPak implements UDFFinder {
public final class AnalysisToolPak extends UDFFinder {
public static final UDFFinder instance = new AnalysisToolPak();

View File

@ -25,10 +25,8 @@ import java.util.Collection;
/**
* Collects add-in libraries and VB macro functions together into one UDF finder
*
* @author PUdalau
*/
public class AggregatingUDFFinder implements UDFFinder {
public class AggregatingUDFFinder extends UDFFinder {
private final Collection<UDFFinder> _usedToolPacks;

View File

@ -25,10 +25,8 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
/**
* Default UDF finder - for adding your own user defined functions.
*
* @author PUdalau
*/
public final class DefaultUDFFinder implements UDFFinder {
public final class DefaultUDFFinder extends UDFFinder {
private final Map<String, FreeRefFunction> _functionsByName;
public DefaultUDFFinder(String[] functionNames, FreeRefFunction[] functionImpls) {

View File

@ -22,12 +22,11 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
/**
* Common interface for "Add-in" libraries and user defined function libraries.
*
* @author PUdalau
*/
public interface UDFFinder {
// FIXME: Findbugs error: IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION
public static final UDFFinder DEFAULT = new AggregatingUDFFinder(AnalysisToolPak.instance);
public abstract class UDFFinder {
public static UDFFinder getDefault() {
return new AggregatingUDFFinder(AnalysisToolPak.instance);
}
/**
* Returns executor by specified name. Returns <code>null</code> if the function name is unknown.
@ -35,5 +34,5 @@ public interface UDFFinder {
* @param name Name of function.
* @return Function executor.
*/
FreeRefFunction findFunction(String name);
public abstract FreeRefFunction findFunction(String name);
}

View File

@ -769,7 +769,7 @@ public final class PackagingURIHelper {
};
private static boolean isUnsafe(int ch) {
return ch > 0x80 || Character.isWhitespace(ch) || ch == '\u00A0';
return ch > 0x80 || Character.isWhitespace(ch);
}
}

View File

@ -29,7 +29,7 @@ public class XDGFRelation extends POIXMLRelation {
/**
* A map to lookup POIXMLRelation by its relation type
*/
protected static final Map<String, XDGFRelation> _table = new HashMap<String, XDGFRelation>();
private static final Map<String, XDGFRelation> _table = new HashMap<String, XDGFRelation>();
public static final XDGFRelation DOCUMENT = new XDGFRelation(
"application/vnd.ms-visio.drawing.main+xml",

View File

@ -30,7 +30,7 @@ public class XSLFRelation extends POIXMLRelation {
/**
* A map to lookup POIXMLRelation by its relation type
*/
protected static final Map<String, XSLFRelation> _table = new HashMap<String, XSLFRelation>();
private static final Map<String, XSLFRelation> _table = new HashMap<String, XSLFRelation>();
public static final XSLFRelation MAIN = new XSLFRelation(
"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml",

View File

@ -54,7 +54,7 @@ public final class XSSFRelation extends POIXMLRelation {
/**
* A map to lookup POIXMLRelation by its relation type
*/
protected static final Map<String, XSSFRelation> _table = new HashMap<String, XSSFRelation>();
private static final Map<String, XSSFRelation> _table = new HashMap<String, XSSFRelation>();
public static final XSSFRelation WORKBOOK = new XSSFRelation(

View File

@ -72,7 +72,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
_cells = new TreeMap<Integer, XSSFCell>();
for (CTCell c : row.getCArray()) {
XSSFCell cell = new XSSFCell(this, c);
_cells.put(new Integer(cell.getColumnIndex()), cell);
_cells.put(cell.getColumnIndex(), cell);
sheet.onReadCell(cell);
}
}
@ -198,7 +198,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*/
public XSSFCell createCell(int columnIndex, int type) {
CTCell ctCell;
XSSFCell prev = _cells.get(new Integer(columnIndex));
XSSFCell prev = _cells.get(columnIndex);
if(prev != null){
ctCell = prev.getCTCell();
ctCell.set(CTCell.Factory.newInstance());
@ -210,7 +210,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
if (type != Cell.CELL_TYPE_BLANK) {
xcell.setCellType(type);
}
_cells.put(new Integer(columnIndex), xcell);
_cells.put(columnIndex, xcell);
return xcell;
}
@ -236,7 +236,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
XSSFCell cell = _cells.get(new Integer(cellnum));
XSSFCell cell = _cells.get(cellnum);
if(policy == RETURN_NULL_AND_BLANK) {
return cell;
}
@ -455,7 +455,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
_sheet.getWorkbook().onDeleteFormula(xcell);
}
_cells.remove(new Integer(cell.getColumnIndex()));
_cells.remove(cell.getColumnIndex());
}
/**

View File

@ -160,7 +160,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* The locator of user-defined functions.
* By default includes functions from the Excel Analysis Toolpack
*/
private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.DEFAULT);
private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.getDefault());
/**
* TODO

View File

@ -31,7 +31,7 @@ public final class XWPFRelation extends POIXMLRelation {
/**
* A map to lookup POIXMLRelation by its relation type
*/
protected static final Map<String, XWPFRelation> _table = new HashMap<String, XWPFRelation>();
private static final Map<String, XWPFRelation> _table = new HashMap<String, XWPFRelation>();
public static final XWPFRelation DOCUMENT = new XWPFRelation(
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",

View File

@ -91,15 +91,18 @@ public abstract class BitMaskTextProp extends TextProp implements Cloneable {
*/
@Override
public int getValue() {
int val = dataValue, i = 0;
for (int mask : subPropMasks) {
if (!subPropMatches[i++]) {
val &= ~mask;
}
}
return val;
return maskValue(dataValue);
}
private int maskValue(int pVal) {
int val = pVal, i = 0;
for (int mask : subPropMasks) {
if (!subPropMatches[i++]) {
val &= ~mask;
}
}
return val;
}
/**
* Set the value of the text property, and recompute the sub
@ -125,8 +128,7 @@ public abstract class BitMaskTextProp extends TextProp implements Cloneable {
*/
public void setValueWithMask(int val, int writeMask) {
setWriteMask(writeMask);
dataValue = val;
dataValue = getValue();
dataValue = maskValue(val);
if (val != dataValue) {
logger.log(POILogger.WARN, "Style properties of '"+getName()+"' don't match mask - output will be sanitized");
if (logger.check(POILogger.DEBUG)) {

View File

@ -381,6 +381,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
AbstractEscherOptRecord opt = getEscherOptRecord();
if (opt == null) return null;
EscherProperty shadowType = opt.lookup(EscherProperties.SHADOWSTYLE__TYPE);
if (shadowType == null) return null;

View File

@ -424,7 +424,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
// If they type (including the bonus 0xF018) is 0, skip it
PictureType pt = PictureType.forNativeID(type - 0xF018);
if(type == 0 || pt == null) {
if (pt == null) {
logger.log(POILogger.ERROR, "Problem reading picture: Invalid image type 0, on picture with length " + imgsize + ".\nYou document will probably become corrupted if you save it!");
logger.log(POILogger.ERROR, "" + pos);
} else {

View File

@ -133,7 +133,7 @@ public final class BorderCode implements Cloneable {
}
public void setBorderType(int borderType) {
_brcType.setValue(_info, borderType);
_info = (short)_brcType.setValue(_info, borderType);
}
/**
@ -161,7 +161,7 @@ public final class BorderCode implements Cloneable {
}
public void setColor(short color) {
_ico.setValue(_info2, color);
_info2 = (short)_ico.setValue(_info2, color);
}
/**
@ -176,7 +176,7 @@ public final class BorderCode implements Cloneable {
}
public void setSpace(int space) {
_dptSpace.setValue(_info2, space);
_info2 = (short)_dptSpace.setValue(_info2, space);
}
/**
@ -188,7 +188,7 @@ public final class BorderCode implements Cloneable {
}
public void setShadow(boolean shadow) {
_fShadow.setValue(_info2, shadow ? 1 : 0);
_info2 = (short)_fShadow.setValue(_info2, shadow ? 1 : 0);
}
/**
@ -199,7 +199,7 @@ public final class BorderCode implements Cloneable {
}
public void setFrame(boolean frame) {
_fFrame.setValue(_info2, frame ? 1 : 0);
_info2 = (short)_fFrame.setValue(_info2, frame ? 1 : 0);
}
@Override

View File

@ -17,28 +17,36 @@
package org.apache.poi.hssf.model;
import junit.framework.TestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.apache.poi.hssf.record.CountryRecord;
import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.record.RecalcIdRecord;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.TestHSSFWorkbook;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.junit.Test;
/**
* Unit test for the Workbook class.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public final class TestWorkbook extends TestCase {
public void testFontStuff() {
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(new HSSFWorkbook());
public final class TestWorkbook {
@Test
public void testFontStuff() throws IOException {
HSSFWorkbook hwb = new HSSFWorkbook();
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(hwb);
assertEquals(4, wb.getNumberOfFontRecords());
assertEquals(68, wb.getRecords().size());
@ -90,11 +98,15 @@ public final class TestWorkbook extends TestCase {
assertEquals(6, wb.getNumberOfFontRecords());
assertEquals(6, wb.getFontIndex(n7));
assertEquals(n7, wb.getFontRecordAt(6));
hwb.close();
}
public void testAddNameX(){
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(new HSSFWorkbook());
assertNotNull(wb.getNameXPtg("ISODD", UDFFinder.DEFAULT));
@Test
public void testAddNameX() throws IOException {
HSSFWorkbook hwb = new HSSFWorkbook();
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(hwb);
assertNotNull(wb.getNameXPtg("ISODD", UDFFinder.getDefault()));
FreeRefFunction NotImplemented = new FreeRefFunction() {
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
@ -114,9 +126,12 @@ public final class TestWorkbook extends TestCase {
assertNotNull(wb.getNameXPtg("myFunc2", udff));
assertNull(wb.getNameXPtg("myFunc3", udff)); // myFunc3 is unknown
hwb.close();
}
public void testRecalcId(){
@Test
public void testRecalcId() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
assertFalse(wb.getForceFormulaRecalculation());
@ -139,5 +154,7 @@ public final class TestWorkbook extends TestCase {
wb.setForceFormulaRecalculation(true); // resets the EngineId flag to zero
assertEquals(0, record.getEngineId());
assertFalse(wb.getForceFormulaRecalculation());
wb.close();
}
}

View File

@ -38,6 +38,7 @@ import org.apache.poi.ss.format.CellFormat;
import org.apache.poi.ss.format.CellFormatResult;
import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.SuppressForbidden;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@ -52,13 +53,15 @@ public class TestDataFormatter {
private static final double _15_MINUTES = 0.041666667;
@BeforeClass
@SuppressForbidden
public static void setUpClass() {
// some pre-checks to hunt for a problem in the Maven build
// these checks ensure that the correct locale is set, so a failure here
// usually indicates an invalid locale during test-execution
assertFalse(DateUtil.isADateFormat(-1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-"));
assertEquals(Locale.getDefault(), LocaleUtil.getUserLocale());
Locale ul = LocaleUtil.getUserLocale();
assertTrue(Locale.ROOT.equals(ul) || Locale.getDefault().equals(ul));
final String textValue = NumberToTextConverter.toText(1234.56);
assertEquals(-1, textValue.indexOf('E'));
Object cellValueO = Double.valueOf(1234.56);