public class PrefixedStringCodecFactory extends Object implements ProtocolCodecFactory
ProtocolCodecFactory that performs encoding and decoding
of a Java String object using a fixed-length length prefix.| Constructor and Description |
|---|
PrefixedStringCodecFactory()
Creates a new PrefixedStringCodecFactory instance
|
PrefixedStringCodecFactory(Charset charset)
Creates a new PrefixedStringCodecFactory instance
|
| Modifier and Type | Method and Description |
|---|---|
ProtocolDecoder |
getDecoder(IoSession session)
Returns a new (or reusable) instance of
ProtocolDecoder which
decodes binary or protocol-specific data into message objects. |
int |
getDecoderMaxDataLength() |
int |
getDecoderPrefixLength()
Gets the length of the length prefix (1, 2, or 4) used by the decoder
|
ProtocolEncoder |
getEncoder(IoSession session)
Returns a new (or reusable) instance of
ProtocolEncoder which
encodes message objects into binary or protocol-specific data. |
int |
getEncoderMaxDataLength()
Returns the allowed maximum size of an encoded string.
|
int |
getEncoderPrefixLength()
Gets the length of the length prefix (1, 2, or 4) used by the encoder
|
void |
setDecoderMaxDataLength(int maxDataLength)
Sets the maximum allowed value specified as data length in the decoded data
Useful for preventing an OutOfMemory attack by the peer.
|
void |
setDecoderPrefixLength(int prefixLength)
Sets the length of the prefix used by the decoder
|
void |
setEncoderMaxDataLength(int maxDataLength)
Sets the allowed maximum size of an encoded String.
|
void |
setEncoderPrefixLength(int prefixLength)
Sets the length of the prefix used by the encoder
|
public PrefixedStringCodecFactory(Charset charset)
charset - The Charset to use for encoding or decodingpublic PrefixedStringCodecFactory()
public int getEncoderMaxDataLength()
IllegalArgumentException.
The default value is PrefixedStringEncoder.DEFAULT_MAX_DATA_LENGTH.
This method does the same job as PrefixedStringEncoder.setMaxDataLength(int).
public void setEncoderMaxDataLength(int maxDataLength)
IllegalArgumentException.
The default value is PrefixedStringEncoder.DEFAULT_MAX_DATA_LENGTH.
This method does the same job as PrefixedStringEncoder.getMaxDataLength().
maxDataLength - allowed maximum size of an encoded String.public int getDecoderMaxDataLength()
This method does the same job as PrefixedStringEncoder.setMaxDataLength(int).
setDecoderMaxDataLength(int)public void setDecoderMaxDataLength(int maxDataLength)
Useful for preventing an OutOfMemory attack by the peer.
The decoder will throw a BufferDataException when data length
specified in the incoming data is greater than maxDataLength
The default value is PrefixedStringDecoder.DEFAULT_MAX_DATA_LENGTH.
This method does the same job as PrefixedStringDecoder.setMaxDataLength(int).
maxDataLength - maximum allowed value specified as data length in the incoming datapublic void setDecoderPrefixLength(int prefixLength)
prefixLength - the length of the length prefix (1, 2, or 4)public int getDecoderPrefixLength()
public void setEncoderPrefixLength(int prefixLength)
prefixLength - the length of the length prefix (1, 2, or 4)public int getEncoderPrefixLength()
public ProtocolEncoder getEncoder(IoSession session) throws Exception
ProtocolEncoder which
encodes message objects into binary or protocol-specific data.getEncoder in interface ProtocolCodecFactorysession - The current sessionException - If an error occurred while retrieving the encoderpublic ProtocolDecoder getDecoder(IoSession session) throws Exception
ProtocolDecoder which
decodes binary or protocol-specific data into message objects.getDecoder in interface ProtocolCodecFactorysession - The current sessionException - If an error occurred while retrieving the decoderCopyright © 2004–2024 Apache MINA Project. All rights reserved.