|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.filter.codec.ProtocolDecoderAdapter
org.apache.mina.filter.codec.CumulativeProtocolDecoder
org.apache.mina.filter.codec.prefixedstring.PrefixedStringDecoder
public class PrefixedStringDecoder
A ProtocolDecoder which decodes a String using a fixed-length length prefix.
| Field Summary | |
|---|---|
static int |
DEFAULT_MAX_DATA_LENGTH
|
static int |
DEFAULT_PREFIX_LENGTH
|
| Constructor Summary | |
|---|---|
PrefixedStringDecoder(Charset charset)
|
|
PrefixedStringDecoder(Charset charset,
int prefixLength)
|
|
PrefixedStringDecoder(Charset charset,
int prefixLength,
int maxDataLength)
|
|
| Method Summary | |
|---|---|
protected boolean |
doDecode(IoSession session,
IoBuffer in,
ProtocolDecoderOutput out)
Implement this method to consume the specified cumulative buffer and decode its content into message(s). |
int |
getMaxDataLength()
Gets the maximum number of bytes allowed for a single String |
int |
getPrefixLength()
Gets the length of the length prefix (1, 2, or 4) |
void |
setMaxDataLength(int maxDataLength)
Sets the maximum allowed value specified as data length in the incoming data Useful for preventing an OutOfMemory attack by the peer. |
void |
setPrefixLength(int prefixLength)
Sets the number of bytes used by the length prefix |
| Methods inherited from class org.apache.mina.filter.codec.CumulativeProtocolDecoder |
|---|
decode, dispose |
| Methods inherited from class org.apache.mina.filter.codec.ProtocolDecoderAdapter |
|---|
finishDecode |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_PREFIX_LENGTH
public static final int DEFAULT_MAX_DATA_LENGTH
| Constructor Detail |
|---|
public PrefixedStringDecoder(Charset charset,
int prefixLength,
int maxDataLength)
charset - the charset to use for encodingprefixLength - the length of the prefixmaxDataLength - maximum number of bytes allowed for a single String
public PrefixedStringDecoder(Charset charset,
int prefixLength)
public PrefixedStringDecoder(Charset charset)
| Method Detail |
|---|
public void setPrefixLength(int prefixLength)
prefixLength - the length of the length prefix (1, 2, or 4)public int getPrefixLength()
public void setMaxDataLength(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 DEFAULT_MAX_DATA_LENGTH.
maxDataLength - maximum allowed value specified as data length in the incoming datapublic int getMaxDataLength()
protected boolean doDecode(IoSession session,
IoBuffer in,
ProtocolDecoderOutput out)
throws Exception
CumulativeProtocolDecoder
doDecode in class CumulativeProtocolDecoderin - the cumulative buffer
Exception - if cannot decode in.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||