Package table

Class IntegerType

All Implemented Interfaces:
Serializable, Cloneable

public class IntegerType extends MetricType
Class for integer types for data tables.
Since:
2006.09.11
See Also:
  • Field Details

    • NULL

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

    • IntegerType

      public IntegerType()
      Create an integer type. The range of values is set empty (max < min).
      Since:
      2006.09.16 (Christian Borgelt)
    • IntegerType

      public IntegerType(int min, int max)
      Create an integer type.
      Parameters:
      min - the minimum attribute value
      max - the maximum attribute value
      Since:
      2006.09.16 (Christian Borgelt)
    • IntegerType

      public IntegerType(IntegerType t)
      Create a clone of an integer type.
      Parameters:
      t - the integer 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.
      Specified by:
      getValueClass in class ColType
      Returns:
      the class used for accessing values of this type
      Since:
      2006.10.04 (Christian Borgelt)
      See Also:
    • getStorageClass

      public Class<?> getStorageClass()
      Get the class used to store values of this type.
      Specified by:
      getStorageClass in class ColType
      Returns:
      the class used for storing values of this type
      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)
    • 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 either be Number or String
      Returns:
      a value that can be used efficiently with setValueAt()
      Since:
      2006.09.16 (Christian Borgelt)
    • addValue

      public void addValue(int 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)
    • getMinNumber

      public double getMinNumber()
      Get the minimal value.
      Specified by:
      getMinNumber in class MetricType
      Returns:
      the minimal value
      Since:
      2007.02.09 (Christian Borgelt)
    • getMaxNumber

      public double getMaxNumber()
      Get the maximal value.
      Specified by:
      getMaxNumber in class MetricType
      Returns:
      the maximal value
      Since:
      2006.02.09 (Christian Borgelt)
    • getMinRaw

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

      public int 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 integer values, i.e. int[]
      index - the index of the array element to access
      Returns:
      the value as an object (of class Integer)
      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 integer values, i.e. int[]
      index - the index of the array element to set
      value - the value to set, must be an instance of Number, String, or IntegerType
      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 integer values; i.e. int[]
      index - the index of the array element to get
      Returns:
      the created string description
      Since:
      2007.02.01 (Christian Borgelt)
      See Also:
    • getNumberAt

      public double getNumberAt(Object array, int index)
      Get an array element as a number.
      Overrides:
      getNumberAt in class ColType
      Parameters:
      array - the array to retrieve an element from
      index - the array index from which to retrieve
      Returns:
      the array element as a number
      Since:
      2007.02.09 (Christian Borgelt)
    • 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 integer values; i.e. int[]
      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 integer values; i.e. int[]
      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 integer values
      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 integer from a string.
      Specified by:
      parseValue in class ColType
      Parameters:
      desc - the string description to parse
      Returns:
      the parsed integer as an Integer 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 integer 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)
    • sum

      public Object sum(Object a, Object b)
      Sum two values.
      Specified by:
      sum in class MetricType
      Parameters:
      a - the first value
      b - the second value
      Returns:
      the sum of the two values
      Since:
      2007.02.02 (Christian Borgelt)
    • diff

      public Object diff(Object a, Object b)
      Compute the difference of two values
      Specified by:
      diff in class MetricType
      Parameters:
      a - the value from which to subtract
      b - the value to subtract
      Returns:
      the difference of the two values
      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 described type
      Throws:
      IOException - if a read error occurs
      Since:
      2007.02.16 (Christian Borgelt)