org.apache.mina.codec.delimited.serialization

## Class ThriftMessageEncoder<INPUT extends org.apache.thrift.TBase<?,?>>

- java.lang.Object
- - org.apache.mina.codec.delimited.ByteBufferEncoder<INPUT>
  - - org.apache.mina.codec.delimited.serialization.ThriftMessageEncoder<INPUT>

Type Parameters:
  `INPUT` - the base type for message to encode

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

    public class ThriftMessageEncoder<INPUT extends org.apache.thrift.TBase<?,?>>
    extends ByteBufferEncoder<INPUT>

Encode Thrift message into `ByteBuffer`

Author:
  Apache MINA Project

### Constructor Summary

Constructors
Constructor and Description
`ThriftMessageEncoder()`

### Method Summary

Methods
`int` `getEncodedSize(INPUT message)` Computes the size of the serialized form of a message in bytes.
`static <L extends org.apache.thrift.TBase<?,?>> ThriftMessageEncoder<L>` `newInstance(Class<L> clazz)`
`void` `writeTo(INPUT message, ByteBuffer buffer)` Writes a message on a `ByteBuffer`.

### Methods inherited from class org.apache.mina.codec.delimited.ByteBufferEncoder

`createEncoderState, encode, encode`

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

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

### Constructor Detail

#### ThriftMessageEncoder

    public ThriftMessageEncoder()

### Method Detail

#### newInstance

    public static <L extends org.apache.thrift.TBase<?,?>> ThriftMessageEncoder<L> newInstance(Class<L> clazz)

#### getEncodedSize

    public int getEncodedSize(INPUT message)

Computes the size of the serialized form of a message in bytes.

Specified by:
  `getEncodedSize` in class `ByteBufferEncoder<INPUT extends org.apache.thrift.TBase<?,?>>`
Parameters:
  `message` - a message to be encoded
Returns:
  the size of the serialized form of the message

#### writeTo

    public void writeTo(INPUT message,
               ByteBuffer buffer)

Writes a message on a `ByteBuffer`.

n.b. The buffer is expected to have at least a sufficient capacity to handle the serialized form of the message.

Specified by:
  `writeTo` in class `ByteBufferEncoder<INPUT extends org.apache.thrift.TBase<?,?>>`
Parameters:
  `message` - a message to be encoded
  `buffer` - a target `ByteBuffer`