Enum DataType

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

    public enum DataType
    extends java.lang.Enum<DataType>
    The data type.
    Author:
    harald
    • Enum Constant Detail

      • STRING

        public static final DataType STRING
        A String.
      • LARGESTRING

        public static final DataType LARGESTRING
        A very large String.
      • DATE

        public static final DataType DATE
        A Date.
      • TIME

        public static final DataType TIME
        A Time.
      • TIMESTAMP

        public static final DataType TIMESTAMP
        A Timestamp.
      • LOCALDATE

        public static final DataType LOCALDATE
        A LocalDate.
      • LOCALTIME

        public static final DataType LOCALTIME
        A LocalTime.
      • LOCALDATETIME

        public static final DataType LOCALDATETIME
        A LocalDateTime.
      • BINARY

        public static final DataType BINARY
        A Binary.
      • BIGDECIMAL

        public static final DataType BIGDECIMAL
        A BigDecimal.
      • BMONEY

        public static final DataType BMONEY
        A BMoney (tentackle type).
      • DMONEY

        public static final DataType DMONEY
        A DMoney (tentackle type).
      • CHARACTER

        public static final DataType CHARACTER
        A Character.
      • CHARACTER_PRIMITIVE

        public static final DataType CHARACTER_PRIMITIVE
        A char (primitive).
      • BOOLEAN

        public static final DataType BOOLEAN
        A Boolean.
      • BOOLEAN_PRIMITIVE

        public static final DataType BOOLEAN_PRIMITIVE
        A boolean (primitive).
      • BYTE

        public static final DataType BYTE
        A Byte.
      • BYTE_PRIMITIVE

        public static final DataType BYTE_PRIMITIVE
        A byte (primitive).
      • SHORT

        public static final DataType SHORT
        A Short.
      • SHORT_PRIMITIVE

        public static final DataType SHORT_PRIMITIVE
        A short (primitive).
      • INTEGER

        public static final DataType INTEGER
        A Integer.
      • INTEGER_PRIMITIVE

        public static final DataType INTEGER_PRIMITIVE
        An int (primitive).
      • LONG

        public static final DataType LONG
        A Long.
      • LONG_PRIMITIVE

        public static final DataType LONG_PRIMITIVE
        A long (primitive).
      • FLOAT

        public static final DataType FLOAT
        A Float.
      • FLOAT_PRIMITIVE

        public static final DataType FLOAT_PRIMITIVE
        A float (primitive).
      • DOUBLE

        public static final DataType DOUBLE
        A Double.
      • DOUBLE_PRIMITIVE

        public static final DataType DOUBLE_PRIMITIVE
        A double (primitive).
      • APPLICATION

        public static final DataType APPLICATION
        Application specific type.
        Such types are immutable because they just convert data between internal and external representation. In most cases this is an enum.
    • 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
      • createFromJavaType

        public static DataType createFromJavaType​(java.lang.String javaType)
        Creates a datatype from a java type string.
        Parameters:
        javaType - the java type
        Returns:
        the datatype, null if no such type
      • isPrimitive

        public boolean isPrimitive()
        Returns whether type is a primitive.
        Returns:
        true if primitive
      • isMutable

        public boolean isMutable()
        Returns whether type is a mutable java object.
        Mutable objects may change their state and must implement Freezable.
        Returns:
        true if mutable and freezable
      • isNumeric

        public boolean isNumeric()
        Returns whether this is a numeric type.
        Returns:
        true if numeric
      • isDateOrTime

        public boolean isDateOrTime()
        Returns whether this is a date and/or time type.
        Returns:
        true if date or time type
      • isBool

        public boolean isBool()
        Returns whether this is a boolean or Boolean type.
        Returns:
        true if bool
      • getSqlTypes

        public org.tentackle.sql.SqlType[] getSqlTypes()
        Gets the sql type.
        Notice that a tentackle type may be mapped to more than one column for multi-column types such as BMoney.
        Returns:
        the sql type(s)
      • getSqlTypesWithPostfix

        public DataType.SqlTypeWithPostfix[] getSqlTypesWithPostfix()
        Gets the SqlTypes along with their column name postfixes.

        The first postfix is always the empty string. The second one is "_2", third "_3" and so on. This is a tentackle convention for multi-column types such as BMoney.

        Returns:
        the sq; types and their postfixes
      • isMultiColumn

        public boolean isMultiColumn()
        True if this is a multicolumn type.
        Returns:
        true if multicolumn
      • isScaleInSecondColumn

        public boolean isScaleInSecondColumn()
        Returns whether this is a numeric type with the scale stored in a second column.

        BMoney and Dmoney for example.

        Returns:
        true if scale in second column
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<DataType>
      • toPrimitive

        public DataType toPrimitive()
        Converts to a Java primitive.
        Returns:
        the primitive type, never null
      • toNonPrimitive

        public DataType toNonPrimitive()
        Converts a primitive to a Java class.
        Returns:
        the non-primitive type, never null
      • parse

        public java.lang.Object parse​(java.lang.String str)
        Parses a string and converts to the value of this type.

        Notice: the method doesn't use any locale, so the results are always the same regardless of the JVM's locale.

        Parameters:
        str - the source string
        Returns:
        the value
      • print

        public java.lang.String print​(java.lang.Object object)
        Takes an object and converts it to a string that can in turn be parsed with parse(java.lang.String).
        Parameters:
        object - the object of this DataType
        Returns:
        the printable string