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 anIoBufferdecoder 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 classIoBufferDecoder.DecodingContextThe class holding the decoding context.
-
Constructor Summary
Constructors Constructor Description IoBufferDecoder(byte[] delimiter)Creates a new instance that uses specifieddelimiterbyte array as a message delimiter.IoBufferDecoder(int contentLength)Creates a new instance that will read messages ofcontentLengthbytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IoBufferdecodeFully(IoBuffer in)Will return null unless it has enough data to decode.voidsetContentLength(int contentLength, boolean resetMatchCount)Sets the the length of the content line to be decoded.voidsetDelimiter(byte[] delim, boolean resetMatchCount)Dynamically sets a new delimiter.
-
-
-
Constructor Detail
-
IoBufferDecoder
public IoBufferDecoder(byte[] delimiter)
Creates a new instance that uses specifieddelimiterbyte 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 ofcontentLengthbytes.- 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 ifresetMatchCountis true but decoding will continue from current position. NB : DelimiterLineDelimiter.AUTOis 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. IfcontentLengthis set then it tries to retrievecontentLengthbytes from the buffer otherwise it will scan the buffer to find the datadelimiterand return all the data and the trailing delimiter.- Parameters:
in- the data to decode- Returns:
- The decoded buffer
-
-