Class TextLineEncoder
java.lang.Object
org.apache.mina.filter.codec.ProtocolEncoderAdapter
org.apache.mina.filter.codec.textline.TextLineEncoder
- All Implemented Interfaces:
ProtocolEncoder
A
ProtocolEncoder which encodes a string into a text line
which ends with the delimiter.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Charsetprivate final LineDelimiterprivate static final AttributeKeyprivate int -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with the current defaultCharsetandLineDelimiter.UNIXdelimiter.TextLineEncoder(String delimiter) Creates a new instance with the current defaultCharsetand the specifieddelimiter.TextLineEncoder(Charset charset) Creates a new instance with the specifiedcharsetandLineDelimiter.UNIXdelimiter.TextLineEncoder(Charset charset, String delimiter) Creates a new instance with the specifiedcharsetand the specifieddelimiter.TextLineEncoder(Charset charset, LineDelimiter delimiter) Creates a new instance with the specifiedcharsetand the specifieddelimiter.TextLineEncoder(LineDelimiter delimiter) Creates a new instance with the current defaultCharsetand the specifieddelimiter. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose the encodervoidencode(IoSession session, Object message, ProtocolEncoderOutput out) Encodes higher-level message objects into binary or protocol-specific data.intvoidsetMaxLineLength(int maxLineLength) Sets the allowed maximum size of the encoded line.Methods inherited from class ProtocolEncoderAdapter
dispose
-
Field Details
-
ENCODER
-
charset
-
delimiter
-
maxLineLength
private int maxLineLength
-
-
Constructor Details
-
TextLineEncoder
public TextLineEncoder()Creates a new instance with the current defaultCharsetandLineDelimiter.UNIXdelimiter. -
TextLineEncoder
-
TextLineEncoder
Creates a new instance with the current defaultCharsetand the specifieddelimiter.- Parameters:
delimiter- The line delimiter to use
-
TextLineEncoder
Creates a new instance with the specifiedcharsetandLineDelimiter.UNIXdelimiter.- Parameters:
charset- TheCharsetto use
-
TextLineEncoder
-
TextLineEncoder
Creates a new instance with the specifiedcharsetand the specifieddelimiter.- Parameters:
charset- TheCharsetto usedelimiter- The line delimiter to use
-
-
Method Details
-
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
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 (typicallyIoBuffers) intoProtocolEncoderOutput.- Parameters:
session- The current Sessionmessage- the message to encodeout- TheProtocolEncoderOutputthat will receive the encoded message- Throws:
Exception- if the message violated protocol specification
-
dispose
-