# Class RowEvaluator

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

public class RowEvaluator extends Object
Examines unknown rows (arrays of strings) to work out what they contain. By repeatedly calling `submitRow(List)` the evaluator can refine its idea of what kind of data is represented by each column.

Since:
  21 Sep 2004
Author:
  Mark Taylor (Starlink)

## Nested Class Summary

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

## Constructor Summary

Constructors
Constructor
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

Modifier and Type
Method
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(List<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 Object

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

## Field Details

### ISO8601_REGEX

public static final 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<Boolean> BOOLEAN_DECODER
Decoder for booleans.

### SHORT_DECODER

public static final RowEvaluator.Decoder<Short> SHORT_DECODER
Decoder for shorts.

### INTEGER_DECODER

public static final RowEvaluator.Decoder<Integer> INTEGER_DECODER
Decoder for integers.

### LONG_DECODER

public static final RowEvaluator.Decoder<Long> LONG_DECODER
Decoder for longs.

### FLOAT_DECODER

public static final RowEvaluator.Decoder<Float> FLOAT_DECODER
Decoder for floats.

### DOUBLE_DECODER

public static final RowEvaluator.Decoder<Double> DOUBLE_DECODER
Decoder for doubles.

### DATE_DECODER

public static final RowEvaluator.Decoder<String> DATE_DECODER
Decoder for ISO-8601 dates.

### HMS_DECODER

public static final RowEvaluator.Decoder<String> HMS_DECODER
Decoder for HMS sexagesimal strings.

### DMS_DECODER

public static final RowEvaluator.Decoder<String> DMS_DECODER
Decoder for DMS sexagesimal strings.

### STRING_DECODER

public static final RowEvaluator.Decoder<String> STRING_DECODER
Decoder for any old string.

## Constructor Details

### 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 Details

### submitRow

public void submitRow(List<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