public class ConcurrentHashMapHeaders extends java.lang.Object implements Headers
Headers using ConcurrentHashMap as the backing data structure. Concurrent
writes are supported. Reads return immutable data types.
NOTE: If using this implementation of Headers, an agent of the same version should be used. Failure to do so
may cause unexpected results at runtime, since the agent's definition may be different than provided by the newrelic-api.
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add a header with the given name and value.
|
static ConcurrentHashMapHeaders |
build(HeaderType headerType)
Build an empty instance with the given
HeaderType. |
static ConcurrentHashMapHeaders |
buildFromFlatMap(HeaderType headerType,
java.util.Map<java.lang.String,java.lang.String> map)
Build an instance with the given
HeaderType and call setHeader(String, String) with each entry
in the map. |
static ConcurrentHashMapHeaders |
buildFromMap(HeaderType headerType,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> map)
Build an instance with the given
HeaderType and call addHeader(String, String) with each entry
in the map. |
boolean |
containsHeader(java.lang.String name)
Return a boolean indicating whether the named header has already been set.
|
java.lang.String |
getHeader(java.lang.String name)
Returns the value of the first specified message header as a
String. |
java.util.Collection<java.lang.String> |
getHeaderNames()
Get the names of the headers.
|
java.util.Collection<java.lang.String> |
getHeaders(java.lang.String name)
Return all the values of the specified message header as a
List of String objects. |
HeaderType |
getHeaderType()
Return the type of header key syntax used for this.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getMapCopy()
Obtain a copy of the backing map.
|
void |
removeHeader(java.lang.String name)
Remove any headers with the name.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Set a header with the given name and value.
|
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMapCopy()
headers map.public void removeHeader(java.lang.String name)
name - The name of the header.public HeaderType getHeaderType()
HeadersgetHeaderType in interface HeadersgetHeaderType in interface InboundHeadersgetHeaderType in interface OutboundHeadersenum specifying the type of headers present.public java.lang.String getHeader(java.lang.String name)
HeadersString. If the message does not include a header
with the specified input name, then this method returns null.getHeader in interface HeadersgetHeader in interface InboundHeadersname - The name of the desired message header.String containing the value of the requested header, or null if the message header is not
present.public java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
HeadersList of String objects. If the message
does not include any headers of the specified name, this method returns an empty list.
Changes to the returned collection must not affect the Headers instance.
getHeaders in interface Headersname - The name of the desired message header.List containing the values of the requested header, or an empty list of the message header is not
present.public void setHeader(java.lang.String name,
java.lang.String value)
HeadersHeaders.containsHeader(String) can be used to test for the presence of a header before setting its value.setHeader in interface HeaderssetHeader in interface OutboundHeadersname - The name of the header.value - The value of the header.public void addHeader(java.lang.String name,
java.lang.String value)
Headerspublic java.util.Collection<java.lang.String> getHeaderNames()
HeadersChanges to the returned collection must not affect the Headers instance.
getHeaderNames in interface HeadersCollection of the names of present headers.public boolean containsHeader(java.lang.String name)
HeaderscontainsHeader in interface Headersname - The name of the header.true if the header has already been set, false otherwise.public static ConcurrentHashMapHeaders build(HeaderType headerType)
HeaderType.
NOTE: If using this implementation of Headers, an agent of the same version should be used. Failure to do so
may cause unexpected results at runtime, since the agent's definition may be different than provided by the newrelic-api.
headerType - The type of headers the instance represents.public static ConcurrentHashMapHeaders buildFromFlatMap(HeaderType headerType, java.util.Map<java.lang.String,java.lang.String> map)
HeaderType and call setHeader(String, String) with each entry
in the map.
NOTE: If using this implementation of Headers, an agent of the same version should be used. Failure to do so
may cause unexpected results at runtime, since the agent's definition may be different than provided by the newrelic-api.
headerType - The type of headers the instance represents.map - A map of header names and values used to populate the instance.public static ConcurrentHashMapHeaders buildFromMap(HeaderType headerType, java.util.Map<java.lang.String,java.util.List<java.lang.String>> map)
HeaderType and call addHeader(String, String) with each entry
in the map.
NOTE: If using this implementation of Headers, an agent of the same version should be used. Failure to do so
may cause unexpected results at runtime, since the agent's definition may be different than provided by the newrelic-api.
headerType - The type of headers the instance represents.map - A map of header names and potentially several values each used to populate the instance.