org.apache.mina.coap.codec

## Class CoapEncoder

- java.lang.Object
- - org.apache.mina.coap.codec.CoapEncoder

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

    public class CoapEncoder
    extends Object
    implements StatelessProtocolEncoder<CoapMessage,ByteBuffer>

Encode a CoAP message following the RFC. Encode `CoapMessage` into `ByteBuffer`

Author:
  Apache MINA Project

### Constructor Summary

Constructors
Constructor and Description
`CoapEncoder()`

### Method Summary

Methods
`Void` `createEncoderState()` Create a new session context for this decoder
`ByteBuffer` `encode(CoapMessage 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

#### CoapEncoder

    public CoapEncoder()

### Method Detail

#### createEncoderState

    public Void createEncoderState()

Create a new session context for this decoder

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

#### encode

    public ByteBuffer encode(CoapMessage message,
                    Void context)

Encodes higher-level message objects of type `INPUT` into binary or protocol-specific data of type `OUTPUT`.

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