Package io.vertx.ext.stomp.lite.frame
Class Frame
- java.lang.Object
-
- io.vertx.ext.stomp.lite.frame.Frame
-
public class Frame extends java.lang.ObjectRepresents a STOMP frame. STOMP frames are structured as follows. It starts by acommand, followed by a set of headers. Then the frame may have a body and is finished by a0byte. This class represents this structure and provide access to the different parts. This class is NOT thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFrame.CommandThe list of command defined by the STOMP specification.static classFrame.HeartbeatRepresents the heartbeat configuration.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACCEPT_VERSIONstatic java.lang.StringACKstatic java.lang.StringCONTENT_LENGTHstatic java.lang.StringCONTENT_TYPEstatic java.lang.StringDESTINATIONstatic java.lang.StringHEARTBEATstatic java.lang.StringHOSTstatic java.lang.StringIDstatic java.lang.StringLOGINstatic java.lang.StringMESSAGEstatic java.lang.StringMESSAGE_IDstatic java.lang.StringPASSCODEstatic java.lang.StringRECEIPTstatic java.lang.StringRECEIPT_IDstatic java.lang.StringSERVERstatic java.lang.StringSESSIONstatic java.lang.StringSTOMP_FRAME_COMMANDHeader used when a frame using an unknown command is received.static java.lang.StringSUBSCRIPTIONstatic java.lang.StringTRANSACTIONstatic java.lang.StringUTF_8static java.lang.StringVERSION
-
Constructor Summary
Constructors Constructor Description Frame()Creates an un-configured frame.Frame(io.vertx.core.json.JsonObject json)Creates a new instance ofFramefrom its JSON representation.Frame(Frame other)Creates a new instance ofFrameby copying the values from theotherframe.Frame(Frame.Command command, java.util.Map<java.lang.String,java.lang.String> headers, io.vertx.core.buffer.Buffer body)Creates a new instance ofFrame.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FrameaddHeader(java.lang.String key, java.lang.String value)Adds a header to the frame.java.lang.Stringencoding()Read the frame encoding.java.lang.StringgetAck()Gets the value of theackheader.io.vertx.core.buffer.BuffergetBody()byte[]getBodyAsByteArray()java.lang.StringgetBodyAsString()Gets the body of the frames as a String encoded in the frame encoding.java.lang.StringgetBodyAsString(java.lang.String encoding)Gets the body of the frames as a String encoded in the given encoding.Frame.CommandgetCommand()java.lang.StringgetDestination()java.lang.StringgetHeader(java.lang.String name)Gets the value of the header with the given name.java.util.Map<java.lang.String,java.lang.String>getHeaders()Gets the frame headers.java.lang.StringgetId()java.lang.StringgetReceipt()java.lang.StringgetTransaction()booleanhasEmptyBody()FramesetBody(io.vertx.core.buffer.Buffer body)Sets the body of the frame.FramesetCommand(Frame.Command command)Sets the frame command.FramesetDestination(java.lang.String destination)FramesetHeaders(java.util.Map<java.lang.String,java.lang.String> headers)Sets the headers of the frames.FramesetId(java.lang.String id)FramesetTransaction(java.lang.String id)io.vertx.core.buffer.BuffertoBuffer()This method does not enforce the trailing line option.io.vertx.core.buffer.BuffertoBuffer(boolean trailingLine)Creates a buffer for the current frame.io.vertx.core.json.JsonObjecttoJson()java.lang.StringtoString()voidvalidate()Checks the validity of the frame.
-
-
-
Field Detail
-
UTF_8
public static final java.lang.String UTF_8
- See Also:
- Constant Field Values
-
CONTENT_LENGTH
public static final java.lang.String CONTENT_LENGTH
- See Also:
- Constant Field Values
-
CONTENT_TYPE
public static final java.lang.String CONTENT_TYPE
- See Also:
- Constant Field Values
-
HOST
public static final java.lang.String HOST
- See Also:
- Constant Field Values
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
ACCEPT_VERSION
public static final java.lang.String ACCEPT_VERSION
- See Also:
- Constant Field Values
-
SESSION
public static final java.lang.String SESSION
- See Also:
- Constant Field Values
-
SERVER
public static final java.lang.String SERVER
- See Also:
- Constant Field Values
-
LOGIN
public static final java.lang.String LOGIN
- See Also:
- Constant Field Values
-
PASSCODE
public static final java.lang.String PASSCODE
- See Also:
- Constant Field Values
-
HEARTBEAT
public static final java.lang.String HEARTBEAT
- See Also:
- Constant Field Values
-
DESTINATION
public static final java.lang.String DESTINATION
- See Also:
- Constant Field Values
-
RECEIPT
public static final java.lang.String RECEIPT
- See Also:
- Constant Field Values
-
RECEIPT_ID
public static final java.lang.String RECEIPT_ID
- See Also:
- Constant Field Values
-
ACK
public static final java.lang.String ACK
- See Also:
- Constant Field Values
-
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
-
SUBSCRIPTION
public static final java.lang.String SUBSCRIPTION
- See Also:
- Constant Field Values
-
MESSAGE_ID
public static final java.lang.String MESSAGE_ID
- See Also:
- Constant Field Values
-
TRANSACTION
public static final java.lang.String TRANSACTION
- See Also:
- Constant Field Values
-
MESSAGE
public static final java.lang.String MESSAGE
- See Also:
- Constant Field Values
-
STOMP_FRAME_COMMAND
public static final java.lang.String STOMP_FRAME_COMMAND
Header used when a frame using an unknown command is received. The createdFrameobject uses theFrame.Command.UNKNOWNcommand 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 ofFrameby copying the values from theotherframe. The body of the frame is copied.- Parameters:
other- the frame to copy.
-
Frame
public Frame(io.vertx.core.json.JsonObject json)
Creates a new instance ofFramefrom its JSON representation.- Parameters:
json- the json form of the frame
-
Frame
public Frame(Frame.Command command, java.util.Map<java.lang.String,java.lang.String> headers, io.vertx.core.buffer.Buffer body)
Creates a new instance ofFrame.- Parameters:
command- the command, must not benullheaders- the headers, must not benullbody- the body
-
-
Method Detail
-
addHeader
public Frame addHeader(java.lang.String key, java.lang.String value)
Adds a header to the frame.- Parameters:
key- the header namevalue- the header value- Returns:
- the current
Frame
-
getAck
public java.lang.String getAck()
Gets the value of theackheader.- Returns:
- the
ackheader value,nullif not set
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
Gets the frame headers. Modifications to the returnedMapmodifies the headers of the frame.- Returns:
- the headers
-
setHeaders
public Frame setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Sets the headers of the frames.- Parameters:
headers- the header, may benull. In thenullcase, 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 benull- Returns:
- the current
Frame
-
setBody
public Frame setBody(io.vertx.core.buffer.Buffer body)
Sets the body of the frame.- Parameters:
body- the body- Returns:
- the current
Frame
-
toJson
public io.vertx.core.json.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 java.lang.String getHeader(java.lang.String name)
Gets the value of the header with the given name.- Parameters:
name- the header name- Returns:
- the value,
nullif not set
-
getBody
public io.vertx.core.buffer.Buffer getBody()
-
getBodyAsString
public java.lang.String getBodyAsString(java.lang.String encoding)
Gets the body of the frames as a String encoded in the given encoding.- Parameters:
encoding- the encoding- Returns:
- the body,
nullif none
-
getBodyAsString
public java.lang.String getBodyAsString()
Gets the body of the frames as a String encoded in the frame encoding.- Returns:
- the body,
nullif none
-
encoding
public java.lang.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,
nullif none.
-
toBuffer
public io.vertx.core.buffer.Buffer toBuffer(boolean trailingLine)
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
public io.vertx.core.buffer.Buffer toBuffer()
This method does not enforce the trailing line option. It should not be used directly, except for the PING frame.- Returns:
- a
Buffercontaining the STOMP frame. It follows strictly the STOMP specification (including header encoding).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setDestination
public Frame setDestination(java.lang.String destination)
-
setTransaction
public Frame setTransaction(java.lang.String id)
-
setId
public Frame setId(java.lang.String id)
-
getId
public java.lang.String getId()
-
getReceipt
public java.lang.String getReceipt()
-
getTransaction
public java.lang.String getTransaction()
-
getDestination
public java.lang.String getDestination()
-
-