org.apache.mina.codec.delimited

## Class IoBufferDecoder<INPUT>

- java.lang.Object
- - org.apache.mina.codec.delimited.IoBufferDecoder<INPUT>

Type Parameters:
  `INPUT` - the type of the messages which will be encoded in ByteBuffers and decoded from ByteBuffers.

All Implemented Interfaces:
  ProtocolDecoder<IoBuffer,INPUT,Void>, StatelessProtocolDecoder<IoBuffer,INPUT>

Direct Known Subclasses:
  JavaNativeMessageDecoder, ProtobufDynamicMessageDecoder, ProtobufMessageDecoder, ThriftDynamicMessageDecoder, ThriftMessageDecoder

    public abstract class IoBufferDecoder<INPUT>
    extends Object
    implements StatelessProtocolDecoder<IoBuffer,INPUT>

Abstract class providing both encoding and decoding methods between a given type and ByteBuffers.

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.

Author:
  Apache MINA Project

### Constructor Summary

Constructors
Constructor and Description
`IoBufferDecoder()`

### Method Summary

Methods
`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

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IoBufferDecoder

    public IoBufferDecoder()

### Method Detail

#### createDecoderState

    public final Void createDecoderState()

Being stateless, this method is left empty

Specified by:
  `createDecoderState` in interface `ProtocolDecoder<IoBuffer,INPUT,Void>`
Returns:
  the newly created context
See Also:
  `ProtocolDecoder.createDecoderState()`

#### decode

    public abstract INPUT decode(IoBuffer input)

Decodes a message from a `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.

Parameters:
  `input` - data to be decoded as a TYPE message
Returns:
  the decoded message on success, null otherwise
Throws:
  `ProtocolDecoderException`

#### decode

    public final 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)`

Specified by:
  `decode` in interface `ProtocolDecoder<IoBuffer,INPUT,Void>`
Parameters:
  `input` - the received message to decode
  `context` - the decoding context (will be stored in the session for the next decode call)
Returns:
  the decoded message or `null` if nothing was decoded

#### finishDecode

    public final void finishDecode(Void context)

Being stateless, this method is left empty

Specified by:
  `finishDecode` in interface `ProtocolDecoder<IoBuffer,INPUT,Void>`
See Also:
  `ProtocolDecoder.finishDecode(Object)`