aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-11-12 21:54:22 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-11-12 21:54:22 +0000
commitb8e98ce811f18ab61c642c8fd702a5ef6690e44e (patch)
tree4ed1914a628270dc58cfe4feaf697347bf2dd67a
parent975677da87d9055055a01cb670da1062a19177be (diff)
downloadpoi-b8e98ce811f18ab61c642c8fd702a5ef6690e44e.tar.gz
poi-b8e98ce811f18ab61c642c8fd702a5ef6690e44e.zip
#60331 - Remove deprecated classes (POI 3.16) - remove StylesTable.getNumberFormatAt(int)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1769431 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java11
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java20
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java36
3 files changed, 31 insertions, 36 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
index 209dc722a1..18b88203f4 100644
--- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
+++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
@@ -258,17 +258,6 @@ public class StylesTable extends POIXMLDocumentPart {
/**
* Get number format string given its id
*
- * @param idx number format id
- * @return number format code
- * @deprecated POI 3.14-beta2. Use {@link #getNumberFormatAt(short)} instead.
- */
- public String getNumberFormatAt(int idx) {
- return getNumberFormatAt((short) idx);
- }
-
- /**
- * Get number format string given its id
- *
* @param fmtId number format id
* @return number format code
*/
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java
index 4b117742ea..d82524515a 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java
@@ -18,6 +18,7 @@ package org.apache.poi.xssf.usermodel;
import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.util.Removal;
import org.apache.poi.xssf.model.StylesTable;
/**
@@ -60,14 +61,6 @@ public class XSSFDataFormat implements DataFormat {
*/
@Override
public String getFormat(short index) {
- return getFormat(index&0xffff);
- }
- /**
- * get the format string that matches the given format index
- * @param index of a format
- * @return string represented at index of format or <code>null</code> if there is not a format at that index
- */
- public String getFormat(int index) {
// Indices used for built-in formats may be overridden with
// custom formats, such as locale-specific currency.
// See org.apache.poi.xssf.usermodel.TestXSSFDataFormat#test49928()
@@ -78,6 +71,17 @@ public class XSSFDataFormat implements DataFormat {
if(fmt == null) fmt = BuiltinFormats.getBuiltinFormat(index);
return fmt;
}
+ /**
+ * get the format string that matches the given format index
+ * @param index of a format
+ * @return string represented at index of format or <code>null</code> if there is not a format at that index
+ *
+ * @deprecated POI 3.16 beta 1 - use {@link #getFormat(short)} instead
+ */
+ @Removal(version="3.18")
+ public String getFormat(int index) {
+ return getFormat((short)index);
+ }
/**
* Add a number format with a specific ID into the number format style table.
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
index 03e232ad25..9d29fc4538 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
@@ -111,8 +111,8 @@ public final class TestStylesTable {
assertEquals(2, st.getFills().size());
assertEquals(1, st.getBorders().size());
- assertEquals("yyyy/mm/dd", st.getNumberFormatAt(165));
- assertEquals("yy/mm/dd", st.getNumberFormatAt(167));
+ assertEquals("yyyy/mm/dd", st.getNumberFormatAt((short)165));
+ assertEquals("yy/mm/dd", st.getNumberFormatAt((short)167));
assertNotNull(st.getStyleAt(0));
assertNotNull(st.getStyleAt(1));
@@ -150,7 +150,7 @@ public final class TestStylesTable {
assertEquals(1, st._getStyleXfsSize());
assertEquals(2, st.getNumDataFormats());
- assertEquals("yyyy-mm-dd", st.getNumberFormatAt(nf1));
+ assertEquals("yyyy-mm-dd", st.getNumberFormatAt((short)nf1));
assertEquals(nf1, st.putNumberFormat("yyyy-mm-dd"));
assertEquals(nf2, st.putNumberFormat("yyyy-mm-DD"));
@@ -177,7 +177,7 @@ public final class TestStylesTable {
assertEquals(1, st._getStyleXfsSize());
assertEquals(10, st.getNumDataFormats());
- assertEquals("YYYY-mm-dd", st.getNumberFormatAt(nf1));
+ assertEquals("YYYY-mm-dd", st.getNumberFormatAt((short)nf1));
assertEquals(nf1, st.putNumberFormat("YYYY-mm-dd"));
assertEquals(nf2, st.putNumberFormat("YYYY-mm-DD"));
@@ -216,22 +216,22 @@ public final class TestStylesTable {
@Test
public void removeNumberFormat() throws IOException {
- XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFWorkbook wb1 = new XSSFWorkbook();
try {
final String fmt = customDataFormat;
- final short fmtIdx = (short) wb.getStylesSource().putNumberFormat(fmt);
+ final short fmtIdx = (short) wb1.getStylesSource().putNumberFormat(fmt);
- Cell cell = wb.createSheet("test").createRow(0).createCell(0);
+ Cell cell = wb1.createSheet("test").createRow(0).createCell(0);
cell.setCellValue(5.25);
- CellStyle style = wb.createCellStyle();
+ CellStyle style = wb1.createCellStyle();
style.setDataFormat(fmtIdx);
cell.setCellStyle(style);
assertEquals(fmt, cell.getCellStyle().getDataFormatString());
- assertEquals(fmt, wb.getStylesSource().getNumberFormatAt(fmtIdx));
+ assertEquals(fmt, wb1.getStylesSource().getNumberFormatAt(fmtIdx));
// remove the number format from the workbook
- wb.getStylesSource().removeNumberFormat(fmt);
+ wb1.getStylesSource().removeNumberFormat(fmt);
// number format in CellStyles should be restored to default number format
final short defaultFmtIdx = 0;
@@ -240,17 +240,17 @@ public final class TestStylesTable {
assertEquals(defaultFmt, style.getDataFormatString());
// The custom number format should be entirely removed from the workbook
- Map<Short,String> numberFormats = wb.getStylesSource().getNumberFormats();
+ Map<Short,String> numberFormats = wb1.getStylesSource().getNumberFormats();
assertNotContainsKey(numberFormats, fmtIdx);
assertNotContainsValue(numberFormats, fmt);
// The default style shouldn't be added back to the styles source because it's built-in
- assertEquals(0, wb.getStylesSource().getNumDataFormats());
+ assertEquals(0, wb1.getStylesSource().getNumDataFormats());
cell = null; style = null; numberFormats = null;
- wb = XSSFTestDataSamples.writeOutCloseAndReadBack(wb);
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutCloseAndReadBack(wb1);
- cell = wb.getSheet("test").getRow(0).getCell(0);
+ cell = wb2.getSheet("test").getRow(0).getCell(0);
style = cell.getCellStyle();
// number format in CellStyles should be restored to default number format
@@ -258,15 +258,17 @@ public final class TestStylesTable {
assertEquals(defaultFmt, style.getDataFormatString());
// The custom number format should be entirely removed from the workbook
- numberFormats = wb.getStylesSource().getNumberFormats();
+ numberFormats = wb2.getStylesSource().getNumberFormats();
assertNotContainsKey(numberFormats, fmtIdx);
assertNotContainsValue(numberFormats, fmt);
// The default style shouldn't be added back to the styles source because it's built-in
- assertEquals(0, wb.getStylesSource().getNumDataFormats());
+ assertEquals(0, wb2.getStylesSource().getNumDataFormats());
+
+ wb2.close();
} finally {
- wb.close();
+ wb1.close();
}
}