bug 59791: CellFormat#ultimateType(Cell) should return an integer for backwards compatibility (use ultimateTypeEnum for now for CellType enums); re-add SXSSFCell(SXSSFRow, int) for backwards compatibility
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751273 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03671fea80
commit
be49e0c5a7
@ -35,6 +35,7 @@ import org.apache.poi.ss.usermodel.ConditionalFormattingRule;
|
|||||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
import org.apache.poi.ss.util.DateFormatConverter;
|
import org.apache.poi.ss.util.DateFormatConverter;
|
||||||
|
import org.apache.poi.util.Internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a value according to the standard Excel behavior. This "standard" is
|
* Format a value according to the standard Excel behavior. This "standard" is
|
||||||
@ -265,7 +266,7 @@ public class CellFormat {
|
|||||||
* @return The result, in a {@link CellFormatResult}.
|
* @return The result, in a {@link CellFormatResult}.
|
||||||
*/
|
*/
|
||||||
public CellFormatResult apply(Cell c) {
|
public CellFormatResult apply(Cell c) {
|
||||||
switch (ultimateType(c)) {
|
switch (ultimateTypeEnum(c)) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
return apply("");
|
return apply("");
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
@ -335,7 +336,7 @@ public class CellFormat {
|
|||||||
* @return The result, in a {@link CellFormatResult}.
|
* @return The result, in a {@link CellFormatResult}.
|
||||||
*/
|
*/
|
||||||
public CellFormatResult apply(JLabel label, Cell c) {
|
public CellFormatResult apply(JLabel label, Cell c) {
|
||||||
switch (ultimateType(c)) {
|
switch (ultimateTypeEnum(c)) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
return apply(label, "");
|
return apply(label, "");
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
@ -414,11 +415,32 @@ public class CellFormat {
|
|||||||
* {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
|
* {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
|
||||||
* result of {@link Cell#getCellTypeEnum()}.
|
* result of {@link Cell#getCellTypeEnum()}.
|
||||||
*
|
*
|
||||||
|
* Will return {@link CellType} in a future version of POI.
|
||||||
|
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||||
|
*
|
||||||
* @param cell The cell.
|
* @param cell The cell.
|
||||||
*
|
*
|
||||||
* @return The ultimate type of this cell.
|
* @return The ultimate type of this cell.
|
||||||
*/
|
*/
|
||||||
public static CellType ultimateType(Cell cell) {
|
public static int ultimateType(Cell cell) {
|
||||||
|
return ultimateTypeEnum(cell).getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ultimate cell type, following the results of formulas. If
|
||||||
|
* the cell is a {@link CellType#FORMULA}, this returns the result of
|
||||||
|
* {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
|
||||||
|
* result of {@link Cell#getCellTypeEnum()}.
|
||||||
|
*
|
||||||
|
* @param cell The cell.
|
||||||
|
*
|
||||||
|
* @return The ultimate type of this cell.
|
||||||
|
* @since POI 3.15 beta 3
|
||||||
|
* @deprecated POI 3.15 beta 3
|
||||||
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
|
*/
|
||||||
|
@Internal
|
||||||
|
public static CellType ultimateTypeEnum(Cell cell) {
|
||||||
CellType type = cell.getCellTypeEnum();
|
CellType type = cell.getCellTypeEnum();
|
||||||
if (type == CellType.FORMULA)
|
if (type == CellType.FORMULA)
|
||||||
return cell.getCachedFormulaResultTypeEnum();
|
return cell.getCachedFormulaResultTypeEnum();
|
||||||
|
@ -57,6 +57,15 @@ public class SXSSFCell implements Cell {
|
|||||||
private CellStyle _style;
|
private CellStyle _style;
|
||||||
private Property _firstProperty;
|
private Property _firstProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated POI 3.15 beta 3.
|
||||||
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
|
*/
|
||||||
|
public SXSSFCell(SXSSFRow row, int cellType)
|
||||||
|
{
|
||||||
|
this(row, CellType.forInt((cellType)));
|
||||||
|
}
|
||||||
|
|
||||||
public SXSSFCell(SXSSFRow row,CellType cellType)
|
public SXSSFCell(SXSSFRow row,CellType cellType)
|
||||||
{
|
{
|
||||||
_row=row;
|
_row=row;
|
||||||
|
@ -58,7 +58,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
|
|||||||
public void testGeneralFormat() throws Exception {
|
public void testGeneralFormat() throws Exception {
|
||||||
runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
|
runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
|
||||||
public Object getValue(Cell cell) {
|
public Object getValue(Cell cell) {
|
||||||
switch (CellFormat.ultimateType(cell)) {
|
switch (CellFormat.ultimateTypeEnum(cell)) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return cell.getBooleanCellValue();
|
return cell.getBooleanCellValue();
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
@ -126,7 +126,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
|
|||||||
public void testTextFormat() throws Exception {
|
public void testTextFormat() throws Exception {
|
||||||
runFormatTests("TextFormatTests.xlsx", new CellValue() {
|
runFormatTests("TextFormatTests.xlsx", new CellValue() {
|
||||||
public Object getValue(Cell cell) {
|
public Object getValue(Cell cell) {
|
||||||
switch(CellFormat.ultimateType(cell)) {
|
switch(CellFormat.ultimateTypeEnum(cell)) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return cell.getBooleanCellValue();
|
return cell.getBooleanCellValue();
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user