Package uk.ac.starlink.ecsv
Class EcsvDecoder<T>
java.lang.Object
uk.ac.starlink.ecsv.EcsvDecoder<T>
Decodes values in the body of an ECSV file for a given data type.
- Since:
- 28 Apr 2020
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
EcsvDecoder
(Class<T> clazz, int[] stilShape, String msg) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic EcsvDecoder
<?> createDecoder
(String datatype, String subtype) Returns an instance of this class given a datatype and optional subtype.abstract T
Attempts to decode the supplied string to a value of this decoder's type.Returns the class to which input values will be decoded.int[]
getShape()
Returns the shape of the object that is decoded, in STIL format.Returns any warning message concerning the behaviour of this decoder.
-
Constructor Details
-
EcsvDecoder
Constructor.- Parameters:
clazz
- destination classstilShape
- shape specifier in STIL formatmsg
- warning or diagnostic message concerning decoding, or null if everything is normal
-
-
Method Details
-
decode
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:
NumberFormatException
- in case of unrecognised string
-
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
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
Returns an instance of this class given a datatype and optional subtype.- Parameters:
datatype
- case-sensitive datatype namesubtype
- subtype specifier string, or null- Returns:
- decoder for datatype, or null if unknown or unsupported
-