类 StompHeaders
- java.lang.Object
- org.springframework.messaging.simp.stomp.StompHeaders
- 所有已实现的接口:
Serializable,Map<String,List<String>>,MultiValueMap<String,String>
public class StompHeaders extends Object implements MultiValueMap<String,String>, Serializable
Represents STOMP frame headers.In addition to the normal methods defined by
Map, this class offers the following convenience methods:getFirst(String)return the first value for a header nameadd(String, String)add to the list of values for a header nameset(String, String)set a header name to a single string value
- 从以下版本开始:
- 4.2
- 作者:
- Rossen Stoyanchev
- 另请参阅:
- https://stomp.github.io/stomp-specification-1.2.html#Frames_and_Headers, 序列化表格
字段概要
字段 修饰符和类型 字段 说明 static StringACCEPT_VERSIONstatic StringACKstatic StringCONTENT_LENGTHstatic StringCONTENT_TYPEstatic StringDESTINATIONstatic StringHEARTBEATstatic StringHOSTstatic StringIDstatic StringLOGINstatic StringMESSAGE_IDstatic StringPASSCODEstatic StringRECEIPTstatic StringRECEIPT_IDstatic StringSERVERstatic StringSESSIONstatic StringSUBSCRIPTION
构造器概要
构造器 构造器 说明 StompHeaders()Create a new instance to be populated with new header values.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 voidadd(String headerName, String headerValue)Add the given, single header value under the given name.voidaddAll(String headerName, List<? extends String> headerValues)Add all the values of the given list to the current list of values for the given key.voidaddAll(MultiValueMap<String,String> values)Add all the values of the givenMultiValueMapto the current values.voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,List<String>>>entrySet()booleanequals(Object other)List<String>get(Object key)String[]getAcceptVersion()Get the accept-version header.StringgetAck()Get the ack header.longgetContentLength()Return the content-length header or -1 if unknown.MimeTypegetContentType()Return the content-type header value.StringgetDestination()Get the destination header.StringgetFirst(String headerName)Return the first header value for the given header name, if any.long[]getHeartbeat()Get the heartbeat header.StringgetHost()Get the host header.StringgetId()Get the id header.StringgetLogin()Get the login header.StringgetMessageId()Get the message-id header.StringgetPasscode()Get the passcode header.StringgetReceipt()Get the receipt header.StringgetReceiptId()Get the receipt header.StringgetServer()Get the server header.StringgetSession()Get the session header.StringgetSubscription()Get the subscription header.inthashCode()booleanisEmpty()booleanisHeartbeatEnabled()Whether heartbeats are enabled.Set<String>keySet()List<String>put(String key, List<String> value)voidputAll(Map<? extends String,? extends List<String>> map)static StompHeadersreadOnlyStompHeaders(Map<String,List<String>> headers)Return aStompHeadersobject that can only be read, not written to.List<String>remove(Object key)voidset(String headerName, String headerValue)Set the given, single header value under the given name.voidsetAcceptVersion(String... acceptVersions)Set the accept-version header.voidsetAck(String ack)Set the ack header to one of "auto", "client", or "client-individual".voidsetAll(Map<String,String> values)Set the given values under.voidsetContentLength(long contentLength)Set the content-length header.voidsetContentType(MimeType mimeType)Set the content-type header.voidsetDestination(String destination)Set the destination header.voidsetHeartbeat(long[] heartbeat)Set the heartbeat header.voidsetHost(String host)Set the host header.voidsetId(String id)Set the id header.voidsetLogin(String login)Set the login header.voidsetMessageId(String messageId)Set the message-id header.voidsetPasscode(String passcode)Set the passcode header.voidsetReceipt(String receipt)Set the receipt header.voidsetReceiptId(String receiptId)Set the receipt-id header.voidsetServer(String server)Set the server header.voidsetSession(String session)Set the session header.voidsetSubscription(String subscription)Set the login header.intsize()Map<String,String>toSingleValueMap()Return aMapwith the first values contained in thisMultiValueMap.StringtoString()Collection<List<String>>values()从接口继承的方法 java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
从接口继承的方法 org.springframework.util.MultiValueMap
addIfAbsent
字段详细资料
CONTENT_TYPE
public static final String CONTENT_TYPE
- 另请参阅:
- 常量字段值
CONTENT_LENGTH
public static final String CONTENT_LENGTH
- 另请参阅:
- 常量字段值
ACCEPT_VERSION
public static final String ACCEPT_VERSION
- 另请参阅:
- 常量字段值
DESTINATION
public static final String DESTINATION
- 另请参阅:
- 常量字段值
SUBSCRIPTION
public static final String SUBSCRIPTION
- 另请参阅:
- 常量字段值
MESSAGE_ID
public static final String MESSAGE_ID
- 另请参阅:
- 常量字段值
RECEIPT_ID
public static final String RECEIPT_ID
- 另请参阅:
- 常量字段值
构造器详细资料
StompHeaders
public StompHeaders()
Create a new instance to be populated with new header values.
方法详细资料
setContentType
public void setContentType(@Nullable MimeType mimeType)
Set the content-type header. Applies to the SEND, MESSAGE, and ERROR frames.
getContentType
@Nullable public MimeType getContentType()
Return the content-type header value.
setContentLength
public void setContentLength(long contentLength)
Set the content-length header. Applies to the SEND, MESSAGE, and ERROR frames.
getContentLength
public long getContentLength()
Return the content-length header or -1 if unknown.
setReceipt
public void setReceipt(@Nullable String receipt)
Set the receipt header. Applies to any client frame other than CONNECT.
getReceipt
@Nullable public String getReceipt()
Get the receipt header.
setHost
public void setHost(@Nullable String host)
Set the host header. Applies to the CONNECT frame.
setAcceptVersion
public void setAcceptVersion(@Nullable String... acceptVersions)
Set the accept-version header. Must be one of "1.1", "1.2", or both. Applies to the CONNECT frame.- 从以下版本开始:
- 5.0.7
getAcceptVersion
@Nullable public String[] getAcceptVersion()
Get the accept-version header.- 从以下版本开始:
- 5.0.7
setLogin
public void setLogin(@Nullable String login)
Set the login header. Applies to the CONNECT frame.
setPasscode
public void setPasscode(@Nullable String passcode)
Set the passcode header. Applies to the CONNECT frame.
getPasscode
@Nullable public String getPasscode()
Get the passcode header.
setHeartbeat
public void setHeartbeat(@Nullable long[] heartbeat)
Set the heartbeat header. Applies to the CONNECT and CONNECTED frames.
getHeartbeat
@Nullable public long[] getHeartbeat()
Get the heartbeat header.
isHeartbeatEnabled
public boolean isHeartbeatEnabled()
Whether heartbeats are enabled. ReturnsfalseifsetHeartbeat(long[])is set to "0,0", andtrueotherwise.
setSession
public void setSession(@Nullable String session)
Set the session header. Applies to the CONNECTED frame.
getSession
@Nullable public String getSession()
Get the session header.
setServer
public void setServer(@Nullable String server)
Set the server header. Applies to the CONNECTED frame.
setDestination
public void setDestination(@Nullable String destination)
Set the destination header.
getDestination
@Nullable public String getDestination()
Get the destination header. Applies to the SEND, SUBSCRIBE, and MESSAGE frames.
setId
public void setId(@Nullable String id)
Set the id header. Applies to the SUBSCR0BE, UNSUBSCRIBE, and ACK or NACK frames.
setAck
public void setAck(@Nullable String ack)
Set the ack header to one of "auto", "client", or "client-individual". Applies to the SUBSCRIBE and MESSAGE frames.
setSubscription
public void setSubscription(@Nullable String subscription)
Set the login header. Applies to the MESSAGE frame.
getSubscription
@Nullable public String getSubscription()
Get the subscription header.
setMessageId
public void setMessageId(@Nullable String messageId)
Set the message-id header. Applies to the MESSAGE frame.
getMessageId
@Nullable public String getMessageId()
Get the message-id header.
setReceiptId
public void setReceiptId(@Nullable String receiptId)
Set the receipt-id header. Applies to the RECEIPT frame.
getReceiptId
@Nullable public String getReceiptId()
Get the receipt header.
getFirst
@Nullable public String getFirst(String headerName)
Return the first header value for the given header name, if any.- 指定者:
getFirst在接口中MultiValueMap<String,String>- 参数:
headerName- the header name- 返回:
- the first header value, or
nullif none
add
public void add(String headerName, @Nullable String headerValue)
Add the given, single header value under the given name.- 指定者:
add在接口中MultiValueMap<String,String>- 参数:
headerName- the header nameheaderValue- the header value- 抛出:
UnsupportedOperationException- if adding headers is not supported- 另请参阅:
put(String, List),set(String, String)
addAll
public void addAll(String headerName, List<? extends String> headerValues)
从接口复制的说明:MultiValueMapAdd all the values of the given list to the current list of values for the given key.- 指定者:
addAll在接口中MultiValueMap<String,String>- 参数:
headerName- they keyheaderValues- the values to be added
addAll
public void addAll(MultiValueMap<String,String> values)
从接口复制的说明:MultiValueMapAdd all the values of the givenMultiValueMapto the current values.- 指定者:
addAll在接口中MultiValueMap<String,String>- 参数:
values- the values to be added
set
public void set(String headerName, @Nullable String headerValue)
Set the given, single header value under the given name.- 指定者:
set在接口中MultiValueMap<String,String>- 参数:
headerName- the header nameheaderValue- the header value- 抛出:
UnsupportedOperationException- if adding headers is not supported- 另请参阅:
put(String, List),add(String, String)
setAll
public void setAll(Map<String,String> values)
从接口复制的说明:MultiValueMapSet the given values under.- 指定者:
setAll在接口中MultiValueMap<String,String>- 参数:
values- the values.
toSingleValueMap
public Map<String,String> toSingleValueMap()
从接口复制的说明:MultiValueMapReturn aMapwith the first values contained in thisMultiValueMap.- 指定者:
toSingleValueMap在接口中MultiValueMap<String,String>- 返回:
- a single value representation of this map
containsKey
public boolean containsKey(Object key)
- 指定者:
containsKey在接口中Map<String,List<String>>
containsValue
public boolean containsValue(Object value)
- 指定者:
containsValue在接口中Map<String,List<String>>
readOnlyStompHeaders
public static StompHeaders readOnlyStompHeaders(@Nullable Map<String,List<String>> headers)
Return aStompHeadersobject that can only be read, not written to.