Class TextLineDecoder
java.lang.Object
org.apache.mina.filter.codec.textline.TextLineDecoder
- All Implemented Interfaces:
ProtocolDecoder
A
ProtocolDecoder which decodes a text line into a string.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with the current defaultCharsetandLineDelimiter.AUTOdelimiter.TextLineDecoder(Charset charset) Creates a new instance with the spcified charset andLineDelimiter.AUTOdelimiter.TextLineDecoder(Charset charset, LineDelimiter delimiter) Creates a new instance with the specified charset and the specified delimiter. -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) Decodes binary or protocol-specific content into higher-level message objects.voidReleases all resources related with this decoder.voidfinishDecode(IoSession session, ProtocolDecoderOutput out) Invoked when the specified session is closed.intReturns the allowed maximum size of the line to be decoded.voidsetMaxLineLength(int maxLineLength) Sets the allowed maximum size of the line to be decoded.
-
Constructor Details
-
TextLineDecoder
public TextLineDecoder()Creates a new instance with the current defaultCharsetandLineDelimiter.AUTOdelimiter. -
TextLineDecoder
Creates a new instance with the spcified charset andLineDelimiter.AUTOdelimiter. -
TextLineDecoder
Creates a new instance with the specified charset and the specified delimiter.
-
-
Method Details
-
getMaxLineLength
public int getMaxLineLength()Returns the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this value, the decoder will throw aBufferDataException. The default value is 1024 (1KB). -
setMaxLineLength
public void setMaxLineLength(int maxLineLength) Sets the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this value, the decoder will throw aBufferDataException. The default value is 1024 (1KB). -
decode
Description copied from interface:ProtocolDecoderDecodes binary or protocol-specific content into higher-level message objects. MINA invokesProtocolDecoder.decode(IoSession, ByteBuffer, ProtocolDecoderOutput)method with read data, and then the decoder implementation puts decoded messages intoProtocolDecoderOutput.- Specified by:
decodein interfaceProtocolDecoder- Throws:
Exception- if the read data violated protocol specification
-
finishDecode
Description copied from interface:ProtocolDecoderInvoked when the specified session is closed. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response without content-length header. Implement this method to process the remaining data thatProtocolDecoder.decode(IoSession, ByteBuffer, ProtocolDecoderOutput)method didn't process completely.- Specified by:
finishDecodein interfaceProtocolDecoder- Throws:
Exception- if the read data violated protocol specification
-
dispose
Description copied from interface:ProtocolDecoderReleases all resources related with this decoder.- Specified by:
disposein interfaceProtocolDecoder- Throws:
Exception- if failed to dispose all resources
-