Enum 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.
    Any other complex data objects can be stored/extended using the OTHER sub-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 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
      • 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
      • COLLECTION

        public static final DataType COLLECTION
      • ENUM

        public static final DataType ENUM
      • LIST

        public static final DataType LIST
      • QUEUE

        public static final DataType QUEUE
      • 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 name
        java.lang.NullPointerException - if the argument is null
      • getAsByte

        public byte getAsByte()
        Returns the byte representation of the data type.
        Returns:
        the byte 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 long 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 byte 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