Class TxtDecoderFactory<T>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.TxtDecoderFactory<T>
-
- Type Parameters:
T- The data type of the decoded items
- All Implemented Interfaces:
DecoderFactory<T>
public class TxtDecoderFactory<T> extends Object implements DecoderFactory<T>
AnDecoderFactorythat decodes items from a textual form, assuming that items are delimited by "\n". See alsoTxtEncoderFactory.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description TxtDecoderFactory(FailableFunction<String,T,? extends ValidationPipeException> itemDetextualizer)Constructor Assumes UTF8 text encoding.TxtDecoderFactory(FailableFunction<String,T,? extends ValidationPipeException> itemDetextualizer, Charset charset)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteArrayDecoder<T>newByteArrayDecoder()ItemDecoder<T>newDecoder(InputStream is, FileReadOptions readOptions)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pipecraft.pipes.serialization.DecoderFactory
newDecoder
-
-
-
-
Constructor Detail
-
TxtDecoderFactory
public TxtDecoderFactory(FailableFunction<String,T,? extends ValidationPipeException> itemDetextualizer, Charset charset)
Constructor- Parameters:
itemDetextualizer- A converter from the textual form to the item itselfcharset- The charset encoding to use for decoding
-
TxtDecoderFactory
public TxtDecoderFactory(FailableFunction<String,T,? extends ValidationPipeException> itemDetextualizer)
Constructor Assumes UTF8 text encoding.- Parameters:
itemDetextualizer- A converter from the textual form to the item itself
-
-
Method Detail
-
newDecoder
public ItemDecoder<T> newDecoder(InputStream is, FileReadOptions readOptions) throws IOException
- Specified by:
newDecoderin interfaceDecoderFactory<T>- Parameters:
is- The input stream the decoder should be bound to. Not expected to be buffered. Buffering is added by the decoder.readOptions- defines how the input stream should be handled- Returns:
- The new decoder
- Throws:
IOException- In case of an IO error while preparing to read from the input stream
-
newByteArrayDecoder
public ByteArrayDecoder<T> newByteArrayDecoder()
- Specified by:
newByteArrayDecoderin interfaceDecoderFactory<T>- Returns:
- A new
ByteArrayDecoder, able to efficiently decode individual items from byte arrays. The default implementation goes through aByteArrayInputStreamand is not very efficient, so sub-classes are encouraged to override it when a faster alternative is available.
-
-