Package table

Class DateType

All Implemented Interfaces:
Serializable, Cloneable

public class DateType extends OrdinalType
Class for date-valued types for data tables.
Since:
2006.10.04
See Also:
  • Field Details

    • NULL

      public static final long NULL
      a null value (of the storage class)
      See Also:
  • Constructor Details

    • DateType

      public DateType()
      Create a date-valued type. The range of values is set empty (max < min).
      Since:
      2006.10.04 (Christian Borgelt)
    • DateType

      public DateType(DateFormat fmt)
      Create a date-valued type. The range of values is set empty (max < min).
      Parameters:
      fmt - the date format
      Since:
      2006.10.04 (Christian Borgelt)
    • DateType

      public DateType(DateFormat fmt, long min, long max)
      Create a date-valued type.
      Parameters:
      fmt - the date format
      min - the minimum value
      max - the maximum value
      Since:
      2006.10.04 (Christian Borgelt)
    • DateType

      public DateType(DateType t)
      Create a clone of a date-valued type.
      Parameters:
      t - the date-valued type to clone
      Since:
      2006.11.15 (Christian Borgelt)
  • Method Details

    • clone

      public Object clone()
      Clone this type.
      Specified by:
      clone in class ColType
      Returns:
      a clone of this type
      Since:
      2006.10.06 (Christian Borgelt)
    • getName

      public String getName()
      Get the name of the type.
      Overrides:
      getName in class ColType
      Returns:
      the name of the type
      Since:
      2007.02.13 (Christian Borgelt)
    • getValueClass

      public Class<?> getValueClass()
      Get the class used to access values of this type, that is, Date.class.
      Specified by:
      getValueClass in class ColType
      Returns:
      Date.class
      Since:
      2006.10.04 (Christian Borgelt)
      See Also:
    • getStorageClass

      public Class<?> getStorageClass()
      Get the class used to store values of this type, that is, long.class.
      Specified by:
      getStorageClass in class ColType
      Returns:
      long.class
      Since:
      2006.10.04 (Christian Borgelt)
      See Also:
    • fits

      public boolean fits(Object array)
      Check whether an array fits this type.

      This function need not really be here, since the generic version in ColType.java yields the same result. However, this version is more efficient.

      Overrides:
      fits in class ColType
      Parameters:
      array - the array to check
      Returns:
      whether the array has the correct type
      Since:
      2007.02.02 (Christian Borgelt)
    • getFormat

      public DateFormat getFormat()
      Get the format used for parsing and formatting.
      Returns:
      the format used for parsing and printing
      Since:
      2007.01.31 (Christian Borgelt)
    • addValue

      public Object addValue(Object value)
      Add a value. The range of values is adapted.
      Overrides:
      addValue in class ColType
      Parameters:
      value - the value to add, must be an object of class Long, Date, or String
      Returns:
      a value that can be used efficiently with setValueAt()
      Since:
      2006.09.16 (Christian Borgelt)
    • addValue

      public void addValue(long value)
      Add a value. The range of values is adapted.
      Parameters:
      value - the value to add
      Since:
      2006.09.16 (Christian Borgelt)
    • clear

      public void clear()
      Clear the range of values.
      Specified by:
      clear in class ColType
      Since:
      2007.07.19 (Christian Borgelt)
    • getMin

      public Object getMin()
      Get the minimal value.
      Specified by:
      getMin in class OrdinalType
      Returns:
      the minimal value
      Since:
      2007.02.02 (Christian Borgelt)
    • getMax

      public Object getMax()
      Get the maximal value.
      Specified by:
      getMax in class OrdinalType
      Returns:
      the maximal value
      Since:
      2007.02.02 (Christian Borgelt)
    • getMinRaw

      public long getMinRaw()
      Get the minimal value.
      Returns:
      the minimal value
      Since:
      2007.02.02 (Christian Borgelt)
    • getMaxRaw

      public long getMaxRaw()
      Get the maximal value.
      Returns:
      the maximal value
      Since:
      2007.02.02 (Christian Borgelt)
    • getValueAt

      public Object getValueAt(Object array, int index)
      Get an array element as an object.
      Overrides:
      getValueAt in class ColType
      Parameters:
      array - an array of dates, i.e. long[]
      index - the index of the array element to get
      Returns:
      the value as an object
      Since:
      2006.09.26 (Christian Borgelt)
    • setValueAt

      public void setValueAt(Object array, int index, Object value)
      Set an array element from an object.
      Overrides:
      setValueAt in class ColType
      Parameters:
      array - an array of dates, i.e. long[]
      index - the index of the array element to set
      value - the value to set, must be an object of class String, Long, or Date
      Since:
      2006.09.26 (Christian Borgelt)
    • getStringAt

      public String getStringAt(Object array, int index)
      Get an array element as a string.
      Overrides:
      getStringAt in class ColType
      Parameters:
      array - an array of dates, i.e. long[]
      index - the index of the array element to get
      Returns:
      the created string description
      Since:
      2007.02.01 (Christian Borgelt)
      See Also:
    • isNull

      public boolean isNull(Object array, int index)
      Check whether an array element is null.
      Overrides:
      isNull in class ColType
      Parameters:
      array - an array of dates, i.e. long[]
      index - the index of the array element to check
      Returns:
      whether the array element is null
      Since:
      2007.01.31 (Christian Borgelt)
      See Also:
    • setNull

      public void setNull(Object array, int index)
      Set an array element to a null value.
      Overrides:
      setNull in class ColType
      Parameters:
      array - an array of dates, i.e. long[]
      index - the index of the array element to set
      Since:
      2007.01.31 (Christian Borgelt)
      See Also:
    • setNull

      public void setNull(Object array, int beg, int end)
      Set a range of array elements to a null value.
      Overrides:
      setNull in class ColType
      Parameters:
      array - an array of dates
      beg - the index of the first array element (inclusive)
      end - the index of the last array element (exclusive)
      Since:
      2007.07.13 (Christian Borgelt)
      See Also:
    • parseValue

      public Object parseValue(String desc)
      Parse an instance from a string.
      Specified by:
      parseValue in class ColType
      Parameters:
      desc - the string description to parse
      Returns:
      the parsed object or null if parsing failed
      Since:
      2007.02.01 (Christian Borgelt)
      See Also:
    • toString

      public String toString()
      Create a string description.
      Overrides:
      toString in class ColType
      Returns:
      a string description of the type
      Since:
      2007.02.02 (Christian Borgelt)
    • compare

      public int compare(Object a, Object b)
      Compare two date values.
      Specified by:
      compare in class OrdinalType
      Parameters:
      a - the first value
      b - the second value
      Returns:
      -1 if the first value is smaller,
      +1 if the second value is smaller,
      0 if the value are equal
      Since:
      2007.02.02 (Christian Borgelt)
    • parseType

      public static ColType parseType(util.Scanner scan) throws IOException
      Parse a type description.
      Parameters:
      scan - the scanner to read from
      Returns:
      the column type read from the description
      Throws:
      IOException - if a read error occurs
      Since:
      2007.02.16 (Christian Borgelt)