# DataType (ARX Developer Documentation)

org.deidentifier.arx

## Class DataType<T>

- java.lang.Object
- - org.deidentifier.arx.DataType<T>

- Type Parameters:
    `T` -
  All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator<T>
  Direct Known Subclasses:
    DataType.ARXDate, DataType.ARXDecimal, DataType.ARXInteger, DataType.ARXOrderedString, DataType.ARXString

      public abstract class DataType<T>
      extends java.lang.Object
      implements java.io.Serializable, java.util.Comparator<T>

  This class provides access to the data types supported by the ARX framework.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DataType.ARXDate` Base class for date/time types.
    `static class` | `DataType.ARXDecimal` Base class for numeric types.
    `static class` | `DataType.ARXInteger` Base class for numeric types.
    `static class` | `DataType.ARXOrderedString` Base class for ordered string types.
    `static class` | `DataType.ARXString` Base class for string types.
    `static class` | `DataType.DataTypeDescription<T>` An entry in the list of available data types.
    `static interface` | `DataType.DataTypeWithFormat` An interface for data types with format.
    `static interface` | `DataType.DataTypeWithRatioScale<T>` An interface for data types with a ratio scale.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ANY_VALUE` The string representing the ANY value
    `static DataType<java.util.Date>` | `DATE` A date data type with default format dd.mm.yyyy
    `static DataType<java.lang.Double>` | `DECIMAL` A generic decimal data type.
    `static DataType<java.lang.Long>` | `INTEGER` A generic integer data type.
    `static java.lang.String` | `NULL_VALUE` The string representing the NULL value
    `static DataType<java.lang.String>` | `ORDERED_STRING` A ordered string data type.
    `static DataType<java.lang.String>` | `STRING` A string data type.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataType()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract DataType<T>` | `clone()`
    `abstract int` | `compare(java.lang.String s1, java.lang.String s2)` Compares two values.
    `abstract int` | `compare(T t1, T t2)` Compare.
    `AggregateFunction.AggregateFunctionBuilder<T>` | `createAggregate()` Returns a new function builder.
    `static DataType<java.util.Date>` | `createDate(java.lang.String format)` A date data type with given format.
    `static DataType<java.util.Date>` | `createDate(java.lang.String format, java.util.Locale locale)` A date data type with given format.
    `static DataType<java.lang.Double>` | `createDecimal(java.lang.String format)` A decimal data type with given format.
    `static DataType<java.lang.Double>` | `createDecimal(java.lang.String format, java.util.Locale locale)` Creates a decimal data type with a format string from the given locale.
    `static DataType<java.lang.Long>` | `createInteger(java.lang.String format)` An integer data type with given format.
    `static DataType<java.lang.Long>` | `createInteger(java.lang.String format, java.util.Locale locale)` An integer data type with given format using the given locale.
    `static DataType<java.lang.String>` | `createOrderedString(java.util.List<java.lang.String> format)` A ordered string type with given format.
    `static DataType<java.lang.String>` | `createOrderedString(java.lang.String format)` A ordered string type with given format.
    `static DataType<java.lang.String>` | `createOrderedString(java.lang.String[] format)` A ordered string type with given format.
    `abstract boolean` | `equals(java.lang.Object other)`
    `abstract java.lang.String` | `format(T t)` Converts a value into a string.
    `abstract DataType.DataTypeDescription<T>` | `getDescription()` Returns a description of the data type.
    `abstract int` | `hashCode()`
    `static boolean` | `isAny(java.lang.String value)` Returns whether the value represents any value
    `static boolean` | `isNull(java.lang.String value)` Returns whether the value represents null
    `abstract boolean` | `isValid(java.lang.String s)` Checks whether the given string conforms to the data type's format.
    `static java.util.List<DataType.DataTypeDescription<?>>` | `list()` Lists all available data types.
    `static <U> DataType.DataTypeDescription<U>` | `list(java.lang.Class<U> clazz)` Returns a datatype for the given class.
    `abstract T` | `parse(java.lang.String s)` Converts a string into a value.

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NULL_VALUE

          public static final java.lang.String NULL_VALUE

      The string representing the NULL value
      See Also:
        Constant Field Values

    - #### ANY_VALUE

          public static final java.lang.String ANY_VALUE

      The string representing the ANY value
      See Also:
        Constant Field Values

    - #### DATE

          public static final DataType<java.util.Date> DATE

      A date data type with default format dd.mm.yyyy

    - #### DECIMAL

          public static final DataType<java.lang.Double> DECIMAL

      A generic decimal data type.

    - #### INTEGER

          public static final DataType<java.lang.Long> INTEGER

      A generic integer data type.

    - #### STRING

          public static final DataType<java.lang.String> STRING

      A string data type.

    - #### ORDERED_STRING

          public static final DataType<java.lang.String> ORDERED_STRING

      A ordered string data type.

  - ### Constructor Detail

    - #### DataType

          public DataType()

  - ### Method Detail

    - #### createDate

          public static final DataType<java.util.Date> createDate(java.lang.String format)

      A date data type with given format.
      Parameters:
        `format` -
      Returns:
      See Also:
        `SimpleDateFormat`

    - #### createDate

          public static final DataType<java.util.Date> createDate(java.lang.String format,
                                            java.util.Locale locale)

      A date data type with given format.
      Parameters:
        `format` -
        `locale` -
      Returns:
      See Also:
        `SimpleDateFormat`

    - #### createDecimal

          public static final DataType<java.lang.Double> createDecimal(java.lang.String format)

      A decimal data type with given format.
      Parameters:
        `format` -
      Returns:
      See Also:
        `DecimalFormat`

    - #### createDecimal

          public static DataType<java.lang.Double> createDecimal(java.lang.String format,
                                                 java.util.Locale locale)

      Creates a decimal data type with a format string from the given locale.
      Parameters:
        `format` -
        `locale` -
      Returns:

    - #### createInteger

          public static final DataType<java.lang.Long> createInteger(java.lang.String format)

      An integer data type with given format.
      Parameters:
        `format` -
      Returns:
      See Also:
        `DecimalFormat`

    - #### createInteger

          public static final DataType<java.lang.Long> createInteger(java.lang.String format,
                                               java.util.Locale locale)

      An integer data type with given format using the given locale.
      Parameters:
        `format` -
        `locale` -
      Returns:
      See Also:
        `DecimalFormat`

    - #### createOrderedString

          public static final DataType<java.lang.String> createOrderedString(java.util.List<java.lang.String> format)

      A ordered string type with given format.
      Parameters:
        `format` - List of ordered strings
      Returns:

    - #### createOrderedString

          public static final DataType<java.lang.String> createOrderedString(java.lang.String format)

      A ordered string type with given format.
      Parameters:
        `format` - List of ordered strings separated by line feeds
      Returns:

    - #### createOrderedString

          public static final DataType<java.lang.String> createOrderedString(java.lang.String[] format)

      A ordered string type with given format.
      Parameters:
        `format` - List of ordered strings
      Returns:

    - #### isAny

          public static final boolean isAny(java.lang.String value)

      Returns whether the value represents any value
      Parameters:
        `value` -
      Returns:

    - #### isNull

          public static final boolean isNull(java.lang.String value)

      Returns whether the value represents null
      Parameters:
        `value` -
      Returns:

    - #### list

          public static final java.util.List<DataType.DataTypeDescription<?>> list()

      Lists all available data types.
      Returns:

    - #### list

          public static final <U> DataType.DataTypeDescription<U> list(java.lang.Class<U> clazz)

      Returns a datatype for the given class.
      Type Parameters:
        `U` -
      Parameters:
        `clazz` -
      Returns:

    - #### clone

          public abstract DataType<T> clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### compare

          public abstract int compare(java.lang.String s1,
                    java.lang.String s2)
                               throws java.lang.NumberFormatException,
                                      java.text.ParseException

      Compares two values. The result is 0 if both values are equal, less than 0 if the first value is less than the second argument, and greater than 0 if the first value is greater than the second argument.
      Parameters:
        `s1` -
        `s2` -
      Returns:
      Throws:
        `java.lang.NumberFormatException`
        `java.text.ParseException`

    - #### compare

          public abstract int compare(T t1,
                    T t2)

      Compare.
      Specified by:
        `compare` in interface `java.util.Comparator<T>`
      Parameters:
        `t1` -
        `t2` -
      Returns:

    - #### createAggregate

          public AggregateFunction.AggregateFunctionBuilder<T> createAggregate()

      Returns a new function builder.
      Returns:

    - #### equals

          public abstract boolean equals(java.lang.Object other)

      Specified by:
        `equals` in interface `java.util.Comparator<T>`
      Overrides:
        `equals` in class `java.lang.Object`

    - #### format

          public abstract java.lang.String format(T t)

      Converts a value into a string.
      Parameters:
        `t` -
      Returns:

    - #### getDescription

          public abstract DataType.DataTypeDescription<T> getDescription()

      Returns a description of the data type.
      Returns:

    - #### hashCode

          public abstract int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### isValid

          public abstract boolean isValid(java.lang.String s)

      Checks whether the given string conforms to the data type's format.
      Parameters:
        `s` -
      Returns:

    - #### parse

          public abstract T parse(java.lang.String s)

      Converts a string into a value.
      Parameters:
        `s` -
      Returns: