Package de.gsi.serializer
Enum DataType
- java.lang.Object
-
- java.lang.Enum<DataType>
-
- de.gsi.serializer.DataType
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<DataType>
public enum DataType extends java.lang.Enum<DataType>
Enum definition for data primitives in the context of serialisation and includes definitions for:- primitives (byte, short, ..., float, double, and String), and
- arrays thereof (ie. byte[], short[], ..., float[], double[], and String[]), as well as
- complex objects implementing Collections (ie. Set, List, Queues), Enums or Maps.
OTHERsub-type.N.B. Multi-dimensional arrays are handled through one-dimensional striding arrays with the additional infos on number of dimensions and size for each individual dimension.
- Author:
- rstein
- See Also:
BinarySerialiser, striding arrays
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BOOLBOOL_ARRAYBYTEBYTE_ARRAYCHARCHAR_ARRAYCOLLECTIONDOUBLEDOUBLE_ARRAYEND_MARKERENUMFLOATFLOAT_ARRAYINTINT_ARRAYLISTLONGLONG_ARRAYMAPOTHERdefault for any other complex or object-type custom data structure, usually followed/refined by an additional user-provided custom type IDQUEUESETSHORTSHORT_ARRAYSTART_MARKERSTRINGSTRING_ARRAY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataTypefromByte(byte value)Returns the data type matching the given uniqueID representation, if any.static DataTypefromClassType(java.lang.Class<?> classType)Returns the data type matching the given java class type, if any.static DataTypefromJavaTypeString(java.lang.String str)Returns the data type matching the given java string representation, if any.static DataTypefromString(java.lang.String str)Returns the data type matching the given string representation, if any.java.lang.StringgetAsString()Returns the string representation of the data type.java.util.List<java.lang.Class<?>>getClassTypes()Returns the corresponding java class type matching the given data typeintgetID()Returns the uniqueID representation of the data type.java.lang.StringgetJavaName()Returns the string representation of the java class type.intgetPrimitiveSize()booleanisArray()booleanisObject()booleanisScalar()static DataTypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static DataType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
START_MARKER
public static final DataType START_MARKER
-
BOOL
public static final DataType BOOL
-
BYTE
public static final DataType BYTE
-
SHORT
public static final DataType SHORT
-
INT
public static final DataType INT
-
LONG
public static final DataType LONG
-
FLOAT
public static final DataType FLOAT
-
DOUBLE
public static final DataType DOUBLE
-
CHAR
public static final DataType CHAR
-
STRING
public static final DataType STRING
-
BOOL_ARRAY
public static final DataType BOOL_ARRAY
-
BYTE_ARRAY
public static final DataType BYTE_ARRAY
-
SHORT_ARRAY
public static final DataType SHORT_ARRAY
-
INT_ARRAY
public static final DataType INT_ARRAY
-
LONG_ARRAY
public static final DataType LONG_ARRAY
-
FLOAT_ARRAY
public static final DataType FLOAT_ARRAY
-
DOUBLE_ARRAY
public static final DataType DOUBLE_ARRAY
-
CHAR_ARRAY
public static final DataType CHAR_ARRAY
-
STRING_ARRAY
public static final DataType STRING_ARRAY
-
ENUM
public static final DataType ENUM
-
LIST
public static final DataType LIST
-
MAP
public static final DataType MAP
-
QUEUE
public static final DataType QUEUE
-
SET
public static final DataType SET
-
COLLECTION
public static final DataType COLLECTION
-
OTHER
public static final DataType OTHER
default for any other complex or object-type custom data structure, usually followed/refined by an additional user-provided custom type ID
-
END_MARKER
public static final DataType END_MARKER
-
-
Method Detail
-
values
public static DataType[] 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 (DataType c : DataType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DataType 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 namejava.lang.NullPointerException- if the argument is null
-
getID
public int getID()
Returns the uniqueID representation of the data type.- Returns:
- the uniqueID representation
-
getAsString
public java.lang.String getAsString()
Returns the string representation of the data type.- Returns:
- the string representation
-
getClassTypes
public java.util.List<java.lang.Class<?>> getClassTypes()
Returns the corresponding java class type matching the given data type- Returns:
- the matching java class type
-
getJavaName
public java.lang.String getJavaName()
Returns the string representation of the java class type.- Returns:
- the string representation of the class
-
getPrimitiveSize
public int getPrimitiveSize()
-
isArray
public boolean isArray()
-
isObject
public boolean isObject()
-
isScalar
public boolean isScalar()
-
fromByte
public static DataType fromByte(byte value)
Returns the data type matching the given uniqueID representation, if any.- Parameters:
value- the value to be searched- Returns:
- the matching data type
-
fromClassType
public static DataType fromClassType(java.lang.Class<?> classType)
Returns the data type matching the given java class type, if any.- Parameters:
classType- the value to be searched- Returns:
- the matching data type
-
fromJavaTypeString
public static DataType fromJavaTypeString(java.lang.String str)
Returns the data type matching the given java string representation, if any.- Parameters:
str- the string to be searched- Returns:
- the matching data type
-
fromString
public static DataType fromString(java.lang.String str)
Returns the data type matching the given string representation, if any.- Parameters:
str- the string to be searched- Returns:
- the matching data type
-
-