org.apache.mina.codec.delimited.serialization

## Class ProtobufMessageEncoder<OUT extends com.google.protobuf.GeneratedMessage>

- java.lang.Object
- - org.apache.mina.codec.delimited.ByteBufferEncoder<OUT>
  - - org.apache.mina.codec.delimited.serialization.ProtobufMessageEncoder<OUT>

- All Implemented Interfaces:
    ProtocolEncoder<OUT,ByteBuffer,Void>, StatelessProtocolEncoder<OUT,ByteBuffer>

      public class ProtobufMessageEncoder<OUT extends com.google.protobuf.GeneratedMessage>
      extends ByteBufferEncoder<OUT>

  Author:
    Apache MINA Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProtobufMessageEncoder()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getEncodedSize(OUT message)` Computes the size of the serialized form of a message in bytes.
    `static <T extends com.google.protobuf.GeneratedMessage> ProtobufMessageEncoder<T>` | `newInstance(Class<T> clazz)`
    `void` | `writeTo(OUT 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

    - #### ProtobufMessageEncoder

          public ProtobufMessageEncoder()

  - ### Method Detail

    - #### newInstance

          public static <T extends com.google.protobuf.GeneratedMessage> ProtobufMessageEncoder<T> newInstance(Class<T> clazz)

    - #### getEncodedSize

          public int getEncodedSize(OUT message)

      Description copied from class: `ByteBufferEncoder`
      Computes the size of the serialized form of a message in bytes.
      Specified by:
        `getEncodedSize` in class `ByteBufferEncoder<OUT extends com.google.protobuf.GeneratedMessage>`
      Parameters:
        `message` - a message to be encoded
      Returns:
        the size of the serialized form of the message

    - #### writeTo

          public void writeTo(OUT message,
                     ByteBuffer buffer)

      Description copied from class: `ByteBufferEncoder`
      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<OUT extends com.google.protobuf.GeneratedMessage>`
      Parameters:
        `message` - a message to be encoded
        `buffer` - a target `ByteBuffer`

Copyright © 2009–2013 Apache MINA Project. All rights reserved.