io.vertx.ext.stomp

## Class Frame

- java.lang.Object
- - io.vertx.ext.stomp.Frame

-     public class Frame
      extends Object

  Represents a STOMP frame. STOMP frames are structured as follows. It starts by a `command`, followed by a set of headers. Then the frame may have a body and is finished by a `0` byte. This class represents this structure and provide access to the different parts.

  This class is NOT thread-safe.
  Author:
    Clement Escoffier

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Frame.Command` The list of command defined by the STOMP specification.
    `static class` | `Frame.Heartbeat` Represents the heartbeat configuration.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ACCEPT_VERSION`
    `static String` | `ACK`
    `static String` | `CONTENT_LENGTH`
    `static String` | `CONTENT_TYPE`
    `static String` | `DESTINATION`
    `static String` | `HEARTBEAT`
    `static String` | `HOST`
    `static String` | `ID`
    `static String` | `LOGIN`
    `static String` | `MESSAGE`
    `static String` | `MESSAGE_ID`
    `static String` | `PASSCODE`
    `static String` | `RECEIPT`
    `static String` | `RECEIPT_ID`
    `static String` | `SERVER`
    `static String` | `SESSION`
    `static String` | `STOMP_FRAME_COMMAND` Header used when a frame using an unknown command is received.
    `static String` | `SUBSCRIPTION`
    `static String` | `TRANSACTION`
    `static String` | `VERSION`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Frame()` Creates an un-configured frame.
    `Frame(Frame.Command command, Map<String,String> headers, Buffer body)` Creates a new instance of `Frame`.
    `Frame(Frame other)` Creates a new instance of `Frame` by copying the values from the `other` frame.
    `Frame(JsonObject json)` Creates a new instance of `Frame` from its JSON representation.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Frame` | `addHeader(String key, String value)` Adds a header to the frame.
    `String` | `encoding()` Read the frame encoding.
    `String` | `getAck()` Gets the value of the `ack` header.
    `Buffer` | `getBody()`
    `byte[]` | `getBodyAsByteArray()`
    `String` | `getBodyAsString()` Gets the body of the frames as a String encoded in the frame encoding.
    `String` | `getBodyAsString(String encoding)` Gets the body of the frames as a String encoded in the given encoding.
    `Frame.Command` | `getCommand()`
    `String` | `getDestination()`
    `String` | `getHeader(String name)` Gets the value of the header with the given name.
    `Map<String,String>` | `getHeaders()` Gets the frame headers.
    `String` | `getId()`
    `String` | `getReceipt()`
    `String` | `getTransaction()`
    `boolean` | `hasEmptyBody()`
    `Frame` | `setBody(Buffer body)` Sets the body of the frame.
    `Frame` | `setCommand(Frame.Command command)` Sets the frame command.
    `Frame` | `setDestination(String destination)`
    `Frame` | `setHeaders(Map<String,String> headers)` Sets the headers of the frames.
    `Frame` | `setId(String id)`
    `Frame` | `setTransaction(String id)`
    `Buffer` | `toBuffer()` This method does not enforce the trailing line option.
    `Buffer` | `toBuffer(boolean trailingLine)` Creates a buffer for the current frame.
    `JsonObject` | `toJson()`
    `String` | `toString()`
    `void` | `validate()` Checks the validity of the frame.

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

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

- - ### Field Detail

    - #### CONTENT_LENGTH

          public static final String CONTENT_LENGTH

      See Also:
        Constant Field Values

    - #### CONTENT_TYPE

          public static final String CONTENT_TYPE

      See Also:
        Constant Field Values

    - #### HOST

          public static final String HOST

      See Also:
        Constant Field Values

    - #### VERSION

          public static final String VERSION

      See Also:
        Constant Field Values

    - #### ACCEPT_VERSION

          public static final String ACCEPT_VERSION

      See Also:
        Constant Field Values

    - #### SESSION

          public static final String SESSION

      See Also:
        Constant Field Values

    - #### SERVER

          public static final String SERVER

      See Also:
        Constant Field Values

    - #### LOGIN

          public static final String LOGIN

      See Also:
        Constant Field Values

    - #### PASSCODE

          public static final String PASSCODE

      See Also:
        Constant Field Values

    - #### HEARTBEAT

          public static final String HEARTBEAT

      See Also:
        Constant Field Values

    - #### DESTINATION

          public static final String DESTINATION

      See Also:
        Constant Field Values

    - #### RECEIPT

          public static final String RECEIPT

      See Also:
        Constant Field Values

    - #### RECEIPT_ID

          public static final String RECEIPT_ID

      See Also:
        Constant Field Values

    - #### ACK

          public static final String ACK

      See Also:
        Constant Field Values

    - #### ID

          public static final String ID

      See Also:
        Constant Field Values

    - #### SUBSCRIPTION

          public static final String SUBSCRIPTION

      See Also:
        Constant Field Values

    - #### MESSAGE_ID

          public static final String MESSAGE_ID

      See Also:
        Constant Field Values

    - #### TRANSACTION

          public static final String TRANSACTION

      See Also:
        Constant Field Values

    - #### MESSAGE

          public static final String MESSAGE

      See Also:
        Constant Field Values

    - #### STOMP_FRAME_COMMAND

          public static final String STOMP_FRAME_COMMAND

      Header used when a frame using an unknown command is received. The created `Frame` object uses the `Frame.Command.UNKNOWN` command and gives the original command in this header.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Frame

          public Frame()

      Creates an un-configured frame. Should only be used by converters.

    - #### Frame

          public Frame(Frame other)

      Creates a new instance of `Frame` by copying the values from the `other` frame. The body of the frame is copied.
      Parameters:
        `other` - the frame to copy.

    - #### Frame

          public Frame(JsonObject json)

      Creates a new instance of `Frame` from its JSON representation.
      Parameters:
        `json` - the json form of the frame

    - #### Frame

          public Frame(Frame.Command command,
                       Map<String,String> headers,
                       Buffer body)

      Creates a new instance of `Frame`.
      Parameters:
        `command` - the command, must not be `null`
        `headers` - the headers, must not be `null`
        `body` - the body

  - ### Method Detail

    - #### addHeader

          public Frame addHeader(String key,
                                 String value)

      Adds a header to the frame.
      Parameters:
        `key` - the header name
        `value` - the header value
      Returns:
        the current `Frame`

    - #### getAck

          public String getAck()

      Gets the value of the `ack` header.
      Returns:
        the `ack` header value, `null` if not set

    - #### getHeaders

          public Map<String,String> getHeaders()

      Gets the frame headers. Modifications to the returned `Map` modifies the headers of the frame.
      Returns:
        the headers

    - #### setHeaders

          public Frame setHeaders(Map<String,String> headers)

      Sets the headers of the frames.
      Parameters:
        `headers` - the header, may be `null`. In the `null` case, an empty map is used to store the frame headers.
      Returns:
        the current `Frame`

    - #### setCommand

          public Frame setCommand(Frame.Command command)

      Sets the frame command.
      Parameters:
        `command` - the command, must not be `null`
      Returns:
        the current `Frame`

    - #### setBody

          public Frame setBody(Buffer body)

      Sets the body of the frame.
      Parameters:
        `body` - the body
      Returns:
        the current `Frame`

    - #### toJson

          public JsonObject toJson()

      Returns:
        the JSON representation of the current frame.

    - #### validate

          public void validate()

      Checks the validity of the frame. Frames must have a valid command, and not all frames can have a body.

    - #### hasEmptyBody

          public boolean hasEmptyBody()

      Returns:
        whether or not the frame has a body.

    - #### getCommand

          public Frame.Command getCommand()

    - #### getHeader

          public String getHeader(String name)

      Gets the value of the header with the given name.
      Parameters:
        `name` - the header name
      Returns:
        the value, `null` if not set

    - #### getBody

          public Buffer getBody()

    - #### getBodyAsString

          public String getBodyAsString(String encoding)

      Gets the body of the frames as a String encoded in the given encoding.
      Parameters:
        `encoding` - the encoding
      Returns:
        the body, `null` if none

    - #### getBodyAsString

          public String getBodyAsString()

      Gets the body of the frames as a String encoded in the frame encoding.
      Returns:
        the body, `null` if none

    - #### encoding

          public String encoding()

      Read the frame encoding. If not set defaults to utf-8.
      Returns:
        the encoding

    - #### getBodyAsByteArray

          public byte[] getBodyAsByteArray()

      Returns:
        the body of the frame as a byte array, `null` if none.

    - #### toBuffer

          public Buffer toBuffer(boolean trailingLine)

      Creates a buffer for the current frame. This buffer may contain an empty line if the `trailingLine` is set to `true`
      Parameters:
        `trailingLine` - whether or not a trailing line should be added to the buffer
      Returns:
        a `Buffer` containing the STOMP frame. It follows strictly the STOMP specification (including header encoding).

    - #### toBuffer

          public Buffer toBuffer()

      This method does not enforce the trailing line option. It should not be used directly, except for the PING frame.
      Returns:
        a `Buffer` containing the STOMP frame. It follows strictly the STOMP specification (including header encoding).

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### setDestination

          public Frame setDestination(String destination)

    - #### setTransaction

          public Frame setTransaction(String id)

    - #### setId

          public Frame setId(String id)

    - #### getId

          public String getId()

    - #### getReceipt

          public String getReceipt()

    - #### getTransaction

          public String getTransaction()

    - #### getDestination

          public String getDestination()

Copyright © 2018 Eclipse. All rights reserved.