Package repast.simphony.freezedry
Enum Class ArrayValueHandler
- All Implemented Interfaces:
Serializable
,Comparable<ArrayValueHandler>
,java.lang.constant.Constable
This is an enum for working with string representation of primitive arrays.
- Author:
- Jerry Vos
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateArray
(String arrayType, int size) Creates an array of the specified type and size.static ArrayValueHandler
getHandler
(String arrayType) Retrieves a handler for the specified array type.abstract Object
Converts the string value to a value for the type of array.boolean
Retrieves if this handler handles the specified type of array.static Object
Reads in an array from the given array string and returns it.static ArrayValueHandler
Returns the enum constant of this class with the specified name.static ArrayValueHandler[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.static String
writeArray
(Object array, char delimiter) Writes an array of a type to a String.
-
Enum Constant Details
-
DOUBLE
-
FLOAT
-
INTEGER
-
BOOLEAN
-
CHARACTER
-
LONG
-
SHORT
-
STRING
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-
getValue
Converts the string value to a value for the type of array. So for a double[] this would convert it to a Double.- Parameters:
value
- the string value of the array element- Returns:
- the converted value
-
createArray
Creates an array of the specified type and size.- Parameters:
arrayType
- the type of the arraysize
- the size of the array- Returns:
- an array of the specified type and size or null if the creation failed
-
handles
Retrieves if this handler handles the specified type of array.- Parameters:
arrayType
- the type of the array (the toString of the array's class)- Returns:
- if it handles the type
-
getHandler
Retrieves a handler for the specified array type.- Parameters:
arrayType
- the type of the array- Returns:
- a handler that handles the specified type, or null if no handler handles that type
-
readArray
Reads in an array from the given array string and returns it. This uses the given delimiter to differentiate between elements of the array. For string arrays, this expects that each element of the array be enclosed in qoutation marks. So if your array isnew String[] { "a", "b" }
the passed in string should be like""a", "b""
.- Parameters:
arrayType
- the type of the array, given by type[].class.getName() (for example double[].class.getName())arrayString
- the string representing the arraydelimiter
- the delimiter between array elements- Returns:
- the read in array of the given type
-
writeArray
Writes an array of a type to a String. This will use the toString method on the array elements to get the value for each element, and will insert between elements the given delimiter followed by a space. For string arrays, this will enclose each element of the array in qoutation marks. So if your array isnew String[] { "a", "b" }
the resultant string will be like""a", "b""
.- Parameters:
array
- the array to turn into a stringdelimiter
- the delimiter between array elements- Returns:
- a string representation of the specified array
-