ByteBufs 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 ByteBuf[] | |
| 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, ByteBuf TooLongFrameException is thrown if
the length of the frame exceeds this value.the delimiter delimiter)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, ByteBuf the delimiter delimiter)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, ByteBuf 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 delimiter delimiter)Creates a new instance. |
| public | DelimiterBasedFrameDecoder(int
the maximum length of the decoded frame.
A maxFrameLength, ByteBuf... 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, ByteBuf... 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, ByteBuf... 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 |
|---|---|
| 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 static int | |
| private static boolean | |
| private boolean | |
| private static void | |
| private static void |
| delimiters | back to summary |
|---|---|
| private final ByteBuf[] 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, ByteBuf delimiter) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, ByteBuf delimiter) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, boolean failFast, ByteBuf delimiter) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, ByteBuf... delimiters) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, ByteBuf... delimiters) Creates a new instance.
| |
| DelimiterBasedFrameDecoder | back to summary |
|---|---|
| public DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, boolean failFast, ByteBuf... delimiters) Creates a new instance.
| |
| 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(long frameLength) | |
| indexOf | back to summary |
|---|---|
| private static int indexOf(ByteBuf haystack, ByteBuf 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 ByteBuf[] 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(ByteBuf delimiter) | |
| validateMaxFrameLength | back to summary |
|---|---|
| private static void validateMaxFrameLength(int maxFrameLength) | |