Class DelegatingCodecFactory<T>

  • Type Parameters:
    T - The encoded/decoded items' data type
    All Implemented Interfaces:
    CodecFactory<T>, DecoderFactory<T>, EncoderFactory<T>
    Direct Known Subclasses:
    TxtCodecFactory

    public class DelegatingCodecFactory<T>
    extends Object
    implements CodecFactory<T>
    Wraps a given encoder and decoder factories, and delegates encoding/decoding creation requests to them.
    Author:
    Eyal Schneider
    • Constructor Detail

      • DelegatingCodecFactory

        public DelegatingCodecFactory​(EncoderFactory<T> encoder,
                                      DecoderFactory<T> decoder)
        Constructor
        Parameters:
        encoder - The encoder factory
        decoder - The decoder factory
    • 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
      • newEncoder

        public ItemEncoder<T> newEncoder​(OutputStream os,
                                         FileWriteOptions writeOptions)
                                  throws IOException
        Specified by:
        newEncoder in interface EncoderFactory<T>
        Parameters:
        os - The output stream the encoder should be bound to. Not expected to be buffered. The encoder handles buffering.
        writeOptions - The way the output stream should be handled
        Returns:
        The new encoder
        Throws:
        IOException - In case of an IO error while preparing to write to the output stream