Class TextLineCodecFactory
- java.lang.Object
-
- org.apache.mina.filter.codec.textline.TextLineCodecFactory
-
- All Implemented Interfaces:
ProtocolCodecFactory
public class TextLineCodecFactory extends Object implements ProtocolCodecFactory
AProtocolCodecFactory
that performs encoding and decoding between a text line data and a Java string object. This codec is useful especially when you work with a text-based protocols such as SMTP and IMAP.- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description TextLineCodecFactory()
Creates a new instance with the current defaultCharset
.TextLineCodecFactory(Charset charset)
Creates a new instance with the specifiedCharset
.TextLineCodecFactory(Charset charset, String encodingDelimiter, String decodingDelimiter)
Creates a new instance of TextLineCodecFactory.TextLineCodecFactory(Charset charset, LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter)
Creates a new instance of TextLineCodecFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtocolDecoder
getDecoder(IoSession session)
Returns a new (or reusable) instance ofProtocolDecoder
which decodes binary or protocol-specific data into message objects.int
getDecoderMaxLineLength()
ProtocolEncoder
getEncoder(IoSession session)
Returns a new (or reusable) instance ofProtocolEncoder
which encodes message objects into binary or protocol-specific data.int
getEncoderMaxLineLength()
void
setDecoderMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the line to be decoded.void
setEncoderMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the encoded line.
-
-
-
Constructor Detail
-
TextLineCodecFactory
public TextLineCodecFactory()
Creates a new instance with the current defaultCharset
.
-
TextLineCodecFactory
public TextLineCodecFactory(Charset charset)
Creates a new instance with the specifiedCharset
. The encoder uses a UNIXLineDelimiter
and the decoder uses the AUTOLineDelimiter
.- Parameters:
charset
- The charset to use in the encoding and decoding
-
TextLineCodecFactory
public TextLineCodecFactory(Charset charset, String encodingDelimiter, String decodingDelimiter)
Creates a new instance of TextLineCodecFactory. This constructor provides more flexibility for the developer.- Parameters:
charset
- The charset to use in the encoding and decodingencodingDelimiter
- The line delimeter for the encoderdecodingDelimiter
- The line delimeter for the decoder
-
TextLineCodecFactory
public TextLineCodecFactory(Charset charset, LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter)
Creates a new instance of TextLineCodecFactory. This constructor provides more flexibility for the developer.- Parameters:
charset
- The charset to use in the encoding and decodingencodingDelimiter
- The line delimeter for the encoderdecodingDelimiter
- The line delimeter for the decoder
-
-
Method Detail
-
getEncoder
public ProtocolEncoder getEncoder(IoSession session)
Returns a new (or reusable) instance ofProtocolEncoder
which encodes message objects into binary or protocol-specific data.- Specified by:
getEncoder
in interfaceProtocolCodecFactory
- Parameters:
session
- The current session- Returns:
- The encoder instance
-
getDecoder
public ProtocolDecoder getDecoder(IoSession session)
Returns a new (or reusable) instance ofProtocolDecoder
which decodes binary or protocol-specific data into message objects.- Specified by:
getDecoder
in interfaceProtocolCodecFactory
- Parameters:
session
- The current session- Returns:
- The decoder instance
-
getEncoderMaxLineLength
public int getEncoderMaxLineLength()
- 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
.This method does the same job with
TextLineEncoder.getMaxLineLength()
.
-
setEncoderMaxLineLength
public void setEncoderMaxLineLength(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
.This method does the same job with
TextLineEncoder.setMaxLineLength(int)
.- Parameters:
maxLineLength
- The maximum encoded line length
-
getDecoderMaxLineLength
public int getDecoderMaxLineLength()
- Returns:
- the allowed maximum size of the line to be decoded.
If the size of the line to be decoded exceeds this value, the
decoder will throw a
BufferDataException
. The default value is 1024 (1KB).This method does the same job with
TextLineDecoder.getMaxLineLength()
.
-
setDecoderMaxLineLength
public void setDecoderMaxLineLength(int maxLineLength)
Sets the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this value, the decoder will throw aBufferDataException
. The default value is 1024 (1KB).This method does the same job with
TextLineDecoder.setMaxLineLength(int)
.- Parameters:
maxLineLength
- the maximum decoded line length
-
-