|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.comm.codec.Decoder<ByteBuffer,ByteBuffer>
com.kuka.comm.codec.bytebuffer.TokenDecoder
public final class TokenDecoder
A TokenDecoder tries to find a specified token in a byte buffer.
By default the token will be consumed when found, i.e. the byte buffer passed to a concatenated decoder does not
include the token (see setTokenIncluded(boolean)). If the token is not consumed the byte buffer will start
at the first byte of the token.
| Constructor Summary | |
|---|---|
TokenDecoder(byte[] token)
Creates a decoder that will seek to the first occurrence of the given byte subsequence (token). |
|
TokenDecoder(String token)
Creates a decoder that will seek to the first occurrence of the given byte subsequence (token). |
|
TokenDecoder(String token,
Charset charset)
Creates a decoder that will seek to the first occurrence of the given byte subsequence (token). |
|
| Method Summary | |
|---|---|
protected ByteBuffer |
decodeImpl(ByteBuffer in)
Realization of the decoding method to be implemented in subclasses. |
boolean |
isTokenIncluded()
Returns true if the token is included in the resulting byte buffer. |
TokenDecoder |
setTokenIncluded(boolean consume)
If set to true the token is included in the resulting byte buffer. |
| Methods inherited from class com.kuka.comm.codec.Decoder |
|---|
concat, decode |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TokenDecoder(String token)
Charset.defaultCharset(). By default the
token will be consumed when found (see setTokenIncluded(boolean)).
token - the subsequence to be searched for
public TokenDecoder(String token,
Charset charset)
setTokenIncluded(boolean)).
token - the subsequence to be searched forcharset - the charset of the stringpublic TokenDecoder(byte[] token)
setTokenIncluded(boolean)).
token - the token to decode| Method Detail |
|---|
public boolean isTokenIncluded()
true if the token is included in the resulting byte buffer.
true if the token is included in the resulting byte buffer.setTokenIncluded(boolean)public TokenDecoder setTokenIncluded(boolean consume)
true the token is included in the resulting byte buffer.
consume - if the token should be included in the resulting byte buffer
isTokenIncluded()
protected ByteBuffer decodeImpl(ByteBuffer in)
throws DecoderException
DecoderDecoder.decode(Object) method.
Return null to indicate that the decoder could not finish its job (e.g. because the input was
incomplete). The decoding will be cancelled, i.e. concatenated decoders coming after this decoder will not be
called, and the decoding process will restart, when more data is available. Throw an exception to indicate that
an error occurred during decoding. The data read so far will be discarded.
decodeImpl in class Decoder<ByteBuffer,ByteBuffer>in - the input for this decoder, usually the message to be decoded
null if the input was incomplete
DecoderException - if an error occurred during decoding
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||