public class CsvDecoder<T extends java.lang.Number> extends java.lang.Object implements Decoder<T>
Decoder that decode data from a CSV formatted text stream into a TimeSeriesProcessor.| Constructor and Description |
|---|
CsvDecoder(java.lang.String encoding,
char delimiter,
TimeSeriesProcessorFactory<T> timeSeriesFactory,
CheckedFunction<java.lang.String,T,DecodingDataFromAdapterException> numberParser,
CheckedFunction<java.lang.String,java.time.ZonedDateTime,DecodingDataFromAdapterException> dateParser)
Initializes a new instance of the
CsvDecoder class. |
| Modifier and Type | Method and Description |
|---|---|
void |
decode(java.io.InputStream in,
java.util.List<java.lang.String> headers,
java.util.function.Consumer<DataSample<T>> mapToResult)
Decodes data from the provided stream and invoke the provided
Consumer for each decoded record. |
java.util.Map<TimeSeriesInfo<T>,TimeSeriesProcessor<T>> |
decode(java.io.InputStream in,
java.util.List<TimeSeriesInfo<T>> seriesInfo)
Decode a stream of data into a map of
TimeSeriesProcessor instances. |
java.util.List<java.lang.String> |
getDataColumnHeaders(java.io.InputStream in)
Returns the columns headers of the CSV file.
|
CheckedFunction<java.lang.String,java.time.ZonedDateTime,DecodingDataFromAdapterException> |
getDateParser()
Returns the function used to parse date fields.
|
char |
getDelimiter()
Returns the delimiter character used in the CSV file.
|
java.lang.String |
getEncoding()
Returns the encoding for the CSV file.
|
CheckedFunction<java.lang.String,T,DecodingDataFromAdapterException> |
getNumberParser()
Returns the function used to parse numeric fields.
|
public CsvDecoder(java.lang.String encoding,
char delimiter,
TimeSeriesProcessorFactory<T> timeSeriesFactory,
CheckedFunction<java.lang.String,T,DecodingDataFromAdapterException> numberParser,
CheckedFunction<java.lang.String,java.time.ZonedDateTime,DecodingDataFromAdapterException> dateParser)
CsvDecoder class.encoding - the encoding used in the CSV streamdelimiter - the character to separate columns in the CSV streamtimeSeriesFactory - the factory used to fromUrl new TimeSeriesProcessor instances.numberParser - the function used to parse numbers from the CSV streamdateParser - the function used to parse dates from the CSV streampublic java.util.List<java.lang.String> getDataColumnHeaders(java.io.InputStream in)
throws java.io.IOException,
DecodingDataFromAdapterException
in - an input stream for the CSV file.java.io.IOException - in the event of an I/O error.DecodingDataFromAdapterException - if an error occurred while decoding the CSV file.public java.util.Map<TimeSeriesInfo<T>,TimeSeriesProcessor<T>> decode(java.io.InputStream in, java.util.List<TimeSeriesInfo<T>> seriesInfo) throws java.io.IOException, DecodingDataFromAdapterException
DecoderTimeSeriesProcessor instances.decode in interface Decoder<T extends java.lang.Number>in - the input stream to decode.seriesInfo - the name of the series to extract from the streamTimeSeriesProcessor instances.java.io.IOException - in the event of an IO errorDecodingDataFromAdapterException - in the event of an decoding errorpublic void decode(java.io.InputStream in,
java.util.List<java.lang.String> headers,
java.util.function.Consumer<DataSample<T>> mapToResult)
throws java.io.IOException,
DecodingDataFromAdapterException
Consumer for each decoded record.in - the InputStream for the CSV fileheaders - a list of the headers to keep from decoded recordsmapToResult - the function to invoke for reach decoded recordjava.io.IOException - in the event of an I/O error.DecodingDataFromAdapterException - if an error occurred while decoding the CSV file.public java.lang.String getEncoding()
public char getDelimiter()
public CheckedFunction<java.lang.String,T,DecodingDataFromAdapterException> getNumberParser()
public CheckedFunction<java.lang.String,java.time.ZonedDateTime,DecodingDataFromAdapterException> getDateParser()
Copyright © 2018 Frederic Thevenet. All rights reserved.