Buffers by one or more
delimiters. It is particularly useful for decoding the frames which ends
with a delimiter such as NUL or
newline characters.
Delimiters defines frequently used delimiters for convenience' sake.
DelimiterBasedFrameDecoder allows you to specify more than one
delimiter. If more than one delimiter is found in the buffer, it chooses
the delimiter which produces the shortest frame. For example, if you have
the following data in the buffer:
+--------------+ | ABC\nDEF\r\n | +--------------+a
DelimiterBasedFrameDecoder(Delimiters.lineDelimiter() )
will choose '\n' as the first delimiter and produce two frames:
+-----+-----+ | ABC | DEF | +-----+-----+rather than incorrectly choosing
'\r\n' as the first delimiter:
+----------+ | ABC\nDEF | +----------+
| Modifier and Type | Field and Description |
|---|---|
| private final Buffer[] | |
| private boolean | |
| private final boolean | |
| private final LineBasedFrameDecoder | lineBasedDecoder
Set only when decoding with "\n" and "\r\n" as the delimiter. |
| private final int | |
| private final boolean | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | DelimiterBasedFrameDecoder(int
the maximum length of the decoded frame.
A maxFrameLength, Buffer... TooLongFrameException is thrown if
the length of the frame exceeds this value.the delimiters delimiters)Creates a new instance. |
| public | DelimiterBasedFrameDecoder(int
the maximum length of the decoded frame.
A maxFrameLength, 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, Buffer... the delimiters delimiters)Creates a new instance. |
| public | DelimiterBasedFrameDecoder(int
the maximum length of the decoded frame.
A maxFrameLength, 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, boolean If true, a failFast, Buffer... 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.the delimiters delimiters)Creates a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| protected final void | decode(ChannelHandlerContext
the ctx, Buffer ChannelHandlerContext which this ByteToMessageDecoder belongs tothe in)Buffer from which to read dataImplements abstract io. Buffer to another.
|
| protected Object | decode0(ChannelHandlerContext
the ctx, Buffer ChannelHandlerContext which this ByteToMessageDecoder belongs tothe buffer)Buffer from which to read dataCreate a frame out of the |
| private void | |
| protected void | handlerRemoved0(ChannelHandlerContext ctx)
Overrides io. ByteToMessageDecoder was removed from the actual context and it doesn't
handle events anymore.
|
| private static int | |
| private static boolean | |
| private boolean | |
| private static void | |
| private static void |
| delimiters | back to summary |
|---|---|
| private final Buffer[] delimiters | |
| discardingTooLongFrame | back to summary |
|---|---|
| private boolean discardingTooLongFrame | |
| failFast | back to summary |
|---|---|
| private final boolean failFast | |
| lineBasedDecoder | back to summary |
|---|---|
| private final LineBasedFrameDecoder lineBasedDecoder Set only when decoding with "\n" and "\r\n" as the delimiter. | |
| maxFrameLength | back to summary |
|---|---|
| private final int maxFrameLength | |
| stripDelimiter | back to summary |
|---|---|
| private final boolean stripDelimiter | |
| tooLongFrameLength | back to summary |
|---|---|
| private int tooLongFrameLength | |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, Buffer... delimiters) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, Buffer... delimiters) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, boolean failFast, Buffer... delimiters) Creates a new instance.
| |
| closeDelimiters | back to summary |
|---|---|
| private static void closeDelimiters(Buffer[] delimiters) | |
| decode | back to summary |
|---|---|
| protected final void decode(ChannelHandlerContext ctx, Buffer in) throws Exception Implements abstract io. Doc from io. Decode the from one
| |
| decode0 | back to summary |
|---|---|
| protected Object decode0(ChannelHandlerContext ctx, Buffer buffer) Create a frame out of the
| |
| fail | back to summary |
|---|---|
| private void fail(long frameLength) | |
| handlerRemoved0 | back to summary |
|---|---|
| protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception Overrides io. Doc from io. Gets called after the
| |
| indexOf | back to summary |
|---|---|
| private static int indexOf(Buffer haystack, Buffer needle) Returns the number of bytes between the readerIndex of the haystack and the first needle found in the haystack. -1 is returned if no needle is found in the haystack. | |
| isLineBased | back to summary |
|---|---|
| private static boolean isLineBased(final Buffer[] delimiters) Returns true if the delimiters are "\n" and "\r\n". | |
| isSubclass | back to summary |
|---|---|
| private boolean isSubclass() Return | |
| validateDelimiter | back to summary |
|---|---|
| private static void validateDelimiter(Buffer delimiter) | |
| validateMaxFrameLength | back to summary |
|---|---|
| private static void validateMaxFrameLength(int maxFrameLength) | |