public class TextLineDecoder extends Object implements ProtocolDecoder
ProtocolDecoder which decodes a text line into a string.| Constructor and Description |
|---|
TextLineDecoder()
Creates a new instance with the current default
Charset
and LineDelimiter.AUTO delimiter. |
TextLineDecoder(Charset charset)
Creates a new instance with the spcified
charset
and LineDelimiter.AUTO delimiter. |
TextLineDecoder(Charset charset,
LineDelimiter delimiter)
Creates a new instance with the specified
charset
and the specified delimiter. |
TextLineDecoder(Charset charset,
String delimiter)
Creates a new instance with the spcified
charset
and the specified delimiter. |
TextLineDecoder(LineDelimiter delimiter)
Creates a new instance with the current default
Charset
and the specified delimiter. |
TextLineDecoder(String delimiter)
Creates a new instance with the current default
Charset
and the specified delimiter. |
| Modifier and Type | Method and Description |
|---|---|
void |
decode(IoSession session,
IoBuffer in,
ProtocolDecoderOutput out)
Decodes binary or protocol-specific content into higher-level message objects.
|
void |
dispose(IoSession session)
Releases all resources related with this decoder.
|
void |
finishDecode(IoSession session,
ProtocolDecoderOutput out)
Invoked when the specified
session is closed. |
int |
getBufferLength() |
int |
getMaxLineLength() |
void |
setBufferLength(int bufferLength)
Sets the default buffer size.
|
void |
setMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the line to be decoded.
|
protected void |
writeText(IoSession session,
String text,
ProtocolDecoderOutput out)
By default, this method propagates the decoded line of text to
ProtocolDecoderOutput#write(Object). |
public TextLineDecoder()
Charset
and LineDelimiter.AUTO delimiter.public TextLineDecoder(String delimiter)
Charset
and the specified delimiter.delimiter - The line delimiter to usepublic TextLineDecoder(LineDelimiter delimiter)
Charset
and the specified delimiter.delimiter - The line delimiter to usepublic TextLineDecoder(Charset charset)
charset
and LineDelimiter.AUTO delimiter.charset - The Charset to usepublic TextLineDecoder(Charset charset, String delimiter)
charset
and the specified delimiter.charset - The Charset to usedelimiter - The line delimiter to usepublic TextLineDecoder(Charset charset, LineDelimiter delimiter)
charset
and the specified delimiter.charset - The Charset to usedelimiter - The line delimiter to usepublic int getMaxLineLength()
BufferDataException. The default
value is 1024 (1KB).public void setMaxLineLength(int maxLineLength)
BufferDataException. The default
value is 1024 (1KB).maxLineLength - The maximum line lengthpublic void setBufferLength(int bufferLength)
bufferLength - The default bufer sizepublic int getBufferLength()
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception
ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method with read data, and then the decoder implementation puts decoded
messages into ProtocolDecoderOutput.decode in interface ProtocolDecodersession - The current Sessionin - the buffer to decodeout - The ProtocolDecoderOutput that will receive the decoded messageException - if the read data violated protocol specificationpublic void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception
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 that ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput)
method didn't process completely.finishDecode in interface ProtocolDecodersession - The current Sessionout - The ProtocolDecoderOutput that contains the decoded messageException - if the read data violated protocol specificationpublic void dispose(IoSession session) throws Exception
dispose in interface ProtocolDecodersession - The current SessionException - if failed to dispose all resourcesprotected void writeText(IoSession session, String text, ProtocolDecoderOutput out)
ProtocolDecoderOutput#write(Object). You may override this method to modify
the default behavior.session - the IoSession the received data.text - the decoded textout - the upstream ProtocolDecoderOutput.Copyright © 2004–2024 Apache MINA Project. All rights reserved.