Top Description Inners Fields Constructors Methods
org.springframework.messaging.simp.stomp

public Class StompEncoder

extends Object
Class Inheritance
Imports
java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .LinkedHashMap, .List, .Map, .Map.Entry, java.util.concurrent.ConcurrentHashMap, org.apache.commons.logging.Log, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.messaging.simp.SimpLogging, .SimpMessageHeaderAccessor, .SimpMessageType, org.springframework.messaging.support.NativeMessageHeaderAccessor, org.springframework.util.Assert

An encoder for STOMP frames.
Authors
Andy Wilkinson, Rossen Stoyanchev
Since
4.0
See Also
StompDecoder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static interface
StompEncoder.Result

Accumulates byte content and returns an aggregated byte[] at the end.

Field Summary

Modifier and TypeField and Description
private static final Byte
private static final int
private final Map<String, byte[]>
private final Map<String, byte[]>
private static final Byte
private static final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

the encoded message
encode
(Message<byte[]>
the message to encode
message
)

Encodes the given STOMP message into a byte[].

public byte[]

Returns:

the encoded message
encode
(Map<String, Object>
the headers
headers
,
byte[]
the payload
payload
)

Encodes the given payload and headers into a byte[].

private byte[]
encodeHeaderKey(String input, boolean escape)

private byte[]
encodeHeaderValue(String input, boolean escape)

private String
escape(String inString)

See STOMP Spec 1.2: "Value Encoding".

private StringBuilder
getStringBuilder(StringBuilder sb, String inString, int i)

private void
writeHeaders(StompCommand command, Map<String, Object> headers, byte[] payload, StompEncoder.Result result)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COLON_BYTEback to summary
private static final Byte COLON_BYTE
HEADER_KEY_CACHE_LIMITback to summary
private static final int HEADER_KEY_CACHE_LIMIT
headerKeyAccessCacheback to summary
private final Map<String, byte[]> headerKeyAccessCache
headerKeyUpdateCacheback to summary
private final Map<String, byte[]> headerKeyUpdateCache
Annotations
@SuppressWarnings:serial
LINE_FEED_BYTEback to summary
private static final Byte LINE_FEED_BYTE
loggerback to summary
private static final Log logger

Constructor Detail

StompEncoderback to summary
public StompEncoder()

Method Detail

encodeback to summary
public byte[] encode(Message<byte[]> message)

Encodes the given STOMP message into a byte[].

Parameters
message:Message<byte[]>

the message to encode

Returns:byte[]

the encoded message

encodeback to summary
public byte[] encode(Map<String, Object> headers, byte[] payload)

Encodes the given payload and headers into a byte[].

Parameters
headers:Map<String, Object>

the headers

payload:byte[]

the payload

Returns:byte[]

the encoded message

encodeHeaderKeyback to summary
private byte[] encodeHeaderKey(String input, boolean escape)
encodeHeaderValueback to summary
private byte[] encodeHeaderValue(String input, boolean escape)
escapeback to summary
private String escape(String inString)

See STOMP Spec 1.2: "Value Encoding".

getStringBuilderback to summary
private StringBuilder getStringBuilder(StringBuilder sb, String inString, int i)
writeHeadersback to summary
private void writeHeaders(StompCommand command, Map<String, Object> headers, byte[] payload, StompEncoder.Result result)
org.springframework.messaging.simp.stomp back to summary

private Class StompEncoder.DefaultResult

extends ArrayList<Object>
implements Result
Class Inheritance
All Implemented Interfaces
org.springframework.messaging.simp.stomp.StompEncoder.Result
Annotations
@SuppressWarnings:serial

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
add(byte[]
element to be appended to this list
bytes
)

Overrides java.util.ArrayList.add.

Implements org.springframework.messaging.simp.stomp.StompEncoder.Result.add, java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this list.

public void
add(byte
element to be appended to this list
b
)

Overrides java.util.ArrayList.add.

Implements org.springframework.messaging.simp.stomp.StompEncoder.Result.add, java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this list.

public byte[]
Inherited from java.util.ArrayList:
addaddAlladdAlladdFirstaddLastclearclonecontainsensureCapacityequalsforEachgetgetFirstgetLasthashCodeindexOfisEmptyiteratorlastIndexOflistIteratorlistIteratorremoveremoveremoveAllremoveFirstremoveIfremoveLastremoveRangereplaceAllretainAllsetsizesortspliteratorsubListtoArraytoArraytrimToSize

Field Detail

sizeback to summary
private int size

Hides java.util.ArrayList.size.

Constructor Detail

DefaultResultback to summary
private DefaultResult()

Method Detail

addback to summary
public void add(byte[] bytes)

Overrides java.util.ArrayList.add.

Implements org.springframework.messaging.simp.stomp.StompEncoder.Result.add, java.util.List.add, java.util.Collection.add.

Doc from java.util.ArrayList.add.

Appends the specified element to the end of this list.

Parameters
bytes:byte[]

element to be appended to this list

Returns:void

true (as specified by Collection#add)

Annotations
@Override
addback to summary
public void add(byte b)

Overrides java.util.ArrayList.add.

Implements org.springframework.messaging.simp.stomp.StompEncoder.Result.add, java.util.List.add, java.util.Collection.add.

Doc from java.util.ArrayList.add.

Appends the specified element to the end of this list.

Parameters
b:byte

element to be appended to this list

Returns:void

true (as specified by Collection#add)

Annotations
@Override
toByteArrayback to summary
public byte[] toByteArray()

Implements org.springframework.messaging.simp.stomp.StompEncoder.Result.toByteArray.

Annotations
@Override
org.springframework.messaging.simp.stomp back to summary

private Interface StompEncoder.Result

Known Direct Implementers
org.springframework.messaging.simp.stomp.StompEncoder.DefaultResult

Accumulates byte content and returns an aggregated byte[] at the end.

Method Summary

Modifier and TypeMethod and Description
public void
add(byte[] bytes)

public void
add(byte b)

public byte[]

Method Detail

addback to summary
public void add(byte[] bytes)
addback to summary
public void add(byte b)
toByteArrayback to summary
public byte[] toByteArray()