Enum SpreadsheetDataType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<SpreadsheetDataType>

    public enum SpreadsheetDataType
    extends java.lang.Enum<SpreadsheetDataType>
    This ENUM enlists the various data types supported, namely String, Integer, Double, Float and Boolean. This class provides convenience methods for working with objects and data types.
    Author:
    Martins Francis
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object castColumnValue​(SpreadsheetDataType dataType, java.lang.Object value)
      Ensures that the given value conforms to the given SpreadsheetDataType.
      static SpreadsheetDataType convert​(java.lang.String dataType)
      Converts the given String representation of a data type to the corresponding internal representation.
      static java.lang.String formatAsString​(SpreadsheetDataType dataType)
      Returns a string representation of the given SpreadsheetDataType.
      static java.lang.String getDefaultDTValue​(SpreadsheetDataType dataType)
      Returns the default value of the given SpreadsheetDataType.
      static SpreadsheetDataType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static SpreadsheetDataType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • values

        public static SpreadsheetDataType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (SpreadsheetDataType c : SpreadsheetDataType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static SpreadsheetDataType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • convert

        public static SpreadsheetDataType convert​(java.lang.String dataType)
        Converts the given String representation of a data type to the corresponding internal representation. If it cannot be converted, then SpreadsheetConstants.DEFAULT_COL_DATATYPE is returned instead.
        Parameters:
        dataType -
        Returns:
        internal data type of the given String descriptor or SpreadsheetConstants.DEFAULT_COL_DATATYPE
      • castColumnValue

        public static java.lang.Object castColumnValue​(SpreadsheetDataType dataType,
                                                       java.lang.Object value)
        Ensures that the given value conforms to the given SpreadsheetDataType. If the value does not conform or cannot be converted then the default value of the given SpreadsheetDataType is returned.
        Parameters:
        dataType -
        value -
        Returns:
        value converted to its data type
      • getDefaultDTValue

        public static java.lang.String getDefaultDTValue​(SpreadsheetDataType dataType)
        Returns the default value of the given SpreadsheetDataType. If an unknown data type is given, then SpreadsheetConstants.DEFAULT_DT_VALUE is returned instead.
        Parameters:
        dataType -
        Returns:
        default value for the given data type
      • formatAsString

        public static java.lang.String formatAsString​(SpreadsheetDataType dataType)
        Returns a string representation of the given SpreadsheetDataType. If data type is unknown then null is returned.
        Parameters:
        dataType -
        Returns:
        String representation of the given data type