Class Frame
java.lang.Object
io.vertx.ext.stomp.Frame
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 ClassesModifier and TypeClassDescriptionstatic classRepresents the heartbeat configuration. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringHeader used when a frame using an unknown command is received.static final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a header to the frame.encoding()Read the frame encoding.getAck()Gets the value of theackheader.getBody()byte[]Gets the body of the frames as a String encoded in the frame encoding.getBodyAsString(String encoding) Gets the body of the frames as a String encoded in the given encoding.Gets the value of the header with the given name.Gets the frame headers.getId()booleanSets the body of the frame.setCommand(Command command) Sets the frame command.setDestination(String destination) setHeaders(Map<String, String> headers) Sets the headers of the frames.setTransaction(String id) toBuffer()This method does not enforce the trailing line option.toBuffer(boolean trailingLine) Creates a buffer for the current frame.toJson()toString()voidvalidate()Checks the validity of the frame.
-
Field Details
-
CONTENT_LENGTH
- See Also:
-
CONTENT_TYPE
- See Also:
-
HOST
- See Also:
-
VERSION
- See Also:
-
ACCEPT_VERSION
- See Also:
-
SESSION
- See Also:
-
SERVER
- See Also:
-
LOGIN
- See Also:
-
PASSCODE
- See Also:
-
HEARTBEAT
- See Also:
-
DESTINATION
- See Also:
-
RECEIPT
- See Also:
-
RECEIPT_ID
- See Also:
-
ACK
- See Also:
-
ID
- See Also:
-
SUBSCRIPTION
- See Also:
-
MESSAGE_ID
- See Also:
-
TRANSACTION
- See Also:
-
MESSAGE
- See Also:
-
STOMP_FRAME_COMMAND
Header used when a frame using an unknown command is received. The createdFrameobject uses theCommand.UNKNOWNcommand and gives the original command in this header.- See Also:
-
-
Constructor Details
-
Frame
public Frame()Creates an un-configured frame. Should only be used by converters. -
Frame
-
Frame
Creates a new instance ofFramefrom its JSON representation.- Parameters:
json- the json form of the frame
-
Frame
-
-
Method Details
-
addHeader
-
getAck
Gets the value of theackheader.- Returns:
- the
ackheader value,nullif not set
-
getHeaders
-
setHeaders
-
setCommand
-
setBody
-
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
-
getHeader
-
getBody
-
getBodyAsString
-
getBodyAsString
Gets the body of the frames as a String encoded in the frame encoding.- Returns:
- the body,
nullif none
-
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,
nullif none.
-
toBuffer
Creates a buffer for the current frame. This buffer may contain an empty line if thetrailingLineis set totrue- Parameters:
trailingLine- whether or not a trailing line should be added to the buffer- Returns:
- a
Buffercontaining the STOMP frame. It follows strictly the STOMP specification (including header encoding).
-
toBuffer
-
toString
-
setDestination
-
setTransaction
-
setId
-
getId
-
getReceipt
-
getTransaction
-
getDestination
-