Documentation of 'com.csam.dif.DIFCell' Java class
DIFCell
com.csam.dif

Class DIFCell



  • public final class DIFCell
    extends java.lang.Object

    This class represents a single data cell in the spreadsheet. It is comprised primarily of a type marker and a value holder.

    Any of the setXXX methods will also set the cell's type to more closely represent the data within the cell. However, this dynamic typing of the data does mean that using setCellType may lead to unexpected behavior, as this method makes no attempt at type-casting of any existing values.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  DIFCell.CellType
      enum of the available cell types supported
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean getBooleanCellValue()
      Returns the value of this cell expressed as a boolean value.
      int getCellNumber()
      Returns the physical cell number within the row where this cell exists.
      DIFCell.CellType getCellType()
      Returns an indication of the type of data stored in this cell.
      java.sql.Date getDateCellValue()
      Returns the Date value stored at this cell.
      double getDoubleCellValue()
      Identical to getNumericCellValue() except the result is expressed as a native double type.
      long getIntCellValue()
      Identical to getNumericCellValue() except the result is expressed as a native double type
      long getLongCellValue()
      Identical to getNumericCellValue() except the result is expressed as a native double type
      java.math.BigDecimal getNumericCellValue()
      Returns the value of this cell expressed as a numeric value (enclosed in a BigDecimal).
      int getRowNumber()
      Returns the physical row number within the sheet where this cell exists (see DIFRow.getRowNumber() for a detailed description of this).
      java.lang.String getStringCellValue()
      Returns the value of this cell expressed as a numeric.
      void setCellType(DIFCell.CellType cellType)
      Sets the current cell type.
      void setCellValue(java.math.BigDecimal value)
      Sets this cell's value, and changes the CellType to NUMERIC
      void setCellValue(boolean value)
      Sets this cell's value, and changes the CellType to BOOLEAN
      void setCellValue(java.sql.Date value)
      Sets this cell's value, and changes the CellType to DATE
      void setCellValue(double value)
      Identical to setCellValue(BigDecimal), except using a native data type of double.
      void setCellValue(int value)
      Identical to setCellValue(BigDecimal), except using a native data type of int.
      void setCellValue(long value)
      Identical to setCellValue(BigDecimal), except using a native data type of long.
      void setCellValue(java.lang.String value)
      Sets this cell's value, and changes the CellType to STRING
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setCellType

        public void setCellType(DIFCell.CellType cellType)
        Sets the current cell type. This method should generally be avoided, as no type-conversion takes place when the cell type is being set. If there is already data stored in the cell, the results of accessing this object will become unreliable.
        Parameters:
        cellType - CellType of data in this cell.
      • getCellType

        public DIFCell.CellType getCellType()
        Returns an indication of the type of data stored in this cell.
        Returns:
        type of data stored in this cell.
      • getRowNumber

        public int getRowNumber()
        Returns the physical row number within the sheet where this cell exists (see DIFRow.getRowNumber() for a detailed description of this).
        Returns:
        int row number
      • getCellNumber

        public int getCellNumber()
        Returns the physical cell number within the row where this cell exists. A "physical" number is defined as the visual position of the cell as opposed to a "logical" position. What this means in real-terms is that in any given row, several cells may be "empty". Thus, these cells may not be represented in the row model. If the first cell within a row which contains data is located on the third cell of the spreadsheet, then the "physical number" is 2 (the numbers are zero-based, meaning the first cell is 0, not 1).
        Returns:
        int cell number
      • setCellValue

        public void setCellValue(boolean value)
        Sets this cell's value, and changes the CellType to BOOLEAN
        Parameters:
        value - the boolean value of this cell
      • setCellValue

        public void setCellValue(java.math.BigDecimal value)
        Sets this cell's value, and changes the CellType to NUMERIC
        Parameters:
        value - the numeric value of this cell
      • setCellValue

        public void setCellValue(double value)
        Identical to setCellValue(BigDecimal), except using a native data type of double.
        Parameters:
        value - the numeric value of this cell
      • setCellValue

        public void setCellValue(long value)
        Identical to setCellValue(BigDecimal), except using a native data type of long.
        Parameters:
        value - the numeric value of this cell
      • setCellValue

        public void setCellValue(int value)
        Identical to setCellValue(BigDecimal), except using a native data type of int.
        Parameters:
        value - the numeric value of this cell
      • setCellValue

        public void setCellValue(java.lang.String value)
        Sets this cell's value, and changes the CellType to STRING
        Parameters:
        value - the string value of this cell
      • setCellValue

        public void setCellValue(java.sql.Date value)
        Sets this cell's value, and changes the CellType to DATE
        Parameters:
        value - the date value of this cell
      • getBooleanCellValue

        public boolean getBooleanCellValue()
                                    throws DIFDataException
        Returns the value of this cell expressed as a boolean value. If the cell type is BOOLEAN, the value returned is an exact reflection of this. This the cell type is BLANK then false is returned. If the cell type is NUMERIC then true is returned for any non-zero value, otherwise false. If the cell type is STRING, then the string value is parsed (using Boolean.valueOf(String)) and the result returned.
        Returns:
        true or alse
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a boolean value
      • getNumericCellValue

        public java.math.BigDecimal getNumericCellValue()
                                                 throws DIFDataException
        Returns the value of this cell expressed as a numeric value (enclosed in a BigDecimal). If the cell type is BLANK the 0 (zero) is returned. If the cell type is BOOLEAN then 1 (one) is returned for true values, otherwise 0 (zero). If the cell type is NUMERIC then the value is returned as-is. If the cell type is STRING, then a conversion is attempted (using new BigDecimal(String)) and the value of this returned.
        Returns:
        numeric value enclosed in a BigDecimal
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a numeric value
      • getStringCellValue

        public java.lang.String getStringCellValue()
                                            throws DIFDataException
        Returns the value of this cell expressed as a numeric. If the cell type is STRING then the value is returned as-is. All other data types are converted using String.valueOf(Object).
        Returns:
        string representation of cell data
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a string value
      • getDateCellValue

        public java.sql.Date getDateCellValue()
                                       throws DIFDataException
        Returns the Date value stored at this cell. No other type conversion occurs here. Any other cell type will cause an exception.
        Returns:
        Date value of this cell
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a date value (i.e. anything other than DATE).
      • getDoubleCellValue

        public double getDoubleCellValue()
                                  throws DIFDataException
        Identical to getNumericCellValue() except the result is expressed as a native double type.
        Returns:
        numeric value expressed as a double
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a numeric value
      • getLongCellValue

        public long getLongCellValue()
                              throws DIFDataException
        Identical to getNumericCellValue() except the result is expressed as a native double type
        Returns:
        numeric value expressed a long
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a numeric value
      • getIntCellValue

        public long getIntCellValue()
                             throws DIFDataException
        Identical to getNumericCellValue() except the result is expressed as a native double type
        Returns:
        numeric value expressed an int
        Throws:
        DIFDataException - if the underlying data type cannot be expressed as a numeric value

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.