Class SimpleDecoder<I extends DecoderInputBuffer,​O extends DecoderOutputBuffer,​E extends DecoderException>

    • Constructor Detail

      • SimpleDecoder

        protected SimpleDecoder​(I[] inputBuffers,
                                O[] outputBuffers)
        inputBuffers - An array of nulls that will be used to store references to input buffers.
        outputBuffers - An array of nulls that will be used to store references to output buffers.
    • Method Detail

      • setInitialInputBufferSize

        protected final void setInitialInputBufferSize​(int size)
        Sets the initial size of each input buffer.

        This method should only be called before the decoder is used (i.e. before the first call to dequeueInputBuffer().

        size - The required input buffer size.
      • releaseOutputBuffer

        protected void releaseOutputBuffer​(O outputBuffer)
        Releases an output buffer back to the decoder.
        outputBuffer - The output buffer being released.
      • flush

        public final void flush()
        Description copied from interface: Decoder
        Flushes the decoder. Ownership of dequeued input buffers is returned to the decoder. The caller is still responsible for releasing any dequeued output buffers.
        Specified by:
        flush in interface Decoder<I extends DecoderInputBuffer,​O extends DecoderOutputBuffer,​E extends DecoderException>
      • createInputBuffer

        protected abstract I createInputBuffer()
        Creates a new input buffer.
      • createOutputBuffer

        protected abstract O createOutputBuffer()
        Creates a new output buffer.
      • createUnexpectedDecodeException

        protected abstract E createUnexpectedDecodeException​(Throwable error)
        Creates an exception to propagate for an unexpected decode error.
        error - The unexpected decode error.
        The exception to propagate.
      • decode

        protected abstract E decode​(I inputBuffer,
                                    O outputBuffer,
                                    boolean reset)
        Decodes the inputBuffer and stores any decoded output in outputBuffer.
        inputBuffer - The buffer to decode.
        outputBuffer - The output buffer to store decoded data. The flag C.BUFFER_FLAG_DECODE_ONLY will be set if the same flag is set on inputBuffer, but may be set/unset as required. If the flag is set when the call returns then the output buffer will not be made available to dequeue. The output buffer may not have been populated in this case.
        reset - Whether the decoder must be reset before decoding.
        A decoder exception if an error occurred, or null if decoding was successful.