Package table

Class StringType

All Implemented Interfaces:
Serializable, Cloneable

public class StringType extends ColType
Class for string types for data tables.

A string type is similar to a nominal type. However, the values are not recoded to integers for storing, but stored directly, that is, they are stored as strings.

Since:
2007.02.13
See Also:
  • Field Details

    • NULL

      public static final String NULL
      a null value (of the storage class)
  • Constructor Details

    • StringType

      public StringType()
      Create a string type.
      Since:
      2007.02.13 (Christian Borgelt)
    • StringType

      public StringType(StringType t)
      Create a clone of a string type.
      Parameters:
      t - the string type to clone
      Since:
      2007.02.13 (Christian Borgelt)
  • Method Details

    • clone

      public Object clone()
      Clone this type.
      Specified by:
      clone in class ColType
      Returns:
      a clone of this type
      Since:
      2007.02.13 (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:
      2007.02.13 (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:
      2007.02.13 (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 storage type
      Since:
      2007.02.13 (Christian Borgelt)
    • addValue

      public Object addValue(Object value)
      Add a value, that is, adapt the range of values.
      Overrides:
      addValue in class ColType
      Parameters:
      value - the value to add
      Returns:
      a value that can be used efficiently with setValueAt()
      Since:
      2007.02.13 (Christian Borgelt)
    • clear

      public void clear()
      Clear the range of values.
      Specified by:
      clear in class ColType
      Since:
      2007.07.19 (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 string values, i.e. String[]
      index - the index of the array element to access
      Returns:
      the value as an object
      Since:
      2007.02.13 (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 string values, i.e. String[]
      index - the index of the array element to set
      value - the value to set
      Since:
      2007.02.13 (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 string values, i.e. String[]
      index - the index of the array element to access
      Returns:
      the created string description
      Since:
      2007.02.13 (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 string values, i.e. String[]
      index - the index of the array element to check
      Returns:
      whether the array element is null
      Since:
      2007.02.13 (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 string values, i.e. String[]
      index - the index of the array element to set
      Since:
      2007.02.13 (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 string 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 a value 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.13 (Christian Borgelt)
      See Also:
    • 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)