Class TextLineEncoder
- java.lang.Object
-
- org.apache.mina.filter.codec.ProtocolEncoderAdapter
-
- org.apache.mina.filter.codec.textline.TextLineEncoder
-
- All Implemented Interfaces:
ProtocolEncoder
public class TextLineEncoder extends ProtocolEncoderAdapter
AProtocolEncoder
which encodes a string into a text line which ends with the delimiter.- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description TextLineEncoder()
Creates a new instance with the current defaultCharset
andLineDelimiter.UNIX
delimiter.TextLineEncoder(String delimiter)
Creates a new instance with the current defaultCharset
and the specified delimiter.TextLineEncoder(Charset charset)
Creates a new instance with the specified charset andLineDelimiter.UNIX
delimiter.TextLineEncoder(Charset charset, String delimiter)
Creates a new instance with the specified charset and the specified delimiter.TextLineEncoder(Charset charset, LineDelimiter delimiter)
Creates a new instance with the specified charset and the specified delimiter.TextLineEncoder(LineDelimiter delimiter)
Creates a new instance with the current defaultCharset
and the specified delimiter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Dispose the encodervoid
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.-
Methods inherited from class org.apache.mina.filter.codec.ProtocolEncoderAdapter
dispose
-
-
-
-
Constructor Detail
-
TextLineEncoder
public TextLineEncoder()
Creates a new instance with the current defaultCharset
andLineDelimiter.UNIX
delimiter.
-
TextLineEncoder
public TextLineEncoder(String delimiter)
Creates a new instance with the current defaultCharset
and the specified delimiter.- Parameters:
delimiter
- The line delimiter to use
-
TextLineEncoder
public TextLineEncoder(LineDelimiter delimiter)
Creates a new instance with the current defaultCharset
and the specified delimiter.- Parameters:
delimiter
- The line delimiter to use
-
TextLineEncoder
public TextLineEncoder(Charset charset)
Creates a new instance with the specified charset andLineDelimiter.UNIX
delimiter.- Parameters:
charset
- TheCharset
to use
-
TextLineEncoder
public TextLineEncoder(Charset charset, String delimiter)
Creates a new instance with the specified charset and the specified delimiter.- Parameters:
charset
- TheCharset
to usedelimiter
- The line delimiter to use
-
TextLineEncoder
public TextLineEncoder(Charset charset, LineDelimiter delimiter)
Creates a new instance with the specified charset and the specified delimiter.- Parameters:
charset
- TheCharset
to usedelimiter
- The line delimiter to use
-
-
Method Detail
-
getMaxLineLength
public int getMaxLineLength()
- Returns:
- the allowed maximum size of the encoded line.
If the size of the encoded line exceeds this value, the encoder
will throw a
IllegalArgumentException
. The default value isInteger.MAX_VALUE
.
-
setMaxLineLength
public void setMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the encoded line. If the size of the encoded line exceeds this value, the encoder will throw aIllegalArgumentException
. The default value isInteger.MAX_VALUE
.- Parameters:
maxLineLength
- The maximum line length
-
encode
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception
Encodes higher-level message objects into binary or protocol-specific data. MINA invokesProtocolEncoder.encode(IoSession, Object, ProtocolEncoderOutput)
method with message which is popped from the session write queue, and then the encoder implementation puts encoded messages (typicallyIoBuffer
s) intoProtocolEncoderOutput
.- Parameters:
session
- The current Sessionmessage
- the message to encodeout
- TheProtocolEncoderOutput
that will receive the encoded message- Throws:
Exception
- if the message violated protocol specification
-
-