public class IoBufferDecoder
extends java.lang.Object
IoBuffer
decoder which supports
two methods :
- dynamic delimiter decoding
- fixed length content reading限定符和类型 | 类和说明 |
---|---|
class |
IoBufferDecoder.DecodingContext
The class holding the decoding context.
|
构造器和说明 |
---|
IoBufferDecoder(byte[] delimiter)
Creates a new instance that uses specified delimiter byte array as a
message delimiter.
|
IoBufferDecoder(int contentLength)
Creates a new instance that will read messages of contentLength bytes.
|
限定符和类型 | 方法和说明 |
---|---|
IoBuffer |
decodeFully(IoBuffer in)
Will return null unless it has enough data to decode.
|
void |
setContentLength(int contentLength,
boolean resetMatchCount)
Sets the the length of the content line to be decoded.
|
void |
setDelimiter(byte[] delim,
boolean resetMatchCount)
Dynamically sets a new delimiter.
|
public IoBufferDecoder(byte[] delimiter)
delimiter
- an array of characters which delimits messagespublic IoBufferDecoder(int contentLength)
contentLength
- the exact length to readpublic void setContentLength(int contentLength, boolean resetMatchCount)
contentLength
- the content length to matchresetMatchCount
- delimiter matching is reset if truepublic void setDelimiter(byte[] delim, boolean resetMatchCount)
decodeFully(IoBuffer)
will be called it will use the new
delimiter. Delimiter matching is reset only if resetMatchCount is true but
decoding will continue from current position.
NB : Delimiter LineDelimiter.AUTO
is not allowed.delim
- the new delimiter as a byte arrayresetMatchCount
- delimiter matching is reset if truepublic IoBuffer decodeFully(IoBuffer in)
contentLength
is set then it tries to retrieve contentLength
bytes from the buffer
otherwise it will scan the buffer to find the data delimiter
and return
all the data and the trailing delimiter.in
- the data to decode