public class Frame extends Object
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.Modifier and Type | Class and Description |
---|---|
static class |
Frame.Heartbeat
Represents the heartbeat configuration.
|
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 and Description |
---|
Frame()
Creates an un-configured 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. |
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.
|
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(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.
|
public static final String CONTENT_LENGTH
public static final String CONTENT_TYPE
public static final String HOST
public static final String VERSION
public static final String ACCEPT_VERSION
public static final String SESSION
public static final String SERVER
public static final String LOGIN
public static final String PASSCODE
public static final String HEARTBEAT
public static final String DESTINATION
public static final String RECEIPT
public static final String RECEIPT_ID
public static final String ACK
public static final String ID
public static final String SUBSCRIPTION
public static final String MESSAGE_ID
public static final String TRANSACTION
public static final String MESSAGE
public static final String STOMP_FRAME_COMMAND
Frame
object uses
the Command.UNKNOWN
command and gives the original command in this header.public Frame()
public Frame(Frame other)
Frame
by copying the values from the other
frame. The body of the
frame is copied.other
- the frame to copy.public Frame(JsonObject json)
Frame
from its JSON representation.json
- the json form of the framepublic Frame addHeader(String key, String value)
key
- the header namevalue
- the header valueFrame
public String getAck()
ack
header.ack
header value, null
if not setpublic Map<String,String> getHeaders()
Map
modifies the headers of the frame.public Frame setHeaders(Map<String,String> headers)
headers
- the header, may be null
. In the null
case, an empty map is used to store the
frame headers.Frame
public Frame setCommand(Command command)
command
- the command, must not be null
Frame
public Frame setBody(Buffer body)
body
- the bodyFrame
public JsonObject toJson()
public void validate()
public boolean hasEmptyBody()
public Command getCommand()
public String getHeader(String name)
name
- the header namenull
if not setpublic Buffer getBody()
public String getBodyAsString(String encoding)
encoding
- the encodingnull
if nonepublic String getBodyAsString()
null
if nonepublic String encoding()
public byte[] getBodyAsByteArray()
null
if none.public Buffer toBuffer(boolean trailingLine)
trailingLine
is set
to true
trailingLine
- whether or not a trailing line should be added to the bufferBuffer
containing the STOMP frame. It follows strictly the STOMP specification (including
header encoding).public Buffer toBuffer()
Buffer
containing the STOMP frame. It follows strictly the STOMP specification (including
header encoding).public String getId()
public String getReceipt()
public String getTransaction()
public String getDestination()
Copyright © 2023 Eclipse. All rights reserved.