ByteBufs 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.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private boolean | discarding
True if we're discarding input because we're already over maxLength. |
| private final boolean | failFast
Whether or not to throw an exception as soon as we exceed maxLength. |
| private final int | maxLength
Maximum length of a frame we're willing to decode. |
| private int | offset
Last scan position. |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | LineBasedFrameDecoder(final int
the maximum length of the decoded frame.
A maxLength)TooLongFrameException is thrown if
the length of the frame exceeds this value.Creates a new decoder. |
| public | LineBasedFrameDecoder(final int
the maximum length of the decoded frame.
A maxLength, final boolean TooLongFrameException is thrown if
the length of the frame exceeds this value.whether the decoded frame should strip out the
delimiter or not stripDelimiter, final boolean If true, a failFast)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.Creates a new decoder. |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | decode(ChannelHandlerContext
the ctx, ByteBuf ChannelHandlerContext which this ByteToMessageDecoder belongs tothe in, List<Object> ByteBuf from which to read datathe out)List to which decoded messages should be addedImplements abstract io. ByteBuf to an other.
|
| protected Object | decode(ChannelHandlerContext
the ctx, ByteBuf ChannelHandlerContext which this ByteToMessageDecoder belongs tothe buffer)ByteBuf from which to read dataCreate a frame out of the |
| private void | |
| private void | |
| private int |
| discardedBytes | back to summary |
|---|---|
| private int discardedBytes | |
| discarding | back to summary |
|---|---|
| private boolean discarding True if we're discarding input because we're already over maxLength. | |
| failFast | back to summary |
|---|---|
| private final boolean failFast Whether or not to throw an exception as soon as we exceed maxLength. | |
| maxLength | back to summary |
|---|---|
| private final int maxLength Maximum length of a frame we're willing to decode. | |
| offset | back to summary |
|---|---|
| private int offset Last scan position. | |
| stripDelimiter | back to summary |
|---|---|
| private final boolean stripDelimiter | |
| LineBasedFrameDecoder | back to summary |
|---|---|
| public LineBasedFrameDecoder(final int maxLength) Creates a new decoder.
| |
| LineBasedFrameDecoder | back to summary |
|---|---|
| public LineBasedFrameDecoder(final int maxLength, final boolean stripDelimiter, final boolean failFast) Creates a new decoder.
| |
| decode | back to summary |
|---|---|
| protected final void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception Implements abstract io. Doc from io. Decode the from one
| |
| decode | back to summary |
|---|---|
| protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception Create a frame out of the
| |
| fail | back to summary |
|---|---|
| private void fail(final ChannelHandlerContext ctx, int length) | |
| fail | back to summary |
|---|---|
| private void fail(final ChannelHandlerContext ctx, String length) | |
| findEndOfLine | back to summary |
|---|---|
| private int findEndOfLine(final ByteBuf buffer) Returns the index in the buffer of the end of line found. Returns -1 if no end of line was found in the buffer. | |