Class LineBasedFrameDecoder

  • All Implemented Interfaces:
    ChannelHandler

    public class LineBasedFrameDecoder
    extends ByteToMessageDecoder
    A decoder that splits the received Buffers on line endings.

    Both "\n" and "\r\n" are handled.

    The byte stream is expected to be in UTF-8 character encoding or ASCII. The current implementation uses direct byte to char cast and then compares that char to a few low range ASCII characters like '\n' or '\r'. UTF-8 is not using low range [0..0x7F] byte values for multibyte codepoint representations therefore fully supported by this implementation.

    For a more general delimiter-based decoder, see DelimiterBasedFrameDecoder.

    • Constructor Detail

      • LineBasedFrameDecoder

        public LineBasedFrameDecoder​(int maxLength)
        Creates a new decoder.
        Parameters:
        maxLength - the maximum length of the decoded frame. A TooLongFrameException is thrown if the length of the frame exceeds this value.
      • LineBasedFrameDecoder

        public LineBasedFrameDecoder​(int maxLength,
                                     boolean stripDelimiter,
                                     boolean failFast)
        Creates a new decoder.
        Parameters:
        maxLength - the maximum length of the decoded frame. A TooLongFrameException is thrown if the length of the frame exceeds this value.
        stripDelimiter - whether the decoded frame should strip out the delimiter or not
        failFast - If true, a TooLongFrameException is thrown as soon as the decoder notices the length of the frame will exceed maxFrameLength regardless of whether the entire frame has been read. If false, a TooLongFrameException is thrown after the entire frame that exceeds maxFrameLength has been read.