org.apache.mina.filter.codec.textline

Class TextLineEncoder

Implemented Interfaces:
ProtocolEncoder

public class TextLineEncoder
extends ProtocolEncoderAdapter

A ProtocolEncoder which encodes a string into a text line which ends with the delimiter.

Constructor Summary

TextLineEncoder()
TextLineEncoder(Charset charset)
TextLineEncoder(Charset charset, LineDelimiter delimiter)
TextLineEncoder(LineDelimiter delimiter)

Method Summary

void
dispose()
void
encode(IoSession session, Object message, ProtocolEncoderOutput out)
Encodes higher-level message objects into binary or protocol-specific data.
int
getMaxLineLength()
Returns the allowed maximum size of the encoded line.
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 Details

TextLineEncoder

public TextLineEncoder()

TextLineEncoder

public TextLineEncoder(Charset charset)

TextLineEncoder

public TextLineEncoder(Charset charset,
                       LineDelimiter delimiter)

TextLineEncoder

public TextLineEncoder(LineDelimiter delimiter)

Method Details

dispose

public void dispose()
            throws Exception

encode

public void encode(IoSession session,
                   Object message,
                   ProtocolEncoderOutput out)
            throws Exception
Encodes higher-level message objects into binary or protocol-specific data. MINA invokes ProtocolEncoder.encode(IoSession,Object,ProtocolEncoderOutput) method with message which is popped from the session write queue, and then the encoder implementation puts encoded ByteBuffers into ProtocolEncoderOutput.
Specified by:
encode in interface ProtocolEncoder

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 is Integer.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 a IllegalArgumentException. The default value is Integer.MAX_VALUE.