uk.ac.starlink.table.formats

## Class RowEvaluator

- java.lang.Object
- - uk.ac.starlink.table.formats.RowEvaluator

-     public class RowEvaluator
      extends java.lang.Object

  Examines unknown rows (arrays of strings) to work out what they contain. By repeatedly calling `submitRow(java.util.List<java.lang.String>)` the evaluator can refine its idea of what kind of data is represented by each column.
  Since:
    21 Sep 2004

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RowEvaluator.Decoder<T>` Interface for an object that can turn a string into a cell content object.
    `static class` | `RowEvaluator.Metadata` Helper class used to group quantities which describe what the data types found in the columns of a table are.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static RowEvaluator.Decoder<?>` | `BLANK_DECODER` Decoder for values that are all blank.
    `static RowEvaluator.Decoder<java.lang.Boolean>` | `BOOLEAN_DECODER` Decoder for booleans.
    `static RowEvaluator.Decoder<java.lang.String>` | `DATE_DECODER` Decoder for ISO-8601 dates.
    `static RowEvaluator.Decoder<java.lang.String>` | `DMS_DECODER` Decoder for DMS sexagesimal strings.
    `static RowEvaluator.Decoder<java.lang.Double>` | `DOUBLE_DECODER` Decoder for doubles.
    `static RowEvaluator.Decoder<java.lang.Float>` | `FLOAT_DECODER` Decoder for floats.
    `static RowEvaluator.Decoder<java.lang.String>` | `HMS_DECODER` Decoder for HMS sexagesimal strings.
    `static RowEvaluator.Decoder<java.lang.Integer>` | `INTEGER_DECODER` Decoder for integers.
    `static java.util.regex.Pattern` | `ISO8601_REGEX` Regular expression for ISO 8601 dates.
    `static RowEvaluator.Decoder<java.lang.Long>` | `LONG_DECODER` Decoder for longs.
    `static RowEvaluator.Decoder<java.lang.Short>` | `SHORT_DECODER` Decoder for shorts.
    `static RowEvaluator.Decoder<java.lang.String>` | `STRING_DECODER` Decoder for any old string.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RowEvaluator()` Constructs a new RowEvaluator which will work out the number of columns from the data using the standard list of decoders.
    `RowEvaluator(int ncol)` Constructs a new RowEvaluator which will examine rows with a fixed number of columns using the standard list of decoders.
    `RowEvaluator(RowEvaluator.Decoder<?>[] decoders)` Constructs a new RowEvaluator which will work out the number of columns from the data using a supplied list of decoders.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `RowEvaluator.Metadata` | `getMetadata()` Returns information gleaned from previous `submitRow` calls about the kind of data that appears to be in the columns.
    `static RowEvaluator.Decoder<?>[]` | `getStandardDecoders()` Returns the standard list of decoder implementation used for identifying column types.
    `void` | `submitRow(java.util.List<java.lang.String> row)` Looks at a given row (list of strings) and records information about what sort of things it looks like it contains.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ISO8601_REGEX

          public static final java.util.regex.Pattern ISO8601_REGEX

      Regular expression for ISO 8601 dates.

    - #### BLANK_DECODER

          public static final RowEvaluator.Decoder<?> BLANK_DECODER

      Decoder for values that are all blank.

    - #### BOOLEAN_DECODER

          public static final RowEvaluator.Decoder<java.lang.Boolean> BOOLEAN_DECODER

      Decoder for booleans.

    - #### SHORT_DECODER

          public static final RowEvaluator.Decoder<java.lang.Short> SHORT_DECODER

      Decoder for shorts.

    - #### INTEGER_DECODER

          public static final RowEvaluator.Decoder<java.lang.Integer> INTEGER_DECODER

      Decoder for integers.

    - #### LONG_DECODER

          public static final RowEvaluator.Decoder<java.lang.Long> LONG_DECODER

      Decoder for longs.

    - #### FLOAT_DECODER

          public static final RowEvaluator.Decoder<java.lang.Float> FLOAT_DECODER

      Decoder for floats.

    - #### DOUBLE_DECODER

          public static final RowEvaluator.Decoder<java.lang.Double> DOUBLE_DECODER

      Decoder for doubles.

    - #### DATE_DECODER

          public static final RowEvaluator.Decoder<java.lang.String> DATE_DECODER

      Decoder for ISO-8601 dates.

    - #### HMS_DECODER

          public static final RowEvaluator.Decoder<java.lang.String> HMS_DECODER

      Decoder for HMS sexagesimal strings.

    - #### DMS_DECODER

          public static final RowEvaluator.Decoder<java.lang.String> DMS_DECODER

      Decoder for DMS sexagesimal strings.

    - #### STRING_DECODER

          public static final RowEvaluator.Decoder<java.lang.String> STRING_DECODER

      Decoder for any old string.

  - ### Constructor Detail

    - #### RowEvaluator

          public RowEvaluator()

      Constructs a new RowEvaluator which will work out the number of columns from the data using the standard list of decoders.

    - #### RowEvaluator

          public RowEvaluator(RowEvaluator.Decoder<?>[] decoders)

      Constructs a new RowEvaluator which will work out the number of columns from the data using a supplied list of decoders.

      Note the order of the supplied decoder list is significant; a type earlier in the list will be preferred over one later in the list where the data is consistent with both.

      In case of no match, a string decoder will be used, even if it does not appear in the supplied list.

      Parameters:
        `decoders` - list of allowed decoders

    - #### RowEvaluator

          public RowEvaluator(int ncol)

      Constructs a new RowEvaluator which will examine rows with a fixed number of columns using the standard list of decoders.
      Parameters:
        `ncol` - column count

  - ### Method Detail

    - #### submitRow

          public void submitRow(java.util.List<java.lang.String> row)
                         throws TableFormatException

      Looks at a given row (list of strings) and records information about what sort of things it looks like it contains.
      Parameters:
        `row` - `ncol`-element list of strings
      Throws:
        `TableFormatException` - if the number of elements in `row` is not the same as on the first call

    - #### getMetadata

          public RowEvaluator.Metadata getMetadata()

      Returns information gleaned from previous `submitRow` calls about the kind of data that appears to be in the columns.
      Returns:
        metadata

    - #### getStandardDecoders

          public static RowEvaluator.Decoder<?>[] getStandardDecoders()

      Returns the standard list of decoder implementation used for identifying column types.
      Returns:
        standard decoder list