Class IoBufferDecoder
java.lang.Object
org.apache.mina.proxy.utils.IoBufferDecoder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThe class holding the decoding context. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIoBufferDecoder(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
Modifier and TypeMethodDescriptiondecodeFully(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.
-
Field Details
-
ctx
The decoding context.
-
-
Constructor Details
-
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 Details
-
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
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
-