org.apache.mina.coap

## Class CoapMessage

- java.lang.Object
- - org.apache.mina.coap.CoapMessage

All Implemented Interfaces:
  Request, Response

    public class CoapMessage
    extends Object
    implements Request, Response

A representation of CoAP message following the CoAP RFC.

Author:
  Apache MINA Project

### Constructor Summary

Constructors
Constructor and Description
`CoapMessage(int version, MessageType type, int code, int id, byte[] token, CoapOption[] options, byte[] payload)` Create a CoAP message

### Method Summary

Methods
`boolean` `equals(Object obj)`
`static CoapMessage` `get(String url, boolean confimable)`
`Integer` `getAccept()`
`int` `getCode()`
`Integer` `getContentFormat()`
`int` `getId()`
`String[]` `getLocationPath()`
`String[]` `getLocationQuery()`
`Integer` `getMaxAge()`
`CoapOption[]` `getOptions()`
`byte[]` `getPayload()`
`String` `getProxyScheme()`
`String` `getProxyUri()` return the absolute URI used to make a request to a forward-proxy
`byte[]` `getToken()`
`MessageType` `getType()`
`String` `getUriHost()`
`String[]` `getUriPath()`
`Integer` `getUriPort()`
`String[]` `getUriQuery()`
`int` `getVersion()`
`int` `hashCode()`
`static CoapMessage` `post(String url, boolean confimable, byte[] payload)`
`Object` `requestId()`
`void` `setCode(int code)`
`void` `setId(int id)`
`void` `setOptions(CoapOption[] options)`
`void` `setPayload(byte[] payload)`
`void` `setToken(byte[] token)`
`void` `setType(MessageType type)`
`void` `setVersion(int version)`
`String` `toString()`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CoapMessage

    public CoapMessage(int version,
               MessageType type,
               int code,
               int id,
               byte[] token,
               CoapOption[] options,
               byte[] payload)

Create a CoAP message

Parameters:
  `version` - the version (you probably want 1 here)
  `type` - the type of CoAP message
  `code` - the message code : `CoapCode`
  `id` - the identifier for this message
  `token` - the message token (can be `null`)
  `options` - list of options for this message (can be `null`)
  `payload` - the payload of the message (can be `null`

### Method Detail

#### get

    public static final CoapMessage get(String url,
                  boolean confimable)

#### post

    public static final CoapMessage post(String url,
                   boolean confimable,
                   byte[] payload)

#### requestId

    public Object requestId()

Specified by:
  `requestId` in interface `Request`
Specified by:
  `requestId` in interface `Response`
Returns:
  the identifier of the associated request or `null` if none

#### getVersion

    public int getVersion()

#### getCode

    public int getCode()

#### getId

    public int getId()

#### getToken

    public byte[] getToken()

#### getPayload

    public byte[] getPayload()

#### getOptions

    public CoapOption[] getOptions()

#### getType

    public MessageType getType()

#### getUriPath

    public String[] getUriPath()

Returns:
  all segments of the absolute path to the resource

#### getUriQuery

    public String[] getUriQuery()

Returns:
  all arguments parameterizing the resource

#### getUriHost

    public String getUriHost()

Returns:
  the Internet host of the resource being requested

#### getUriPort

    public Integer getUriPort()

Returns:
  the transport layer port number of the resource

#### getProxyUri

    public String getProxyUri()

return the absolute URI used to make a request to a forward-proxy

#### getProxyScheme

    public String getProxyScheme()

Returns:
  the scheme to be used in the proxy URI

#### getContentFormat

    public Integer getContentFormat()

Returns:
  the representation format of the message payload

#### getAccept

    public Integer getAccept()

Returns:
  which Content-Format is acceptable to the client

#### getMaxAge

    public Integer getMaxAge()

Returns:
  the maximum time a response may be cached before it is considered not fresh

#### getLocationPath

    public String[] getLocationPath()

Returns:
  all segments of the path to the created resource (as the result of a POST request)

#### getLocationQuery

    public String[] getLocationQuery()

Returns:
  all arguments parameterizing the created resource (as the result of a POST request)

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### setVersion

    public void setVersion(int version)

#### setType

    public void setType(MessageType type)

#### setCode

    public void setCode(int code)

#### setId

    public void setId(int id)

#### setToken

    public void setToken(byte[] token)

#### setPayload

    public void setPayload(byte[] payload)

#### setOptions

    public void setOptions(CoapOption[] options)