public class LineReader
extends java.lang.Object
ByteBuffers that contain strings terminated with
a new line. This reader supports non-blocking incremental reads split across random places in the line.
This is not thread-safe and must only be called from a ChannelHandler.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY |
| Constructor and Description |
|---|
LineReader() |
LineReader(int maxLineLength,
java.nio.charset.Charset encoding) |
| Modifier and Type | Method and Description |
|---|---|
void |
decode(io.netty.buffer.ByteBuf in,
java.util.List<java.lang.Object> out,
io.netty.buffer.ByteBufAllocator allocator)
Reads the
in buffer as much as it can and adds all the read lines into the out list. |
void |
decodeLast(io.netty.buffer.ByteBuf in,
java.util.List<java.lang.Object> out,
io.netty.buffer.ByteBufAllocator allocator)
Same as
decode(ByteBuf, List, ByteBufAllocator) but it also produces the left-over buffer, even in
absence of a line termination. |
void |
dispose()
Disposes any half-read data buffers.
|
static boolean |
isLineDelimiter(char c) |
public static final int DEFAULT_INITIAL_CAPACITY
public LineReader()
public LineReader(int maxLineLength,
java.nio.charset.Charset encoding)
public void decode(io.netty.buffer.ByteBuf in,
java.util.List<java.lang.Object> out,
io.netty.buffer.ByteBufAllocator allocator)
in buffer as much as it can and adds all the read lines into the out list. If there is any outstanding data that is not read, it is stored into a temporary buffer and the next decode will prepend this data to the newly read data.
dispose() must be called when the associated ChannelHandler is removed from the pipeline.
in - Buffer to decode.out - List to add the read lines to.allocator - Allocator to allocate new buffers, if required.public void decodeLast(io.netty.buffer.ByteBuf in,
java.util.List<java.lang.Object> out,
io.netty.buffer.ByteBufAllocator allocator)
decode(ByteBuf, List, ByteBufAllocator) but it also produces the left-over buffer, even in
absence of a line termination.
dispose() must be called when the associated ChannelHandler is removed from the pipeline.in - Buffer to decode.out - List to add the read lines to.allocator - Allocator to allocate new buffers, if required.public void dispose()
public static boolean isLineDelimiter(char c)