change CellFormat.ultimateType to return CellType
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
318fe3e597
commit
e0ee55e75f
@ -37,6 +37,7 @@ 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.LocaleUtil;
|
import org.apache.poi.util.LocaleUtil;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a value according to the standard Excel behavior. This "standard" is
|
* Format a value according to the standard Excel behavior. This "standard" is
|
||||||
@ -289,7 +290,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 (ultimateTypeEnum(c)) {
|
switch (ultimateType(c)) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
return apply("");
|
return apply("");
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
@ -359,7 +360,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 (ultimateTypeEnum(c)) {
|
switch (ultimateType(c)) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
return apply(label, "");
|
return apply(label, "");
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
@ -438,16 +439,16 @@ public class CellFormat {
|
|||||||
* {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the
|
* {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the
|
||||||
* result of {@link Cell#getCellType()}.
|
* result of {@link Cell#getCellType()}.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
* @deprecated POI 3.15. This will return a CellType enum in the future
|
|
||||||
*/
|
*/
|
||||||
public static int ultimateType(Cell cell) {
|
public static CellType ultimateType(Cell cell) {
|
||||||
return ultimateTypeEnum(cell).getCode();
|
CellType type = cell.getCellType();
|
||||||
|
if (type == CellType.FORMULA)
|
||||||
|
return cell.getCachedFormulaResultType();
|
||||||
|
else
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -460,15 +461,12 @@ public class CellFormat {
|
|||||||
*
|
*
|
||||||
* @return The ultimate type of this cell.
|
* @return The ultimate type of this cell.
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
* @deprecated POI 3.15 beta 3
|
* @deprecated use <code>ultimateType</code> instead
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version = "4.2")
|
||||||
public static CellType ultimateTypeEnum(Cell cell) {
|
public static CellType ultimateTypeEnum(Cell cell) {
|
||||||
CellType type = cell.getCellType();
|
return ultimateType(cell);
|
||||||
if (type == CellType.FORMULA)
|
|
||||||
return cell.getCachedFormulaResultType();
|
|
||||||
else
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
|
|||||||
runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
|
runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(Cell cell) {
|
public Object getValue(Cell cell) {
|
||||||
switch (CellFormat.ultimateTypeEnum(cell)) {
|
switch (CellFormat.ultimateType(cell)) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return cell.getBooleanCellValue();
|
return cell.getBooleanCellValue();
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
@ -132,7 +132,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
|
|||||||
runFormatTests("TextFormatTests.xlsx", new CellValue() {
|
runFormatTests("TextFormatTests.xlsx", new CellValue() {
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(Cell cell) {
|
public Object getValue(Cell cell) {
|
||||||
switch(CellFormat.ultimateTypeEnum(cell)) {
|
switch(CellFormat.ultimateType(cell)) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return cell.getBooleanCellValue();
|
return cell.getBooleanCellValue();
|
||||||
default:
|
default:
|
||||||
@ -158,7 +158,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Cannot find numer in \"" + str + "\"");
|
"Cannot find numer in \"" + str + "\"");
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
// The groups in the pattern are the parts of the number
|
// The groups in the pattern are the parts of the number
|
||||||
for (int i = 1; i <= m.groupCount(); i++) {
|
for (int i = 1; i <= m.groupCount(); i++) {
|
||||||
String part = m.group(i);
|
String part = m.group(i);
|
||||||
|
Loading…
Reference in New Issue
Block a user