Class DataType

    • Constructor Detail

      • DataType

        protected DataType()
      • DataType

        protected DataType​(java.lang.String encoding,
                           boolean nullable)
    • Method Detail

      • clone

        public DataType clone()
        Overrides:
        clone in class java.lang.Object
      • nullableInstance

        public final DataType nullableInstance​(boolean nullable)
      • getEncoding

        public final java.lang.String getEncoding()
      • isNullable

        public boolean isNullable()
      • setNullable

        public void setNullable​(boolean nullable)
      • parseEncoding

        public void parseEncoding​(java.lang.String encoding)
      • parseBoolean

        public static boolean parseBoolean​(java.lang.String s)
      • parseByte

        public static byte parseByte​(java.lang.String s)
      • parseShort

        public static short parseShort​(java.lang.String s)
      • parseInt

        public static int parseInt​(java.lang.String s)
      • parseLong

        public static long parseLong​(java.lang.String s)
      • parseDouble

        public static double parseDouble​(java.lang.String s)
      • parseFloat

        public static float parseFloat​(java.lang.String s)
      • parseDate

        public static long parseDate​(java.lang.String s)
      • toBoxedImpl

        protected abstract java.lang.Object toBoxedImpl​(java.lang.CharSequence text)
        Parse non-null text and return an object without checking constraints.
      • toStringImpl

        protected abstract java.lang.String toStringImpl​(java.lang.Object obj)
        Converts a non-null, constraint-compliant Boxed value to String.
        Parameters:
        obj - A non-null, valid value.
        Returns:
        A String representation.
      • unsupportedType

        protected final java.lang.IllegalArgumentException unsupportedType​(java.lang.Object obj)
        Helper method to construct an exception thrown when object type passed to toString(java.lang.Object) or assertValid(java.lang.Object) is completely illegal.
        Parameters:
        obj - The culprit.
        Returns:
        An exception to throw.
      • outOfRange

        protected final java.lang.IllegalArgumentException outOfRange​(java.lang.Object obj,
                                                                      java.lang.Object min,
                                                                      java.lang.Object max)
        Helper method to construct an exception thrown when a value passed to toString(java.lang.Object) or assertValid(java.lang.Object) is out of range.
        Parameters:
        obj - The culprit.
        min - Inclusive minimum.
        max - Inclusive maximum.
        Returns:
        An exception to throw.
      • assertValidImpl

        protected abstract void assertValidImpl​(java.lang.Object obj)
        Checks a non-null Boxed value against constraints, if any. If the object is of unsupported type, this method should throw unsupportedType(java.lang.Object).
        Parameters:
        obj - A Boxed representation of a value.
        Throws:
        java.lang.IllegalArgumentException - If constraints are violated.
      • parse

        public final java.lang.Object parse​(java.lang.CharSequence value)
        Convert the String representation to Boxed, also validating it against constraints, if any.

        Boxed return type should be the same independently from encoding. For example: Long for all INTEGER encodings INT8, INT16 ... INT64

        Parameters:
        value - String representation.
        Returns:
        Boxed representation or null if the argument is null.
      • getCode

        public abstract int getCode()
      • toString

        public final java.lang.String toString​(java.lang.Object obj)
        Convert the Boxed representation to String, also validating it against constraints, if any.
        Parameters:
        obj -
      • assertValid

        public final void assertValid​(java.lang.Object obj)
        Checks a Boxed value against constraints, if any. Overriding methods must call the superclass implementation first.
        Parameters:
        obj - A Boxed representation of a value.
        Throws:
        java.lang.IllegalArgumentException - If constraints are violated.
      • getBaseName

        public abstract java.lang.String getBaseName()
      • writeTo

        public void writeTo​(java.io.DataOutputStream out)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readFields

        protected void readFields​(java.io.DataInputStream in,
                                  ClassDescriptor.TypeResolver resolver)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • isPrimitive

        public boolean isPrimitive()