Class SimpleDecoderFactory<T>
- java.lang.Object
-
- org.pipecraft.pipes.serialization.SimpleDecoderFactory<T>
-
- Type Parameters:
T- The data type of the decoded objects
- All Implemented Interfaces:
DecoderFactory<T>
public class SimpleDecoderFactory<T> extends Object implements DecoderFactory<T>
A simple generic decoder factory implementation. Handles input stream buffering and closing. Uses a simplified stateless input stream decoder function given in the ctor.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description SimpleDecoderFactory(FailableFunction<InputStream,T,? extends IOException> statelessDecoder)ConstructorSimpleDecoderFactory(FailableFunction<InputStream,T,? extends IOException> statelessDecoder, ByteArrayDecoder<T> byteArrDecoder)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
-
SimpleDecoderFactory
public SimpleDecoderFactory(FailableFunction<InputStream,T,? extends IOException> statelessDecoder)
Constructor- Parameters:
statelessDecoder- A function receiving a (buffered) input stream, reading & returning the next item read from it.
-
SimpleDecoderFactory
public SimpleDecoderFactory(FailableFunction<InputStream,T,? extends IOException> statelessDecoder, ByteArrayDecoder<T> byteArrDecoder)
Constructor- Parameters:
statelessDecoder- A function recieving a (buffered) input stream, reading & returning the next item read from it.byteArrDecoder- The byte array decoder to be returned by the newByteArrayDecoder() function.
-
-
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.
-
-