public class DelimiterBasedFrameDecoder extends ByteToMessageDecoder<Object>
ByteBuf
s 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 | +----------+
Constructor and Description |
---|
DelimiterBasedFrameDecoder(int maxFrameLength,
boolean stripDelimiter,
boolean failFast,
io.netty.buffer.ByteBuf... delimiters)
Creates a new instance.
|
DelimiterBasedFrameDecoder(int maxFrameLength,
boolean stripDelimiter,
boolean failFast,
io.netty.buffer.ByteBuf delimiter)
Creates a new instance.
|
DelimiterBasedFrameDecoder(int maxFrameLength,
boolean stripDelimiter,
io.netty.buffer.ByteBuf... delimiters)
Creates a new instance.
|
DelimiterBasedFrameDecoder(int maxFrameLength,
boolean stripDelimiter,
io.netty.buffer.ByteBuf delimiter)
Creates a new instance.
|
DelimiterBasedFrameDecoder(int maxFrameLength,
io.netty.buffer.ByteBuf... delimiters)
Creates a new instance.
|
DelimiterBasedFrameDecoder(int maxFrameLength,
io.netty.buffer.ByteBuf delimiter)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
Object |
decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf buffer) |
beforeAdd, callDecode, channelInactive, decodeLast, inboundBufferUpdated, newInboundBuffer, replace
afterAdd, afterRemove, beforeRemove, channelActive, channelRegistered, channelUnregistered, exceptionCaught, userEventTriggered
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public DelimiterBasedFrameDecoder(int maxFrameLength, io.netty.buffer.ByteBuf delimiter)
maxFrameLength
- the maximum length of the decoded frame.
A TooLongFrameException
is thrown if
the length of the frame exceeds this value.delimiter
- the delimiterpublic DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, io.netty.buffer.ByteBuf delimiter)
maxFrameLength
- 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 notdelimiter
- the delimiterpublic DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, boolean failFast, io.netty.buffer.ByteBuf delimiter)
maxFrameLength
- 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 notfailFast
- 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.delimiter
- the delimiterpublic DelimiterBasedFrameDecoder(int maxFrameLength, io.netty.buffer.ByteBuf... delimiters)
maxFrameLength
- the maximum length of the decoded frame.
A TooLongFrameException
is thrown if
the length of the frame exceeds this value.delimiters
- the delimiterspublic DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, io.netty.buffer.ByteBuf... delimiters)
maxFrameLength
- 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 notdelimiters
- the delimiterspublic DelimiterBasedFrameDecoder(int maxFrameLength, boolean stripDelimiter, boolean failFast, io.netty.buffer.ByteBuf... delimiters)
maxFrameLength
- 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 notfailFast
- 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.delimiters
- the delimitersCopyright © 2008-2012 The Netty Project. All Rights Reserved.