Class 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 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:
        newDecoder in interface DecoderFactory<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