INPUT
- the type of the messages which will be encoded in ByteBuffers and
decoded from ByteBuffers.public abstract class IoBufferDecoder<INPUT> extends Object implements StatelessProtocolDecoder<IoBuffer,INPUT>
Transcoder is stateless class providing encoding and decoding facilities. Additionally this abstract requires two methods which allows to determine the size of a given message and to write it directly to a previously allocated ByteBuffer.
Constructor and Description |
---|
IoBufferDecoder() |
Modifier and Type | Method and Description |
---|---|
Void |
createDecoderState()
Being stateless, this method is left empty
|
abstract INPUT |
decode(IoBuffer input)
Decodes a message from a
IoBuffer
When a truncated input is given to this method it may return null. |
INPUT |
decode(IoBuffer input,
Void context)
Decodes a message from a
ByteBuffer
The actual decoding needs to be implemented in the abstract method
IoBufferDecoder#decode(ByteBuffer)
|
void |
finishDecode(Void context)
Being stateless, this method is left empty
|
public final Void createDecoderState()
createDecoderState
in interface ProtocolDecoder<IoBuffer,INPUT,Void>
ProtocolDecoder.createDecoderState()
public abstract INPUT decode(IoBuffer input)
IoBuffer
When a truncated input is given to this method it may return null. Not all decoder will be able to detect this issue and report it that way. Thanks to prefixing of messages, decoder will only receive appropriately sized ByteBuffers.
n.b. The decoders used for the prefixing (i.e. RawInt32
and
VarInt
) have to detect truncated ByteBuffers.
input
- data to be decoded as a TYPE messageProtocolDecoderException
public final INPUT decode(IoBuffer input, Void context)
ByteBuffer
The actual decoding needs to be implemented in the abstract method
IoBufferDecoder#decode(ByteBuffer)
decode
in interface ProtocolDecoder<IoBuffer,INPUT,Void>
input
- the received message to decodecontext
- the decoding context (will be stored in the session for the next decode call)null
if nothing was decodedpublic final void finishDecode(Void context)
finishDecode
in interface ProtocolDecoder<IoBuffer,INPUT,Void>
ProtocolDecoder.finishDecode(Object)
Copyright © 2009–2013 Apache MINA Project. All rights reserved.