public class TextLineDecoder extends Object implements ProtocolDecoder<ByteBuffer,String,TextLineDecoder.Context>
ProtocolDecoder
which decodes a text line into a string.Modifier and Type | Class and Description |
---|---|
class |
TextLineDecoder.Context
A Context used during the decoding of a lin.
|
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 |
---|---|
TextLineDecoder.Context |
createDecoderState()
Create a new session context for this decoder
|
String |
decode(ByteBuffer in,
TextLineDecoder.Context ctx)
Decode binary or protocol-specific content of type
INPUT into higher-level protocol message objects,
of type OUTPUT |
void |
finishDecode(TextLineDecoder.Context ctx)
Finish decoding, for example if the decoder accumulated some unused input, it should discard it, or throw an
Exception
|
int |
getBufferLength()
Returns the allowed buffer size used to store the decoded line in the Context instance.
|
int |
getMaxLineLength()
Returns the allowed maximum size of the line to be decoded.
|
void |
setBufferLength(int bufferLength)
Sets the default buffer size.
|
void |
setMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the line to be decoded.
|
public TextLineDecoder()
Charset
and LineDelimiter.AUTO
delimiter.public TextLineDecoder(String delimiter)
Charset
and the specified delimiter.public TextLineDecoder(LineDelimiter delimiter)
Charset
and the specified delimiter.public TextLineDecoder(Charset charset)
LineDelimiter.AUTO
delimiter.public TextLineDecoder(Charset charset, String delimiter)
public TextLineDecoder(Charset charset, LineDelimiter delimiter)
public int getMaxLineLength()
BufferDataException
. The default value is 1024 (1KB).public void setMaxLineLength(int maxLineLength)
BufferDataException
. The default value is 1024 (1KB).public void setBufferLength(int bufferLength)
bufferLength
- The default bufer sizepublic int getBufferLength()
public TextLineDecoder.Context createDecoderState()
ProtocolDecoder
createDecoderState
in interface ProtocolDecoder<ByteBuffer,String,TextLineDecoder.Context>
public String decode(ByteBuffer in, TextLineDecoder.Context ctx)
INPUT
into higher-level protocol message objects,
of type OUTPUTdecode
in interface ProtocolDecoder<ByteBuffer,String,TextLineDecoder.Context>
in
- the received message to decodectx
- the decoding context (will be stored in the session for the next decode call)null
if nothing was decodedpublic void finishDecode(TextLineDecoder.Context ctx)
finishDecode
in interface ProtocolDecoder<ByteBuffer,String,TextLineDecoder.Context>
Copyright © 2009–2013 Apache MINA Project. All rights reserved.