uk.ac.starlink.ecsv

## Class EcsvDecoder<T>

- java.lang.Object
- - uk.ac.starlink.ecsv.EcsvDecoder<T>

-     public abstract class EcsvDecoder<T>
      extends java.lang.Object

  Decodes values in the body of an ECSV file for a given data type.
  Since:
    28 Apr 2020

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `EcsvDecoder(java.lang.Class<T> clazz, int[] stilShape, java.lang.String msg)` Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static EcsvDecoder<?>` | `createDecoder(java.lang.String datatype, java.lang.String subtype)` Returns an instance of this class given a datatype and optional subtype.
    `abstract T` | `decode(java.lang.String txt)` Attempts to decode the supplied string to a value of this decoder's type.
    `java.lang.Class<T>` | `getContentClass()` Returns the class to which input values will be decoded.
    `int[]` | `getShape()` Returns the shape of the object that is decoded, in STIL format.
    `java.lang.String` | `getWarning()` Returns any warning message concerning the behaviour of this decoder.

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

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

- - ### Constructor Detail

    - #### EcsvDecoder

          protected EcsvDecoder(java.lang.Class<T> clazz,
                                int[] stilShape,
                                java.lang.String msg)

      Constructor.
      Parameters:
        `clazz` - destination class
        `stilShape` - shape specifier in STIL format
        `msg` - warning or diagnostic message concerning decoding, or null if everything is normal

  - ### Method Detail

    - #### decode

          public abstract T decode(java.lang.String txt)

      Attempts to decode the supplied string to a value of this decoder's type. The supplied string will not be null or the empty string. Implementations should work on the assumption that the supplied string is of an appropriate type for this decoder; if it is not, it is permissiable to throw a NumberFormatException.
      Parameters:
        `txt` - non-blank string to decode
      Returns:
        typed value
      Throws:
        `java.lang.NumberFormatException` - in case of unrecognised string

    - #### getContentClass

          public java.lang.Class<T> getContentClass()

      Returns the class to which input values will be decoded.
      Returns:
        destination class

    - #### getShape

          public int[] getShape()

      Returns the shape of the object that is decoded, in STIL format. That may not be the same as what was specified in the ECSV metadata, if STIL is not smart enough to make sense of it.
      Returns:
        STIL shape array, or null for scalar

    - #### getWarning

          public java.lang.String getWarning()

      Returns any warning message concerning the behaviour of this decoder.
      Returns:
        warning message to be conveyed to user concerning this column, or null if everything is normal

    - #### createDecoder

          public static EcsvDecoder<?> createDecoder(java.lang.String datatype,
                                                     java.lang.String subtype)

      Returns an instance of this class given a datatype and optional subtype.
      Parameters:
        `datatype` - case-sensitive datatype name
        `subtype` - subtype specifier string, or null
      Returns:
        decoder for datatype, or null if unknown or unsupported