public class TextLineEncoder extends ProtocolEncoderAdapter
ProtocolEncoder
which encodes a string into a text line
which ends with the delimiter.Constructor and Description |
---|
TextLineEncoder()
Creates a new instance with the current default
Charset
and LineDelimiter.UNIX delimiter. |
TextLineEncoder(Charset charset)
Creates a new instance with the specified charset
and
LineDelimiter.UNIX delimiter. |
TextLineEncoder(Charset charset,
LineDelimiter delimiter)
Creates a new instance with the specified charset
and the specified delimiter.
|
TextLineEncoder(Charset charset,
String delimiter)
Creates a new instance with the specified charset
and the specified delimiter.
|
TextLineEncoder(LineDelimiter delimiter)
Creates a new instance with the current default
Charset
and the specified delimiter. |
TextLineEncoder(String delimiter)
Creates a new instance with the current default
Charset
and the specified delimiter. |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Dispose the encoder
|
void |
encode(IoSession session,
Object message,
ProtocolEncoderOutput out)
Encodes higher-level message objects into binary or protocol-specific data.
|
int |
getMaxLineLength() |
void |
setMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the encoded line.
|
dispose
public TextLineEncoder()
Charset
and LineDelimiter.UNIX
delimiter.public TextLineEncoder(String delimiter)
Charset
and the specified delimiter.delimiter
- The line delimiter to usepublic TextLineEncoder(LineDelimiter delimiter)
Charset
and the specified delimiter.delimiter
- The line delimiter to usepublic TextLineEncoder(Charset charset)
LineDelimiter.UNIX
delimiter.charset
- The Charset
to usepublic TextLineEncoder(Charset charset, String delimiter)
charset
- The Charset
to usedelimiter
- The line delimiter to usepublic TextLineEncoder(Charset charset, LineDelimiter delimiter)
charset
- The Charset
to usedelimiter
- The line delimiter to usepublic int getMaxLineLength()
IllegalArgumentException
. The default value
is Integer.MAX_VALUE
.public void setMaxLineLength(int maxLineLength)
IllegalArgumentException
. The default value
is Integer.MAX_VALUE
.maxLineLength
- The maximum line lengthpublic void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception
ProtocolEncoder.encode(IoSession, Object, ProtocolEncoderOutput)
method with message which is popped from the session write queue, and then
the encoder implementation puts encoded messages (typically IoBuffer
s)
into ProtocolEncoderOutput
.session
- The current Sessionmessage
- the message to encodeout
- The ProtocolEncoderOutput
that will receive the encoded messageException
- if the message violated protocol specificationCopyright © 2004–2022 Apache MINA Project. All rights reserved.