org.apache.mina.codec.delimited

## Class SizePrefixedDecoder<OUT>

- java.lang.Object
- - org.apache.mina.codec.delimited.SizePrefixedDecoder<OUT>

All Implemented Interfaces:
  ProtocolDecoder<IoBuffer,OUT,SizePrefixedDecoder.MutableInt>

Direct Known Subclasses:
  ProtobufDecoder, ProtobufDynamicDecoder, ThriftDecoder, ThriftDynamicDecoder

    public class SizePrefixedDecoder<OUT>
    extends Object
    implements ProtocolDecoder<IoBuffer,OUT,SizePrefixedDecoder.MutableInt>

Author:
  Apache MINA Project

### Nested Class Summary

Nested Classes
`protected static class` `SizePrefixedDecoder.MutableInt` A mutable `Integer` wrapper.

### Constructor Summary

Constructors
Constructor and Description
`SizePrefixedDecoder(IoBufferDecoder<Integer> sizeDecoder, IoBufferDecoder<OUT> payloadDecoder)`

### Method Summary

Methods
`SizePrefixedDecoder.MutableInt` `createDecoderState()` Create a new session context for this decoder
`OUT` `decode(IoBuffer input, SizePrefixedDecoder.MutableInt nextBlockSize)` Decode binary or protocol-specific content of type `INPUT` into higher-level protocol message objects, of type OUTPUT
`void` `finishDecode(SizePrefixedDecoder.MutableInt context)` Finish decoding, for example if the decoder accumulated some unused input, it should discard it, or throw an Exception

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

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

### Constructor Detail

#### SizePrefixedDecoder

    public SizePrefixedDecoder(IoBufferDecoder<Integer> sizeDecoder,
                       IoBufferDecoder<OUT> payloadDecoder)

### Method Detail

#### createDecoderState

    public SizePrefixedDecoder.MutableInt createDecoderState()

Description copied from interface: `ProtocolDecoder`
Create a new session context for this decoder

Specified by:
  `createDecoderState` in interface `ProtocolDecoder<IoBuffer,OUT,SizePrefixedDecoder.MutableInt>`
Returns:
  the newly created context

#### decode

    public OUT decode(IoBuffer input,
             SizePrefixedDecoder.MutableInt nextBlockSize)

Description copied from interface: `ProtocolDecoder`
Decode binary or protocol-specific content of type `INPUT` into higher-level protocol message objects, of type OUTPUT

Specified by:
  `decode` in interface `ProtocolDecoder<IoBuffer,OUT,SizePrefixedDecoder.MutableInt>`
Parameters:
  `input` - the received message to decode
  `nextBlockSize` - 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 void finishDecode(SizePrefixedDecoder.MutableInt context)

Description copied from interface: `ProtocolDecoder`
Finish decoding, for example if the decoder accumulated some unused input, it should discard it, or throw an Exception

Specified by:
  `finishDecode` in interface `ProtocolDecoder<IoBuffer,OUT,SizePrefixedDecoder.MutableInt>`