Interface Encoder<T extends MessageHeader,D extends MessageHeader>

Type Parameters:
T - the type of the message header to be encoded
D - the type of the message header decoded by the peer decoder
All Superinterfaces:
Codec
All Known Implementing Classes:
HttpEncoder, HttpRequestEncoder, HttpResponseEncoder, WsEncoder

public interface Encoder<T extends MessageHeader,D extends MessageHeader> extends Codec
The general interface of an encoder.
  • Method Details

    • setPeerDecoder

      Sets the peer decoder.

      Some decoder implementations need to know the state of the decoder or the last decoded message.

      Parameters:
      decoder - the decoder
      Returns:
      the encoder
    • encoding

      Returns the type of the messages encoded by this encoder.
      Returns:
      the value
    • encode

      void encode(T messageHeader)
      Set the header of the message that is to be encoded.

      Must be invoked before the first invocation to any encode method for a given message.

      Parameters:
      messageHeader - the message header
    • encode

      Codec.Result encode(Buffer in, ByteBuffer out, boolean endOfInput)
      Encodes a message.

      First encodes the message header set by encode(MessageHeader) and then (optionally) adds payload data from in.

      Parameters:
      in - the body data
      out - the buffer to which data is written
      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)
      Returns:
      the result
    • encode

      Convenience method for invoking encode(Buffer, ByteBuffer, boolean) with an empty in buffer and true.

      Can be used to get the result of encoding a message without body.

      Parameters:
      out - the buffer to which data is written
      Returns:
      the result
    • header

      Returns the last message (header) encoded.
      Returns:
      the result