Enum SpreadsheetDataType
- java.lang.Object
-
- java.lang.Enum<SpreadsheetDataType>
-
- org.eclipse.epsilon.emc.spreadsheets.SpreadsheetDataType
-
- All Implemented Interfaces:
Serializable
,Comparable<SpreadsheetDataType>
public enum SpreadsheetDataType extends 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 Object
castColumnValue(SpreadsheetDataType dataType, Object value)
Ensures that the given value conforms to the given SpreadsheetDataType.static Object
coerceColumnValue(SpreadsheetDataType dataType, Object value)
static SpreadsheetDataType
convert(String dataType)
Converts the given String representation of a data type to the corresponding internal representation.static String
formatAsString(SpreadsheetDataType dataType)
Returns a string representation of the given SpreadsheetDataType.static String
getDefaultDTValue(SpreadsheetDataType dataType)
Returns the default value of the given SpreadsheetDataType.static SpreadsheetDataType
valueOf(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.
-
-
-
Enum Constant Detail
-
STRING
public static final SpreadsheetDataType STRING
-
INTEGER
public static final SpreadsheetDataType INTEGER
-
BOOLEAN
public static final SpreadsheetDataType BOOLEAN
-
DOUBLE
public static final SpreadsheetDataType DOUBLE
-
FLOAT
public static final SpreadsheetDataType FLOAT
-
-
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(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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
convert
public static SpreadsheetDataType convert(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 Object castColumnValue(SpreadsheetDataType dataType, 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
-
coerceColumnValue
public static Object coerceColumnValue(SpreadsheetDataType dataType, Object value)
-
getDefaultDTValue
public static 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 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
-
-