Package org.apache.mina.proxy.utils
Class IoBufferDecoder
- java.lang.Object
-
- org.apache.mina.proxy.utils.IoBufferDecoder
-
public class IoBufferDecoder extends Object
IoBufferDecoder.java - Handles anIoBuffer
decoder which supports two methods : - dynamic delimiter decoding - fixed length content reading- Since:
- MINA 2.0.0-M3
- Author:
- Apache MINA Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
IoBufferDecoder.DecodingContext
The class holding the decoding context.
-
Constructor Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Constructor Detail
-
IoBufferDecoder
public IoBufferDecoder(byte[] delimiter)
Creates a new instance that uses specified delimiter byte array as a message delimiter.- Parameters:
delimiter
- an array of characters which delimits messages
-
IoBufferDecoder
public IoBufferDecoder(int contentLength)
Creates a new instance that will read messages of contentLength bytes.- Parameters:
contentLength
- the exact length to read
-
-
Method Detail
-
setContentLength
public void setContentLength(int contentLength, boolean resetMatchCount)
Sets the the length of the content line to be decoded. When set, it overrides the dynamic delimiter setting and content length method will be used for decoding on the next decodeOnce call. The default value is -1.- Parameters:
contentLength
- the content length to matchresetMatchCount
- delimiter matching is reset if true
-
setDelimiter
public void setDelimiter(byte[] delim, boolean resetMatchCount)
Dynamically sets a new delimiter. Next timedecodeFully(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 : DelimiterLineDelimiter.AUTO
is not allowed.- Parameters:
delim
- the new delimiter as a byte arrayresetMatchCount
- delimiter matching is reset if true
-
decodeFully
public IoBuffer decodeFully(IoBuffer in)
Will return null unless it has enough data to decode. IfcontentLength
is set then it tries to retrievecontentLength
bytes from the buffer otherwise it will scan the buffer to find the datadelimiter
and return all the data and the trailing delimiter.- Parameters:
in
- the data to decode- Returns:
- The decoded buffer
-
-