aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-06-24 23:31:12 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-06-24 23:31:12 +0000
commite72ad899b3ba6bac3b771bd8388d6cde3bc6b50e (patch)
tree10fee9859bbbc2c4c867997978931319489e6d49
parentf0a56b51d3610b64eb3cf93cae9c6ff220cd434d (diff)
downloadpoi-e72ad899b3ba6bac3b771bd8388d6cde3bc6b50e.tar.gz
poi-e72ad899b3ba6bac3b771bd8388d6cde3bc6b50e.zip
deprecated constants pointing to MissingCellPolicy - use enum instead
javadocs fixes (jdk8) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1750172 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java4
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFRow.java60
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java8
-rw-r--r--src/java/org/apache/poi/ss/usermodel/Row.java50
-rw-r--r--src/java/org/apache/poi/ss/usermodel/Sheet.java85
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java40
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java5
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java56
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java29
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java9
-rw-r--r--src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java3
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java51
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java3
14 files changed, 229 insertions, 181 deletions
diff --git a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
index d6046845bc..b619d271e1 100644
--- a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
+++ b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
@@ -37,6 +37,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.usermodel.HeaderFooter;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
/**
* A text extractor for Excel files.
@@ -236,6 +237,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
extractor.setIncludeHeadersFooters(cmdArgs.shouldIncludeHeadersFooters());
System.out.println(extractor.getText());
extractor.close();
+ wb.close();
}
/**
* Should sheet names be included? Default is true
@@ -280,7 +282,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
// We don't care about the difference between
// null (missing) and blank cells
- _wb.setMissingCellPolicy(HSSFRow.RETURN_BLANK_AS_NULL);
+ _wb.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
// Process each sheet in turn
for(int i=0;i<_wb.getNumberOfSheets();i++) {
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
index c3354d6aa4..6712e00fb8 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
@@ -107,9 +107,10 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @throws IllegalArgumentException if columnIndex < 0 or greater than 255,
* the maximum number of columns supported by the Excel binary format (.xls)
*/
+ @Override
public HSSFCell createCell(int column)
{
- return this.createCell(column,HSSFCell.CELL_TYPE_BLANK);
+ return this.createCell(column,Cell.CELL_TYPE_BLANK);
}
/**
@@ -126,6 +127,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @throws IllegalArgumentException if columnIndex < 0 or greater than 255,
* the maximum number of columns supported by the Excel binary format (.xls)
*/
+ @Override
public HSSFCell createCell(int columnIndex, int type)
{
short shortCellNum = (short)columnIndex;
@@ -143,6 +145,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* remove the HSSFCell from this row.
* @param cell to remove
*/
+ @Override
public void removeCell(Cell cell) {
if(cell == null) {
throw new IllegalArgumentException("cell must not be null");
@@ -221,6 +224,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @param rowIndex the row number (0-based)
* @throws IndexOutOfBoundsException if the row number is not within the range 0-65535.
*/
+ @Override
public void setRowNum(int rowIndex) {
int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
if ((rowIndex < 0) || (rowIndex > maxrow)) {
@@ -237,6 +241,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* get row number this row represents
* @return the row number (0 based)
*/
+ @Override
public int getRowNum()
{
return rowNum;
@@ -247,6 +252,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
*
* @return the HSSFSheet that owns this row
*/
+ @Override
public HSSFSheet getSheet()
{
return sheet;
@@ -257,6 +263,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* put it into more groups (outlines), reduced as
* you take it out of them.
*/
+ @Override
public int getOutlineLevel() {
return row.getOutlineLevel();
}
@@ -339,6 +346,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @param cellnum 0 based column number
* @return HSSFCell representing that column or null if undefined.
*/
+ @Override
public HSSFCell getCell(int cellnum) {
return getCell(cellnum, book.getMissingCellPolicy());
}
@@ -352,31 +360,27 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @param policy Policy on blank / missing cells
* @return representing that column or null if undefined + policy allows.
*/
+ @Override
public HSSFCell getCell(int cellnum, MissingCellPolicy policy) {
HSSFCell cell = retrieveCell(cellnum);
- if(policy == RETURN_NULL_AND_BLANK) {
- return cell;
- }
- if(policy == RETURN_BLANK_AS_NULL) {
- if(cell == null) return cell;
- if(cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
- return null;
- }
- return cell;
+ switch (policy) {
+ case RETURN_NULL_AND_BLANK:
+ return cell;
+ case RETURN_BLANK_AS_NULL:
+ boolean isBlank = (cell != null && cell.getCellType() == Cell.CELL_TYPE_BLANK);
+ return (isBlank) ? null : cell;
+ case CREATE_NULL_AS_BLANK:
+ return (cell == null) ? createCell(cellnum, Cell.CELL_TYPE_BLANK) : cell;
+ default:
+ throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
}
- if(policy == CREATE_NULL_AS_BLANK) {
- if(cell == null) {
- return createCell(cellnum, HSSFCell.CELL_TYPE_BLANK);
- }
- return cell;
- }
- throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
}
/**
* get the number of the first cell contained in this row.
* @return short representing the first logical cell in the row, or -1 if the row does not contain any cells.
*/
+ @Override
public short getFirstCellNum() {
if (row.isEmpty()) {
return -1;
@@ -403,6 +407,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @return short representing the last logical cell in the row <b>PLUS ONE</b>, or -1 if the
* row does not contain any cells.
*/
+ @Override
public short getLastCellNum() {
if (row.isEmpty()) {
return -1;
@@ -417,6 +422,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @return int representing the number of defined cells in the row.
*/
+ @Override
public int getPhysicalNumberOfCells()
{
int count=0;
@@ -433,6 +439,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @param height rowheight or -1 for undefined (use sheet default)
*/
+ @Override
public void setHeight(short height)
{
if(height == -1){
@@ -448,6 +455,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* set whether or not to display this row with 0 height
* @param zHeight height is zero or not.
*/
+ @Override
public void setZeroHeight(boolean zHeight) {
row.setZeroHeight(zHeight);
}
@@ -456,6 +464,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* get whether or not to display this row with 0 height
* @return - zHeight height is zero or not.
*/
+ @Override
public boolean getZeroHeight() {
return row.getZeroHeight();
}
@@ -465,6 +474,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @param height row height in points, <code>-1</code> means to use the default height
*/
+ @Override
public void setHeightInPoints(float height)
{
if(height == -1){
@@ -480,6 +490,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @return rowheight or 0xff for undefined (use sheet default)
*/
+ @Override
public short getHeight()
{
short height = row.getHeight();
@@ -497,6 +508,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* @return rowheight or 0xff for undefined (use sheet default)
*/
+ @Override
public float getHeightInPoints()
{
return ((float)getHeight() / 20);
@@ -553,6 +565,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* do have whole-row styles. For those that do, you
* can get the formatting from {@link #getRowStyle()}
*/
+ @Override
public boolean isFormatted() {
return row.getFormatted();
}
@@ -561,6 +574,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* have one of these, so will return null. Call
* {@link #isFormatted()} to check first.
*/
+ @Override
public HSSFCellStyle getRowStyle() {
if(!isFormatted()) { return null; }
short styleIndex = row.getXFIndex();
@@ -577,6 +591,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
/**
* Applies a whole-row cell styling to the row.
*/
+ @Override
public void setRowStyle(CellStyle style) {
setRowStyle((HSSFCellStyle)style);
}
@@ -589,6 +604,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* As this only ever works on physically defined cells,
* the {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy} has no effect.
*/
+ @Override
public Iterator<Cell> cellIterator()
{
return new CellIterator();
@@ -597,6 +613,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
* Alias for {@link #cellIterator} to allow
* foreach loops
*/
+ @Override
public Iterator<Cell> iterator() {
return cellIterator();
}
@@ -613,11 +630,13 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
findNext();
}
- public boolean hasNext() {
+ @Override
+ public boolean hasNext() {
return nextId<cells.length;
}
- public Cell next() {
+ @Override
+ public Cell next() {
if (!hasNext())
throw new NoSuchElementException("At last element");
HSSFCell cell=cells[nextId];
@@ -626,7 +645,8 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
return cell;
}
- public void remove() {
+ @Override
+ public void remove() {
if (thisId == -1)
throw new IllegalStateException("remove() called before next()");
cells[thisId]=null;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
index 32cf2229d6..c0f7228fb8 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
@@ -175,7 +175,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
* blank cells when fetching from a row.
* See {@link MissingCellPolicy}
*/
- private MissingCellPolicy missingCellPolicy = HSSFRow.RETURN_NULL_AND_BLANK;
+ private MissingCellPolicy missingCellPolicy = MissingCellPolicy.RETURN_NULL_AND_BLANK;
private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class);
@@ -888,6 +888,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
*
* @return an iterator of the sheets.
*/
+ @Override
public Iterator<Sheet> sheetIterator() {
Iterator<Sheet> result = new SheetIterator<Sheet>();
return result;
@@ -897,6 +898,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
* Alias for {@link #sheetIterator()} to allow
* foreach loops
*/
+ @Override
public Iterator<Sheet> iterator() {
return sheetIterator();
}
@@ -1130,6 +1132,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
* Finds a font that matches the one with the supplied attributes
* @deprecated 3.15 beta 2. Use {@link #findFont(boolean, short, short, String, boolean, boolean, short, byte)} instead.
*/
+ @Deprecated
@Override
public HSSFFont findFont(short boldWeight, short color, short fontHeight,
String name, boolean italic, boolean strikeout,
@@ -1159,6 +1162,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
/**
* Finds a font that matches the one with the supplied attributes
*/
+ @Override
public HSSFFont findFont(boolean bold, short color, short fontHeight,
String name, boolean italic, boolean strikeout,
short typeOffset, byte underline)
@@ -1756,7 +1760,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
break;
}
- blipRecord.setRecordId((short) (EscherBitmapBlip.RECORD_ID_START + format));
+ blipRecord.setRecordId((short) (EscherBlipRecord.RECORD_ID_START + format));
switch (format)
{
case PICTURE_TYPE_EMF:
diff --git a/src/java/org/apache/poi/ss/usermodel/Row.java b/src/java/org/apache/poi/ss/usermodel/Row.java
index 1aae2f78d7..a2bacb487f 100644
--- a/src/java/org/apache/poi/ss/usermodel/Row.java
+++ b/src/java/org/apache/poi/ss/usermodel/Row.java
@@ -32,7 +32,7 @@ public interface Row extends Iterable<Cell> {
*
* @param column - the column number this cell represents
* @return Cell a high level representation of the created cell.
- * @throws IllegalArgumentException if columnIndex < 0 or greater than the maximum number of supported columns
+ * @throws IllegalArgumentException if columnIndex &lt; 0 or greater than the maximum number of supported columns
* (255 for *.xls, 1048576 for *.xlsx)
*/
Cell createCell(int column);
@@ -48,7 +48,7 @@ public interface Row extends Iterable<Cell> {
* @param column - the column number this cell represents
* @param type - the cell's data type
* @return Cell a high level representation of the created cell.
- * @throws IllegalArgumentException if columnIndex < 0 or greate than a maximum number of supported columns
+ * @throws IllegalArgumentException if columnIndex &lt; 0 or greater than a maximum number of supported columns
* (255 for *.xls, 1048576 for *.xlsx)
* @see Cell#CELL_TYPE_BLANK
* @see Cell#CELL_TYPE_BOOLEAN
@@ -70,7 +70,7 @@ public interface Row extends Iterable<Cell> {
* Set the row number of this row.
*
* @param rowNum the row number (0-based)
- * @throws IllegalArgumentException if rowNum < 0
+ * @throws IllegalArgumentException if rowNum &lt; 0
*/
void setRowNum(int rowNum);
@@ -95,10 +95,7 @@ public interface Row extends Iterable<Cell> {
* Returns the cell at the given (0 based) index, with the specified {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy}
*
* @return the cell at the given (0 based) index
- * @throws IllegalArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid
- * @see Row#RETURN_NULL_AND_BLANK
- * @see Row#RETURN_BLANK_AS_NULL
- * @see Row#CREATE_NULL_AS_BLANK
+ * @throws IllegalArgumentException if cellnum &lt; 0 or the specified MissingCellPolicy is invalid
*/
Cell getCell(int cellnum, MissingCellPolicy policy);
@@ -221,22 +218,41 @@ public interface Row extends Iterable<Cell> {
* Used to specify the different possible policies
* if for the case of null and blank cells
*/
- public static enum MissingCellPolicy {
- RETURN_NULL_AND_BLANK(),
- RETURN_BLANK_AS_NULL(),
- CREATE_NULL_AS_BLANK();
+ public enum MissingCellPolicy {
+ RETURN_NULL_AND_BLANK(1),
+ RETURN_BLANK_AS_NULL(2),
+ CREATE_NULL_AS_BLANK(3);
- private int NEXT_ID = 1;
+ /**
+ * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - the id has no function and will be removed
+ */
+ @Deprecated
public final int id;
- private MissingCellPolicy() {
- this.id = NEXT_ID++;
+ private MissingCellPolicy(int id) {
+ this.id = id;
}
}
- /** Missing cells are returned as null, Blank cells are returned as normal */
+
+ /**
+ * Missing cells are returned as null, Blank cells are returned as normal
+ *
+ * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum
+ **/
+ @Deprecated
public static final MissingCellPolicy RETURN_NULL_AND_BLANK = MissingCellPolicy.RETURN_NULL_AND_BLANK;
- /** Missing cells and blank cells are returned as null */
+ /**
+ * Missing cells and blank cells are returned as null
+ *
+ * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum
+ **/
+ @Deprecated
public static final MissingCellPolicy RETURN_BLANK_AS_NULL = MissingCellPolicy.RETURN_BLANK_AS_NULL;
- /** A new, blank cell is created for missing cells. Blank cells are returned as normal */
+ /**
+ * A new, blank cell is created for missing cells. Blank cells are returned as normal
+ *
+ * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum
+ **/
+ @Deprecated
public static final MissingCellPolicy CREATE_NULL_AS_BLANK = MissingCellPolicy.CREATE_NULL_AS_BLANK;
/**
diff --git a/src/java/org/apache/poi/ss/usermodel/Sheet.java b/src/java/org/apache/poi/ss/usermodel/Sheet.java
index d477f5b448..5fbdd5bc20 100644
--- a/src/java/org/apache/poi/ss/usermodel/Sheet.java
+++ b/src/java/org/apache/poi/ss/usermodel/Sheet.java
@@ -135,48 +135,43 @@ public interface Sheet extends Iterable<Row> {
public boolean isRightToLeft();
/**
- * Set the width (in units of 1/256th of a character width)
+ * Set the width (in units of 1/256th of a character width)<p>
*
- * <p>
* The maximum column width for an individual cell is 255 characters.
* This value represents the number of characters that can be displayed
- * in a cell that is formatted with the standard font (first font in the workbook).
- * </p>
+ * in a cell that is formatted with the standard font (first font in the workbook).<p>
*
- * <p>
* Character width is defined as the maximum digit width
* of the numbers <code>0, 1, 2, ... 9</code> as rendered
- * using the default font (first font in the workbook).
- * <br/>
+ * using the default font (first font in the workbook).<p>
+ *
* Unless you are using a very special font, the default character is '0' (zero),
- * this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)
- * </p>
+ * this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)<p>
*
- * <p>
* Please note, that the width set by this method includes 4 pixels of margin padding (two on each side),
* plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec).
- * This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character).
- * </p>
- * <p>
+ * This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character).<p>
+ *
* To compute the actual number of visible characters,
- * Excel uses the following formula (Section 3.3.1.12 of the OOXML spec):
- * </p>
+ * Excel uses the following formula (Section 3.3.1.12 of the OOXML spec):<p>
+ *
* <code>
* width = Truncate([{Number of Visible Characters} *
* {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256
* </code>
- * <p>Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi).
- * If you set a column width to be eight characters wide, e.g. <code>setColumnWidth(columnIndex, 8*256)</code>,
- * then the actual value of visible characters (the value shown in Excel) is derived from the following equation:
+ *
+ * Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi).
+ * If you set a column width to be eight characters wide, e.g. <code>setColumnWidth(columnIndex, 8*256)</code>,
+ * then the actual value of visible characters (the value shown in Excel) is derived from the following equation:
* <code>
- Truncate([numChars*7+5]/7*256)/256 = 8;
+ * Truncate([numChars*7+5]/7*256)/256 = 8;
* </code>
*
- * which gives <code>7.29</code>.
+ * which gives <code>7.29</code>.
*
* @param columnIndex - the column to set (0-based)
* @param width - the width in units of 1/256th of a character width
- * @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters)
+ * @throws IllegalArgumentException if width &gt; 255*256 (the maximum column width in Excel is 255 characters)
*/
void setColumnWidth(int columnIndex, int width);
@@ -557,17 +552,17 @@ public interface Sheet extends Iterable<Row> {
PrintSetup getPrintSetup();
/**
- * Gets the user model for the default document header.
- * <p/>
+ * Gets the user model for the default document header.<p>
+ *
* Note that XSSF offers more kinds of document headers than HSSF does
- * </p>
+ *
* @return the document header. Never <code>null</code>
*/
Header getHeader();
/**
- * Gets the user model for the default document footer.
- * <p/>
+ * Gets the user model for the default document footer.<p>
+ *
* Note that XSSF offers more kinds of document footers than HSSF does.
*
* @return the document footer. Never <code>null</code>
@@ -575,10 +570,10 @@ public interface Sheet extends Iterable<Row> {
Footer getFooter();
/**
- * Sets a flag indicating whether this sheet is selected.
- *<p>
+ * Sets a flag indicating whether this sheet is selected.<p>
+ *
* Note: multiple sheets can be selected, but only one sheet can be active at one time.
- *</p>
+ *
* @param value <code>true</code> if this sheet is selected
* @see Workbook#setActiveSheet(int)
*/
@@ -603,7 +598,7 @@ public interface Sheet extends Iterable<Row> {
/**
* Answer whether protection is enabled or disabled
*
- * @return true => protection enabled; false => protection disabled
+ * @return true =&gt; protection enabled; false =&gt; protection disabled
*/
boolean getProtect();
@@ -616,7 +611,7 @@ public interface Sheet extends Iterable<Row> {
/**
* Answer whether scenario protection is enabled or disabled
*
- * @return true => protection enabled; false => protection disabled
+ * @return true =&gt; protection enabled; false =&gt; protection disabled
*/
boolean getScenarioProtect();
@@ -629,11 +624,12 @@ public interface Sheet extends Iterable<Row> {
* @param denominator The denominator for the zoom magnification.
* @deprecated 2015-11-23 (circa POI 3.14beta1). Use {@link #setZoom(int)} instead.
*/
+ @Deprecated
void setZoom(int numerator, int denominator);
/**
* Window zoom magnification for current view representing percent values.
- * Valid values range from 10 to 400. Horizontal & Vertical scale together.
+ * Valid values range from 10 to 400. Horizontal &amp; Vertical scale together.
*
* For example:
* <pre>
@@ -949,6 +945,7 @@ public interface Sheet extends Iterable<Row> {
* @return cell comment or <code>null</code> if not found
* @deprecated as of 2015-11-23 (circa POI 3.14beta1). Use {@link #getCellComment(CellAddress)} instead.
*/
+ @Deprecated
Comment getCellComment(int row, int column);
/**
@@ -1054,8 +1051,8 @@ public interface Sheet extends Iterable<Row> {
/**
* Gets the repeating rows used when printing the sheet, as found in
- * File->PageSetup->Sheet.
- * <p/>
+ * File-&gt;PageSetup-&gt;Sheet.<p>
+ *
* Repeating rows cover a range of contiguous rows, e.g.:
* <pre>
* Sheet1!$1:$1
@@ -1063,8 +1060,8 @@ public interface Sheet extends Iterable<Row> {
* </pre>
* The {@link CellRangeAddress} returned contains a column part which spans
* all columns, and a row part which specifies the contiguous range of
- * repeating rows.
- * <p/>
+ * repeating rows.<p>
+ *
* If the Sheet does not have any repeating rows defined, null is returned.
*
* @return an {@link CellRangeAddress} containing the repeating rows for the
@@ -1075,8 +1072,8 @@ public interface Sheet extends Iterable<Row> {
/**
* Gets the repeating columns used when printing the sheet, as found in
- * File->PageSetup->Sheet.
- * <p/>
+ * File-&gt;PageSetup-&gt;Sheet.<p>
+ *
* Repeating columns cover a range of contiguous columns, e.g.:
* <pre>
* Sheet1!$A:$A
@@ -1084,8 +1081,8 @@ public interface Sheet extends Iterable<Row> {
* </pre>
* The {@link CellRangeAddress} returned contains a row part which spans all
* rows, and a column part which specifies the contiguous range of
- * repeating columns.
- * <p/>
+ * repeating columns.<p>
+ *
* If the Sheet does not have any repeating columns defined, null is
* returned.
*
@@ -1097,8 +1094,8 @@ public interface Sheet extends Iterable<Row> {
/**
* Sets the repeating rows used when printing the sheet, as found in
- * File->PageSetup->Sheet.
- * <p/>
+ * File-&gt;PageSetup-&gt;Sheet.<p>
+ *
* Repeating rows cover a range of contiguous rows, e.g.:
* <pre>
* Sheet1!$1:$1
@@ -1121,8 +1118,8 @@ public interface Sheet extends Iterable<Row> {
/**
* Sets the repeating columns used when printing the sheet, as found in
- * File->PageSetup->Sheet.
- * <p/>
+ * File-&gt;PageSetup-&gt;Sheet.<p>
+ *
* Repeating columns cover a range of contiguous columns, e.g.:
* <pre>
* Sheet1!$A:$A
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
index 2d6fe20f4a..cec3136f61 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
@@ -32,9 +32,7 @@ import org.apache.poi.util.Internal;
/**
* Streaming version of XSSFRow implementing the "BigGridDemo" strategy.
- *
- * @author Alex Geller, Four J's Development Tools
-*/
+ */
public class SXSSFRow implements Row, Comparable<SXSSFRow>
{
private static final Boolean UNDEFINED = null;
@@ -55,6 +53,7 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
* @param initialSize - no longer needed
* @deprecated 2015-11-30 (circa POI 3.14beta1). Use {@link #SXSSFRow(SXSSFSheet)} instead.
*/
+ @Deprecated
public SXSSFRow(SXSSFSheet sheet, @SuppressWarnings("UnusedParameters") int initialSize)
{
this(sheet);
@@ -74,6 +73,7 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
return _height!=-1;
}
+ @Override
public int getOutlineLevel(){
return _outlineLevel;
}
@@ -239,38 +239,24 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
*
* @return the cell at the given (0 based) index
* @throws IllegalArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid
- * @see Row#RETURN_NULL_AND_BLANK
- * @see Row#RETURN_BLANK_AS_NULL
- * @see Row#CREATE_NULL_AS_BLANK
*/
@Override
public SXSSFCell getCell(int cellnum, MissingCellPolicy policy)
{
checkBounds(cellnum);
- // FIXME: replace with switch(enum)
final SXSSFCell cell = _cells.get(cellnum);
- if (policy == RETURN_NULL_AND_BLANK)
- {
- return cell;
- }
- else if (policy == RETURN_BLANK_AS_NULL)
- {
- if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
- {
- return null;
- }
- return cell;
- }
- else if (policy == CREATE_NULL_AS_BLANK)
- {
- if (cell == null)
- {
- return createCell(cellnum, Cell.CELL_TYPE_BLANK);
- }
- return cell;
+ switch (policy) {
+ case RETURN_NULL_AND_BLANK:
+ return cell;
+ case RETURN_BLANK_AS_NULL:
+ boolean isBlank = (cell != null && cell.getCellType() == Cell.CELL_TYPE_BLANK);
+ return (isBlank) ? null : cell;
+ case CREATE_NULL_AS_BLANK:
+ return (cell == null) ? createCell(cellnum, Cell.CELL_TYPE_BLANK) : cell;
+ default:
+ throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
}
- throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index dd2417630c..463bad5c35 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -38,7 +38,7 @@ import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.RichTextString;
-import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
@@ -112,7 +112,7 @@ public final class XSSFCell implements Cell {
} else {
int prevNum = row.getLastCellNum();
if(prevNum != -1){
- _cellNum = row.getCell(prevNum-1, Row.RETURN_NULL_AND_BLANK).getColumnIndex() + 1;
+ _cellNum = row.getCell(prevNum-1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getColumnIndex() + 1;
}
}
_sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource();
@@ -551,6 +551,7 @@ public final class XSSFCell implements Cell {
cellFormula.setRef(range.formatAsString());
}
+ @SuppressWarnings("resource")
private void setFormula(String formula, int formulaType) {
XSSFWorkbook wb = _row.getSheet().getWorkbook();
if (formula == null) {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
index ee956b437d..c4e63c70f9 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
@@ -94,6 +94,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return the XSSFSheet that owns this row
*/
+ @Override
public XSSFSheet getSheet() {
return this._sheet;
}
@@ -109,6 +110,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return an iterator over cells in this row.
*/
+ @Override
@SuppressWarnings("unchecked")
public Iterator<Cell> cellIterator() {
return (Iterator<Cell>)(Iterator<? extends Cell>)_cells.values().iterator();
@@ -124,6 +126,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return an iterator over cells in this row.
*/
+ @Override
public Iterator<Cell> iterator() {
return cellIterator();
}
@@ -189,6 +192,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @throws IllegalArgumentException if columnIndex < 0 or greater than 16384,
* the maximum number of columns supported by the SpreadsheetML format (.xlsx)
*/
+ @Override
public XSSFCell createCell(int columnIndex) {
return createCell(columnIndex, Cell.CELL_TYPE_BLANK);
}
@@ -208,6 +212,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @see Cell#CELL_TYPE_NUMERIC
* @see Cell#CELL_TYPE_STRING
*/
+ @Override
public XSSFCell createCell(int columnIndex, int type) {
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer colI = new Integer(columnIndex); // NOSONAR
@@ -234,6 +239,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return the cell at the given (0 based) index
*/
+ @Override
public XSSFCell getCell(int cellnum) {
return getCell(cellnum, _sheet.getWorkbook().getMissingCellPolicy());
}
@@ -242,34 +248,26 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* Returns the cell at the given (0 based) index, with the specified {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy}
*
* @return the cell at the given (0 based) index
- * @throws IllegalArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid
- * @see Row#RETURN_NULL_AND_BLANK
- * @see Row#RETURN_BLANK_AS_NULL
- * @see Row#CREATE_NULL_AS_BLANK
+ * @throws IllegalArgumentException if cellnum &lt; 0 or the specified MissingCellPolicy is invalid
*/
+ @Override
public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer colI = new Integer(cellnum); // NOSONAR
XSSFCell cell = _cells.get(colI);
- if(policy == RETURN_NULL_AND_BLANK) {
- return cell;
- }
- if(policy == RETURN_BLANK_AS_NULL) {
- if(cell == null) return cell;
- if(cell.getCellType() == Cell.CELL_TYPE_BLANK) {
- return null;
- }
- return cell;
- }
- if(policy == CREATE_NULL_AS_BLANK) {
- if(cell == null) {
- return createCell((short)cellnum, Cell.CELL_TYPE_BLANK);
- }
- return cell;
- }
- throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
+ switch (policy) {
+ case RETURN_NULL_AND_BLANK:
+ return cell;
+ case RETURN_BLANK_AS_NULL:
+ boolean isBlank = (cell != null && cell.getCellType() == Cell.CELL_TYPE_BLANK);
+ return (isBlank) ? null : cell;
+ case CREATE_NULL_AS_BLANK:
+ return (cell == null) ? createCell(cellnum, Cell.CELL_TYPE_BLANK) : cell;
+ default:
+ throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
+ }
}
/**
@@ -278,6 +276,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return short representing the first logical cell in the row,
* or -1 if the row does not contain any cells.
*/
+ @Override
public short getFirstCellNum() {
return (short)(_cells.size() == 0 ? -1 : _cells.firstKey());
}
@@ -301,6 +300,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return short representing the last logical cell in the row <b>PLUS ONE</b>,
* or -1 if the row does not contain any cells.
*/
+ @Override
public short getLastCellNum() {
return (short)(_cells.size() == 0 ? -1 : (_cells.lastKey() + 1));
}
@@ -311,6 +311,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return row height measured in twips (1/20th of a point)
*/
+ @Override
public short getHeight() {
return (short)(getHeightInPoints()*20);
}
@@ -322,6 +323,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return row height measured in point size
* @see org.apache.poi.xssf.usermodel.XSSFSheet#getDefaultRowHeightInPoints()
*/
+ @Override
public float getHeightInPoints() {
if (this._row.isSetHt()) {
return (float) this._row.getHt();
@@ -334,6 +336,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @param height the height in "twips" or 1/20th of a point. <code>-1</code> resets to the default height
*/
+ @Override
public void setHeight(short height) {
if (height == -1) {
if (_row.isSetHt()) _row.unsetHt();
@@ -350,6 +353,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @param height the height in points. <code>-1</code> resets to the default height
*/
+ @Override
public void setHeightInPoints(float height) {
setHeight((short)(height == -1 ? -1 : (height*20)));
}
@@ -360,6 +364,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return int representing the number of defined cells in the row.
*/
+ @Override
public int getPhysicalNumberOfCells() {
return _cells.size();
}
@@ -369,6 +374,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return the row number (0 based)
*/
+ @Override
public int getRowNum() {
return (int) (_row.getR() - 1);
}
@@ -379,6 +385,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @param rowIndex the row number (0-based)
* @throws IllegalArgumentException if rowNum < 0 or greater than 1048575
*/
+ @Override
public void setRowNum(int rowIndex) {
int maxrow = SpreadsheetVersion.EXCEL2007.getLastRowIndex();
if (rowIndex < 0 || rowIndex > maxrow) {
@@ -393,6 +400,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @return - height is zero or not.
*/
+ @Override
public boolean getZeroHeight() {
return this._row.getHidden();
}
@@ -402,6 +410,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @param height height is zero or not.
*/
+ @Override
public void setZeroHeight(boolean height) {
this._row.setHidden(height);
@@ -412,6 +421,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* do have whole-row styles. For those that do, you
* can get the formatting from {@link #getRowStyle()}
*/
+ @Override
public boolean isFormatted() {
return _row.isSetS();
}
@@ -420,6 +430,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* have one of these, so will return null. Call
* {@link #isFormatted()} to check first.
*/
+ @Override
public XSSFCellStyle getRowStyle() {
if(!isFormatted()) return null;
@@ -436,6 +447,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* If the value is null then the style information is removed,
* causing the cell to used the default workbook style.
*/
+ @Override
public void setRowStyle(CellStyle style) {
if(style == null) {
if(_row.isSetS()) {
@@ -459,6 +471,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*
* @param cell the cell to remove
*/
+ @Override
public void removeCell(Cell cell) {
if (cell.getRow() != this) {
throw new IllegalArgumentException("Specified cell does not belong to this row");
@@ -640,6 +653,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
}
}
+ @Override
public int getOutlineLevel() {
return _row.getOutlineLevel();
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
index ce4b033fc1..9133046239 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -190,7 +190,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* blank cells when fetching from a row.
* See {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy}
*/
- private MissingCellPolicy _missingCellPolicy = Row.RETURN_NULL_AND_BLANK;
+ private MissingCellPolicy _missingCellPolicy = MissingCellPolicy.RETURN_NULL_AND_BLANK;
/**
* array of pictures for this workbook
@@ -872,6 +872,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* Finds a font that matches the one with the supplied attributes
* @deprecated POI 3.15. Use {@link #findFont(boolean, short, short, String, boolean, boolean, short, byte)} instead.
*/
+ @Deprecated
@Override
public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
return stylesSource.findFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
@@ -921,6 +922,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* @param idx index within the set of styles
* @return XSSFCellStyle object at the index
*/
+ @Override
public XSSFCellStyle getCellStyleAt(int idx) {
return stylesSource.getStyleAt(idx);
}
@@ -995,6 +997,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
*
* @return count of cell styles
*/
+ @Override
public int getNumCellStyles() {
return stylesSource.getNumCellStyles();
}
@@ -1127,6 +1130,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
*
* @return an iterator of the sheets.
*/
+ @Override
public Iterator<Sheet> sheetIterator() {
return new SheetIterator<Sheet>();
}
@@ -1950,6 +1954,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* @param name The name the workbook will be referenced as in formulas
* @param workbook The open workbook to fetch the link required information from
*/
+ @Override
@NotImplemented
public int linkExternalWorkbook(String name, Workbook workbook) {
throw new RuntimeException("Not Implemented - see bug #57184");
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
index f41e5c53ec..b9c5c9809a 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
@@ -30,6 +30,7 @@ import java.util.List;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.BaseTestXCell;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.CellStyle;
@@ -40,6 +41,7 @@ import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
@@ -52,9 +54,6 @@ import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
-/**
- * @author Yegor Kozlov
- */
public final class TestXSSFCell extends BaseTestXCell {
public TestXSSFCell() {
@@ -152,7 +151,7 @@ public final class TestXSSFCell extends BaseTestXCell {
CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml
cell.setCellFormula("A2");
- assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
assertEquals("A2", cell.getCellFormula());
//the value is not set and cell's type='N' which means blank
assertEquals(STCellType.N, ctCell.getT());
@@ -160,7 +159,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//set cached formula value
cell.setCellValue("t='str'");
//we are still of 'formula' type
- assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
assertEquals("A2", cell.getCellFormula());
//cached formula value is set and cell's type='STR'
assertEquals(STCellType.STR, ctCell.getT());
@@ -168,14 +167,14 @@ public final class TestXSSFCell extends BaseTestXCell {
//now remove the formula, the cached formula result remains
cell.setCellFormula(null);
- assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
assertEquals(STCellType.STR, ctCell.getT());
//the line below failed prior to fix of Bug #47889
assertEquals("t='str'", cell.getStringCellValue());
//revert to a blank cell
cell.setCellValue((String)null);
- assertEquals(XSSFCell.CELL_TYPE_BLANK, cell.getCellType());
+ assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
assertEquals(STCellType.N, ctCell.getT());
assertEquals("", cell.getStringCellValue());
} finally {
@@ -195,7 +194,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//try a string cell
cell = sh.getRow(0).getCell(0);
- assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
assertEquals("a", cell.getStringCellValue());
assertEquals("a", cell.toString());
//Gnumeric produces spreadsheets without styles
@@ -204,7 +203,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//try a numeric cell
cell = sh.getRow(1).getCell(0);
- assertEquals(XSSFCell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCellType());
assertEquals(1.0, cell.getNumericCellValue(), 0);
assertEquals("1.0", cell.toString());
//Gnumeric produces spreadsheets without styles
@@ -417,7 +416,7 @@ public final class TestXSSFCell extends BaseTestXCell {
public void testBug56644ReturnNull() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56644.xlsx");
try {
- wb.setMissingCellPolicy(Row.RETURN_BLANK_AS_NULL);
+ wb.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
Sheet sheet = wb.getSheet("samplelist");
Row row = sheet.getRow(20);
row.createCell(2);
@@ -430,7 +429,7 @@ public final class TestXSSFCell extends BaseTestXCell {
public void testBug56644ReturnBlank() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56644.xlsx");
try {
- wb.setMissingCellPolicy(Row.RETURN_NULL_AND_BLANK);
+ wb.setMissingCellPolicy(MissingCellPolicy.RETURN_NULL_AND_BLANK);
Sheet sheet = wb.getSheet("samplelist");
Row row = sheet.getRow(20);
row.createCell(2);
@@ -443,7 +442,7 @@ public final class TestXSSFCell extends BaseTestXCell {
public void testBug56644CreateBlank() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56644.xlsx");
try {
- wb.setMissingCellPolicy(Row.CREATE_NULL_AS_BLANK);
+ wb.setMissingCellPolicy(MissingCellPolicy.CREATE_NULL_AS_BLANK);
Sheet sheet = wb.getSheet("samplelist");
Row row = sheet.getRow(20);
row.createCell(2);
@@ -565,7 +564,7 @@ public final class TestXSSFCell extends BaseTestXCell {
final CreationHelper createHelper = wb.getCreationHelper();
srcCell.setCellValue("URL LINK");
- Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
+ Hyperlink link = createHelper.createHyperlink(org.apache.poi.common.usermodel.Hyperlink.LINK_URL);
link.setAddress("http://poi.apache.org/");
srcCell.setHyperlink(link);
@@ -602,7 +601,7 @@ public final class TestXSSFCell extends BaseTestXCell {
final CreationHelper createHelper = wb.getCreationHelper();
srcCell.setCellValue("URL LINK");
- Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
+ Hyperlink link = createHelper.createHyperlink(org.apache.poi.common.usermodel.Hyperlink.LINK_URL);
link.setAddress("http://poi.apache.org/");
destCell.setHyperlink(link);
@@ -657,7 +656,7 @@ public final class TestXSSFCell extends BaseTestXCell {
srcCell.setCellFormula("2+3");
final CellStyle style = wb.createCellStyle();
- style.setBorderTop(CellStyle.BORDER_THICK);
+ style.setBorderTop(BorderStyle.THICK);
style.setFillBackgroundColor((short) 5);
srcCell.setCellStyle(style);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index 81eed92ca9..c3420c780a 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -59,6 +59,7 @@ import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -1036,26 +1037,26 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
// read-only mode works!
Workbook workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ));
- Date dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
+ Date dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, dateAct);
workbook.close();
workbook = null;
workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ));
- dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
+ dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, dateAct);
workbook.close();
workbook = null;
// now check read/write mode
workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE));
- dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
+ dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, dateAct);
workbook.close();
workbook = null;
workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE));
- dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, Row.CREATE_NULL_AS_BLANK).getDateCellValue();
+ dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue();
assertEquals(dateExp, dateAct);
workbook.close();
workbook = null;
diff --git a/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java b/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
index 537dafbb3e..d28ac8892c 100644
--- a/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
+++ b/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
@@ -41,6 +41,7 @@ import javax.swing.JLabel;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.LocaleUtil;
@@ -141,7 +142,7 @@ public class CellFormatTestBase {
protected void openWorkbook(String workbookName)
throws IOException {
workbook = _testDataProvider.openSampleWorkbook(workbookName);
- workbook.setMissingCellPolicy(Row.CREATE_NULL_AS_BLANK);
+ workbook.setMissingCellPolicy(MissingCellPolicy.CREATE_NULL_AS_BLANK);
testFile = workbookName;
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
index 5b22f82792..120216bd7f 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
@@ -28,6 +28,7 @@ import java.io.IOException;
import java.util.Iterator;
import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.junit.Test;
/**
@@ -263,41 +264,41 @@ public abstract class BaseTestRow {
assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType());
// RETURN_NULL_AND_BLANK - same as default
- assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0, Row.RETURN_NULL_AND_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, Row.RETURN_NULL_AND_BLANK).getCellType());
- assertEquals(null, row.getCell(2, Row.RETURN_NULL_AND_BLANK));
- assertEquals(null, row.getCell(3, Row.RETURN_NULL_AND_BLANK));
- assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(4, Row.RETURN_NULL_AND_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, Row.RETURN_NULL_AND_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+ assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_NULL_AND_BLANK));
+ assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_NULL_AND_BLANK));
+ assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
// RETURN_BLANK_AS_NULL - nearly the same
- assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0, Row.RETURN_BLANK_AS_NULL).getCellType());
- assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, Row.RETURN_BLANK_AS_NULL).getCellType());
- assertEquals(null, row.getCell(2, Row.RETURN_BLANK_AS_NULL));
- assertEquals(null, row.getCell(3, Row.RETURN_BLANK_AS_NULL));
- assertEquals(null, row.getCell(4, Row.RETURN_BLANK_AS_NULL));
- assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, Row.RETURN_BLANK_AS_NULL).getCellType());
+ assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
+ assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
+ assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_BLANK_AS_NULL));
+ assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_BLANK_AS_NULL));
+ assertEquals(null, row.getCell(4, MissingCellPolicy.RETURN_BLANK_AS_NULL));
+ assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
// CREATE_NULL_AS_BLANK - creates as needed
- assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0, Row.CREATE_NULL_AS_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, Row.CREATE_NULL_AS_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(2, Row.CREATE_NULL_AS_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(3, Row.CREATE_NULL_AS_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(4, Row.CREATE_NULL_AS_BLANK).getCellType());
- assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, Row.CREATE_NULL_AS_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+ assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
// Check created ones get the right column
- assertEquals(0, row.getCell(0, Row.CREATE_NULL_AS_BLANK).getColumnIndex());
- assertEquals(1, row.getCell(1, Row.CREATE_NULL_AS_BLANK).getColumnIndex());
- assertEquals(2, row.getCell(2, Row.CREATE_NULL_AS_BLANK).getColumnIndex());
- assertEquals(3, row.getCell(3, Row.CREATE_NULL_AS_BLANK).getColumnIndex());
- assertEquals(4, row.getCell(4, Row.CREATE_NULL_AS_BLANK).getColumnIndex());
- assertEquals(5, row.getCell(5, Row.CREATE_NULL_AS_BLANK).getColumnIndex());
+ assertEquals(0, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
+ assertEquals(1, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
+ assertEquals(2, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
+ assertEquals(3, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
+ assertEquals(4, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
+ assertEquals(5, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
// Now change the cell policy on the workbook, check
// that that is now used if no policy given
- workbook.setMissingCellPolicy(Row.RETURN_BLANK_AS_NULL);
+ workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
assertEquals(Cell.CELL_TYPE_STRING, row.getCell(0).getCellType());
assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java b/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
index 6fd632c0c5..e99c3fe698 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
@@ -25,6 +25,7 @@ import java.io.FileInputStream;
import java.io.InputStreamReader;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
import org.apache.poi.util.LocaleUtil;
import org.junit.Test;
@@ -60,7 +61,7 @@ public final class TestFractionFormat {
String[] truths = truthLine.split("\t");
// Intentionally ignore the last column (tika-1132), for now
for (short j = 3; j < 12; j++){
- Cell cell = r.getCell(j, Row.CREATE_NULL_AS_BLANK);
+ Cell cell = r.getCell(j, MissingCellPolicy.CREATE_NULL_AS_BLANK);
String formatted = clean(formatter.formatCellValue(cell, evaluator));
if (truths.length <= j){
continue;