Interface Decoder<T extends MessageHeader,R extends MessageHeader>

Type Parameters:
T - the type of message decoded by this decoder
R - the type of message that may be generated as response (see Decoder.Result.response())
All Superinterfaces:
All Known Implementing Classes:
HttpDecoder, HttpRequestDecoder, HttpResponseDecoder, WsDecoder

public interface Decoder<T extends MessageHeader,R extends MessageHeader> extends Codec
The general interface of a decoder.
  • Method Details

    • setPeerEncoder

      Sets the peer encoder.

      Some decoders need to know the state of the encoder or the last encoded message.

      encoder - the encoder
      the decoder
    • decoding

      Returns the type of the messages decoded by this decoder.
      the value
    • decode

      Decoder.Result<R> decode(ByteBuffer in, Buffer out, boolean endOfInput) throws ProtocolException
      Decodes the next chunk of data.

      This method will never leave remaining data in the in buffer unless a header has been decoded completely and/or the out buffer is full. In either case, decoding will therefore continue when the method is invoked again with the same in buffer and another (or emptied) out buffer. It is never necessary (though possible) to add data to an existing in buffer.

      in - holds the data to be decoded
      out - gets the body data (if any) written to it
      endOfInput - true if there is no input left beyond the data currently in the in buffer (indicates end of body or no body at all)
      the result
      ProtocolException - if the message violates the HTTP
    • header

      Returns the last message (header) received.

      If a header is completed during a decode(ByteBuffer, Buffer, boolean) invocation, the result’s Decoder.Result.isHeaderCompleted() is true and the header can be retrieved using this method. It remains available until decode is invoked for a new message (i.e. is invoked again after returning a result with Codec.Result.isUnderflow() being false.

      the result