Class StompHeaders

java.lang.Object
org.springframework.messaging.simp.stomp.StompHeaders
All Implemented Interfaces:
Serializable, Map<String,List<String>>, org.springframework.util.MultiValueMap<String,String>

public class StompHeaders extends Object implements org.springframework.util.MultiValueMap<String,String>, Serializable
Represents STOMP frame headers.

In addition to the normal methods defined by Map, this class offers the following convenience methods:

Since:
4.2
Author:
Rossen Stoyanchev
See Also:
  • Field Details

  • Constructor Details

    • StompHeaders

      public StompHeaders()
      Create a new instance to be populated with new header values.
  • Method Details

    • setContentType

      public void setContentType(@Nullable org.springframework.util.MimeType mimeType)
      Set the content-type header. Applies to the SEND, MESSAGE, and ERROR frames.
    • getContentType

      @Nullable public org.springframework.util.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.
    • getHost

      @Nullable public String getHost()
      Get the host header.
    • 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.
      Since:
      5.0.7
    • getAcceptVersion

      @Nullable public String[] getAcceptVersion()
      Get the accept-version header.
      Since:
      5.0.7
    • setLogin

      public void setLogin(@Nullable String login)
      Set the login header. Applies to the CONNECT frame.
    • getLogin

      @Nullable public String getLogin()
      Get the login header.
    • 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. Returns false if setHeartbeat(long[]) is set to "0,0", and true otherwise.
    • 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.
    • getServer

      @Nullable public String getServer()
      Get 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.
    • getId

      @Nullable public String getId()
      Get the id header.
    • 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.
    • getAck

      @Nullable public String getAck()
      Get the ack header.
    • 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.
      Specified by:
      getFirst in interface org.springframework.util.MultiValueMap<String,String>
      Parameters:
      headerName - the header name
      Returns:
      the first header value, or null if none
    • add

      public void add(String headerName, @Nullable String headerValue)
      Add the given, single header value under the given name.
      Specified by:
      add in interface org.springframework.util.MultiValueMap<String,String>
      Parameters:
      headerName - the header name
      headerValue - the header value
      Throws:
      UnsupportedOperationException - if adding headers is not supported
      See Also:
    • addAll

      public void addAll(String headerName, List<? extends String> headerValues)
      Specified by:
      addAll in interface org.springframework.util.MultiValueMap<String,String>
    • addAll

      public void addAll(org.springframework.util.MultiValueMap<String,String> values)
      Specified by:
      addAll in interface org.springframework.util.MultiValueMap<String,String>
    • set

      public void set(String headerName, @Nullable String headerValue)
      Set the given, single header value under the given name.
      Specified by:
      set in interface org.springframework.util.MultiValueMap<String,String>
      Parameters:
      headerName - the header name
      headerValue - the header value
      Throws:
      UnsupportedOperationException - if adding headers is not supported
      See Also:
    • setAll

      public void setAll(Map<String,String> values)
      Specified by:
      setAll in interface org.springframework.util.MultiValueMap<String,String>
    • toSingleValueMap

      public Map<String,String> toSingleValueMap()
      Specified by:
      toSingleValueMap in interface org.springframework.util.MultiValueMap<String,String>
    • size

      public int size()
      Specified by:
      size in interface Map<String,List<String>>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,List<String>>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,List<String>>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,List<String>>
    • get

      public List<String> get(Object key)
      Specified by:
      get in interface Map<String,List<String>>
    • put

      public List<String> put(String key, List<String> value)
      Specified by:
      put in interface Map<String,List<String>>
    • remove

      public List<String> remove(Object key)
      Specified by:
      remove in interface Map<String,List<String>>
    • putAll

      public void putAll(Map<? extends String,? extends List<String>> map)
      Specified by:
      putAll in interface Map<String,List<String>>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,List<String>>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,List<String>>
    • values

      public Collection<List<String>> values()
      Specified by:
      values in interface Map<String,List<String>>
    • entrySet

      public Set<Map.Entry<String,List<String>>> entrySet()
      Specified by:
      entrySet in interface Map<String,List<String>>
    • equals

      public boolean equals(@Nullable Object other)
      Specified by:
      equals in interface Map<String,List<String>>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,List<String>>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • readOnlyStompHeaders

      public static StompHeaders readOnlyStompHeaders(@Nullable Map<String,List<String>> headers)
      Return a StompHeaders object that can only be read, not written to.