A protected constructor to create new headers.
A protected constructor to create new headers. @param nativeHeaders native headers to create the message with (may be {@code null})
A protected constructor accepting the headers of an existing message to copy.
Add the specified native header value to existing values.
Whether the native header map contains the give header name.
Return the first value for the specified native header, or {@code null} if none.
Return all values for the specified native header. or {@code null} if none.
Set the specified native header value replacing existing values.
Return a copy of the native header values or an empty map.
The header name used to store native headers.
The default charset used for headers.
Build a 'nested' accessor for the given message. @param message the message to build a new accessor for @return the nested accessor (typically a specific subclass)
By default when {@link #getMessageHeaders()} is called, {@code "this"} {@code MessageHeaderAccessor} instance can no longer be used to modify the underlying message headers and the returned {@code MessageHeaders} is immutable. <p>However when this is set to {@code true}, the returned (underlying) {@code MessageHeaders} instance remains mutable. To make further modifications continue to use the same accessor instance or re-obtain it via:<br> {@link MessageHeaderAccessor#getAccessor(Message, Class) MessageHeaderAccessor.getAccessor(Message, Class)} <p>When modifications are complete use {@link #setImmutable()} to prevent further changes. The intended use case for this mechanism is initialization of a Message within a single thread. <p>By default this is set to {@code false}. @since 4.1
By default when {@link #getMessageHeaders()} is called, {@code "this"} {@code MessageHeaderAccessor} instance can no longer be used to modify the underlying message headers. However if {@link #setLeaveMutable()} is used, this method is necessary to indicate explicitly when the {@code MessageHeaders} instance should no longer be modified. @since 4.1
Whether the underlying headers can still be modified. @since 4.1
Mark the underlying message headers as modified. @param modified typically {@code true}, or {@code false} to reset the flag @since 4.1
Check whether the underlying message headers have been marked as modified. @return {@code true} if the flag has been set, {@code false} otherwise
A package private mechanism to enables the automatic addition of the {@link hunt.stomp.MessageHeaders#TIMESTAMP} header. <p>By default, this property is set to {@code false}. @see IdTimestampMessageHeaderInitializer
A package-private mechanism to configure the IdGenerator strategy to use. <p>By default this property is not set in which case the default IdGenerator in {@link hunt.stomp.MessageHeaders} is used. @see IdTimestampMessageHeaderInitializer
Return the underlying {@code MessageHeaders} instance. <p>Unless {@link #setLeaveMutable()} was set to {@code true}, after this call, the headers are immutable and this accessor can no longer modify them. <p>This method always returns the same {@code MessageHeaders} instance if invoked multiples times. To obtain a copy of the underlying headers, use {@link #toMessageHeaders()} or {@link #toMap()} instead. @since 4.1
Return a copy of the underlying header values as a {@link MessageHeaders} object. <p>This method can be invoked many times, with modifications in between where each new call returns a fresh copy of the current header values. @since 4.1
Return a copy of the underlying header values as a plain {@link Map} object. <p>This method can be invoked many times, with modifications in between where each new call returns a fresh copy of the current header values.
Retrieve the value for the header with the given name. @param headerName the name of the header @return the associated value, or {@code null} if none found
Set the value for the given header name. <p>If the provided value is {@code null}, the header will be removed.
Set the value for the given header name only if the header name is not already associated with a value.
Remove the value for the given header name.
Removes all headers provided via array of 'headerPatterns'. <p>As the name suggests, array may contain simple matching patterns for header names. Supported pattern styles are: "xxx*", "*xxx", "*xxx*" and "xxx*yyy".
Copy the name-value pairs from the provided Map. <p>This operation will overwrite any existing values. Use {@link #copyHeadersIfAbsent(Map)} to avoid overwriting values.
Copy the name-value pairs from the provided Map. <p>This operation will <em>not</em> overwrite any existing values.
Return a concise message for logging purposes. @param payload the payload that corresponds to the headers. @return the message
Return a more detailed message for logging purposes. @param payload the payload that corresponds to the headers. @return the message
Return the original {@code MessageHeaderAccessor} used to create the headers of the given {@code Message}, or {@code null} if that's not available or if its type does not match the required type. <p>This is for cases where the existence of an accessor is strongly expected (followed up with an assertion) or where an accessor will be created otherwise. @param message the message to get an accessor for @param requiredType the required accessor type (or {@code null} for any) @return an accessor instance of the specified type, or {@code null} if none @since 4.1
A variation of {@link #getAccessor(hunt.stomp.Message, Class)} with a {@code MessageHeaders} instance instead of a {@code Message}. <p>This is for cases when a full message may not have been created yet. @param messageHeaders the message headers to get an accessor for @param requiredType the required accessor type (or {@code null} for any) @return an accessor instance of the specified type, or {@code null} if none @since 4.1
Return a mutable {@code MessageHeaderAccessor} for the given message attempting to match the type of accessor used to create the message headers, or otherwise wrapping the message with a {@code MessageHeaderAccessor} instance. <p>This is for cases where a header needs to be updated in generic code while preserving the accessor type for downstream processing. @return an accessor of the required type (never {@code null}) @since 4.1
An extension of {@link MessageHeaderAccessor} that also stores and provides read/write access to message headers from an external source -- e.g. a Spring {@link Message} created to represent a STOMP message received from a STOMP client or message broker. Native message headers are kept in a {@code MultiStringsMap} under the key {@link #NATIVE_HEADERS}.
<p>This class is not intended for direct use but is rather expected to be used indirectly through protocol-specific sub-classes such as {@link hunt.stomp.simp.stomp.StompHeaderAccessor StompHeaderAccessor}. Such sub-classes may provide factory methods to translate message headers from an external messaging source (e.g. STOMP) to Spring {@link Message} headers and reversely to translate Spring {@link Message} headers to a message to send to an external source.
@author Rossen Stoyanchev @since 4.0