poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1751273 - in /poi/trunk/src: java/org/apache/poi/ss/format/CellFormat.java ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
Date Mon, 04 Jul 2016 13:09:30 GMT
Author: onealj
Date: Mon Jul  4 13:09:30 2016
New Revision: 1751273

URL: http://svn.apache.org/viewvc?rev=1751273&view=rev
Log:
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

Modified:
    poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java

Modified: poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java?rev=1751273&r1=1751272&r2=1751273&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java Mon Jul  4 13:09:30 2016
@@ -35,6 +35,7 @@ import org.apache.poi.ss.usermodel.Condi
 import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.DateUtil;
 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
@@ -265,7 +266,7 @@ public class CellFormat {
      * @return The result, in a {@link CellFormatResult}.
      */
     public CellFormatResult apply(Cell c) {
-        switch (ultimateType(c)) {
+        switch (ultimateTypeEnum(c)) {
         case BLANK:
             return apply("");
         case BOOLEAN:
@@ -335,7 +336,7 @@ public class CellFormat {
      * @return The result, in a {@link CellFormatResult}.
      */
     public CellFormatResult apply(JLabel label, Cell c) {
-        switch (ultimateType(c)) {
+        switch (ultimateTypeEnum(c)) {
             case BLANK:
                 return apply(label, "");
             case BOOLEAN:
@@ -407,6 +408,23 @@ public class CellFormat {
         }
         
     }
+    
+    /**
+     * 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()}.
+     * 
+     * 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.
+     *
+     * @return The ultimate type of this cell.
+     */
+    public static int ultimateType(Cell cell) {
+        return ultimateTypeEnum(cell).getCode();
+    }
 
     /**
      * Returns the ultimate cell type, following the results of formulas.  If
@@ -417,8 +435,12 @@ public class CellFormat {
      * @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.
      */
-    public static CellType ultimateType(Cell cell) {
+    @Internal
+    public static CellType ultimateTypeEnum(Cell cell) {
         CellType type = cell.getCellTypeEnum();
         if (type == CellType.FORMULA)
             return cell.getCachedFormulaResultTypeEnum();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java?rev=1751273&r1=1751272&r2=1751273&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java Mon Jul  4 13:09:30
2016
@@ -56,6 +56,15 @@ public class SXSSFCell implements Cell {
     private Value _value;
     private CellStyle _style;
     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)
     {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java?rev=1751273&r1=1751272&r2=1751273&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java Mon Jul
 4 13:09:30 2016
@@ -58,7 +58,7 @@ public class TestCellFormatPart extends
     public void testGeneralFormat() throws Exception {
         runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
             public Object getValue(Cell cell) {
-                switch (CellFormat.ultimateType(cell)) {
+                switch (CellFormat.ultimateTypeEnum(cell)) {
                     case BOOLEAN:
                         return cell.getBooleanCellValue();
                     case NUMERIC:
@@ -126,7 +126,7 @@ public class TestCellFormatPart extends
     public void testTextFormat() throws Exception {
         runFormatTests("TextFormatTests.xlsx", new CellValue() {
             public Object getValue(Cell cell) {
-                switch(CellFormat.ultimateType(cell)) {
+                switch(CellFormat.ultimateTypeEnum(cell)) {
                     case BOOLEAN:
                         return cell.getBooleanCellValue();
                     default:



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message