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() |
PrefixedStringCodecFactory(Charset charset) |
| 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()
Returns the allowed maximum size of a decoded string.
|
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
|
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)
public 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
ProtocolCodecFactoryProtocolEncoder which
encodes message objects into binary or protocol-specific data.getEncoder in interface ProtocolCodecFactoryExceptionpublic ProtocolDecoder getDecoder(IoSession session) throws Exception
ProtocolCodecFactoryProtocolDecoder which
decodes binary or protocol-specific data into message objects.getDecoder in interface ProtocolCodecFactoryException