org.apache.mina.codec.delimited

## Class SizePrefixedEncoder<IN>

- java.lang.Object
- - org.apache.mina.codec.delimited.SizePrefixedEncoder<IN>

All Implemented Interfaces:
  ProtocolEncoder<IN,ByteBuffer,Void>, StatelessProtocolEncoder<IN,ByteBuffer>

Direct Known Subclasses:
  ProtobufEncoder, ThriftEncoder

    public class SizePrefixedEncoder<IN>
    extends Object
    implements StatelessProtocolEncoder<IN,ByteBuffer>

Author:
  Apache MINA Project

### Constructor Summary

Constructors
Constructor and Description
`SizePrefixedEncoder(ByteBufferEncoder<Integer> sizeEncoder, ByteBufferEncoder<IN> payloadEncoder)`

### Method Summary

Methods
`Void` `createEncoderState()` Create a new session context for this decoder
`ByteBuffer` `encode(IN message, Void context)` Encodes higher-level message objects of type `INPUT` into binary or protocol-specific data of type `OUTPUT`.

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

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

### Constructor Detail

#### SizePrefixedEncoder

    public SizePrefixedEncoder(ByteBufferEncoder<Integer> sizeEncoder,
                       ByteBufferEncoder<IN> payloadEncoder)

### Method Detail

#### createEncoderState

    public Void createEncoderState()

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

Specified by:
  `createEncoderState` in interface `ProtocolEncoder<IN,ByteBuffer,Void>`
Returns:
  the newly created context

#### encode

    public ByteBuffer encode(IN message,
                    Void context)

Description copied from interface: `ProtocolEncoder`
Encodes higher-level message objects of type `INPUT` into binary or protocol-specific data of type `OUTPUT`.

Specified by:
  `encode` in interface `ProtocolEncoder<IN,ByteBuffer,Void>`
Parameters:
  `message` - the message to encode
  `context` - the encoding context (will be stored in the session for the next decode call)