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
AProtocolEncoderwhich 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 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Dispose the encodervoidencode(IoSession session, Object message, ProtocolEncoderOutput out)Encodes higher-level message objects into binary or protocol-specific data.intgetMaxLineLength()voidsetMaxLineLength(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 defaultCharsetandLineDelimiter.UNIXdelimiter.
-
TextLineEncoder
public TextLineEncoder(String delimiter)
Creates a new instance with the current defaultCharsetand the specifieddelimiter.- Parameters:
delimiter- The line delimiter to use
-
TextLineEncoder
public TextLineEncoder(LineDelimiter delimiter)
Creates a new instance with the current defaultCharsetand the specifieddelimiter.- Parameters:
delimiter- The line delimiter to use
-
TextLineEncoder
public TextLineEncoder(Charset charset)
Creates a new instance with the specifiedcharsetandLineDelimiter.UNIXdelimiter.- Parameters:
charset- TheCharsetto use
-
TextLineEncoder
public TextLineEncoder(Charset charset, String delimiter)
Creates a new instance with the specifiedcharsetand the specifieddelimiter.- Parameters:
charset- TheCharsetto usedelimiter- The line delimiter to use
-
TextLineEncoder
public TextLineEncoder(Charset charset, LineDelimiter delimiter)
Creates a new instance with the specifiedcharsetand the specifieddelimiter.- Parameters:
charset- TheCharsetto 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 (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
-
-