org.apache.mina.codec.delimited.serialization

## Class ProtobufMessageDecoder<IN extends com.google.protobuf.GeneratedMessage>

- java.lang.Object
- - org.apache.mina.codec.delimited.IoBufferDecoder<IN>
  - - org.apache.mina.codec.delimited.serialization.ProtobufMessageDecoder<IN>

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

    public final class ProtobufMessageDecoder<IN extends com.google.protobuf.GeneratedMessage>
    extends IoBufferDecoder<IN>

Author:
  Apache MINA Project

### Method Summary

Methods
`IN` `decode(IoBuffer input)` Decodes a message from a `IoBuffer` When a truncated input is given to this method it may return null.
`static <TYPE extends com.google.protobuf.GeneratedMessage> ProtobufMessageDecoder<TYPE>` `newInstance(Class<TYPE> c)`
`static <TYPE extends com.google.protobuf.GeneratedMessage> ProtobufMessageDecoder<TYPE>` `newInstance(Class<TYPE> c, com.google.protobuf.ExtensionRegistryLite registry)`

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

`createDecoderState, decode, finishDecode`

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

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

### Method Detail

#### newInstance

    public static <TYPE extends com.google.protobuf.GeneratedMessage> ProtobufMessageDecoder<TYPE> newInstance(Class<TYPE> c)
                                                                                                 throws NoSuchMethodException

Throws:
  `NoSuchMethodException`

#### newInstance

    public static <TYPE extends com.google.protobuf.GeneratedMessage> ProtobufMessageDecoder<TYPE> newInstance(Class<TYPE> c,
                                                                                               com.google.protobuf.ExtensionRegistryLite registry)
                                                                                                 throws NoSuchMethodException

Throws:
  `NoSuchMethodException`

#### decode

    public IN decode(IoBuffer input)

Description copied from class: `IoBufferDecoder`
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.

Specified by:
  `decode` in class `IoBufferDecoder<IN extends com.google.protobuf.GeneratedMessage>`
Parameters:
  `input` - data to be decoded as a TYPE message
Returns:
  the decoded message on success, null otherwise