Package org.forgerock.http.protocol
Class Headers
- java.lang.Object
-
- org.forgerock.http.protocol.Headers
-
-
Constructor Summary
Constructors Constructor Description Headers()
Constructs aHeaders
object that is case-insensitive for header names.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String key, Object value)
A script compatible add method that will accept aHeader
,String
,Collection<String>
andString[]
value.void
add(Header header)
An add method to add a particularHeader
instance.void
addAll(Map<? extends String,? extends Object> map)
A script compatible addAll method that will accept aHeader
,String
,Collection<String>
andString[]
value.Map<String,Header>
asMapOfHeaders()
TheHeaders
class extendsMap<String, Object>
to support flexible parameters in scripting.void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Map<String,List<String>>
copyAsMultiMapOfStrings()
Returns a copy of these headers as a multi-valued map of strings.Set<Map.Entry<String,Object>>
entrySet()
<H extends Header>
Hget(Class<H> headerType)
Returns the specifiedHeader
or {code null} if the header is not included in the message.Header
get(Object key)
Rich-type friendly get method.List<String>
getAll(String key)
Gets all the values of the header, or an empty list if the header doesn't exist.String
getFirst(Class<? extends Header> key)
Gets the first value of the header, or null if the header does not exist.String
getFirst(String key)
Gets the first value of the header, or null if the header does not exist.boolean
isEmpty()
Set<String>
keySet()
Header
put(String key, Object value)
A script compatible put method that will accept aHeader
,String
,Collection<String>
andString[]
value.Header
put(Header header)
A put method to add a particularHeader
instance.void
putAll(Map<? extends String,? extends Object> m)
A script compatible putAll method that will acceptHeader
,String
,Collection<String>
andString[]
values.Header
remove(Object key)
Rich-type friendly remove method.int
size()
Collection<Object>
values()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
getFirst
public String getFirst(String key)
Gets the first value of the header, or null if the header does not exist.- Parameters:
key
- The name of the header.- Returns:
- The first header value.
-
getFirst
public String getFirst(Class<? extends Header> key)
Gets the first value of the header, or null if the header does not exist.- Parameters:
key
- The name of the header.- Returns:
- The first header value.
-
getAll
public List<String> getAll(String key)
Gets all the values of the header, or an empty list if the header doesn't exist.- Parameters:
key
- The name of the header.- Returns:
- The values of the header.
-
get
public <H extends Header> H get(Class<H> headerType) throws MalformedHeaderException
Returns the specifiedHeader
or {code null} if the header is not included in the message.- Type Parameters:
H
- The type of header.- Parameters:
headerType
- The type of header.- Returns:
- The header instance, or null if none exists.
- Throws:
MalformedHeaderException
- When the header was not well formed, and so could not be parsed as its richly-typed class.
-
putAll
public void putAll(Map<? extends String,? extends Object> m)
A script compatible putAll method that will acceptHeader
,String
,Collection<String>
andString[]
values.
-
put
public Header put(String key, Object value)
A script compatible put method that will accept aHeader
,String
,Collection<String>
andString[]
value.
-
remove
public Header remove(Object key)
Rich-type friendly remove method. Removes theHeader
object for the given header name.
-
put
public Header put(Header header)
A put method to add a particularHeader
instance. Will overwrite any existing value for this header name.- Parameters:
header
- The header instance.- Returns:
- The previous
Header
value for the header with the same name, or null.
-
add
public void add(Header header)
An add method to add a particularHeader
instance. Existing values for the header will be added to.- Parameters:
header
- The header instance.
-
add
public void add(String key, Object value)
A script compatible add method that will accept aHeader
,String
,Collection<String>
andString[]
value. Existing values for the header will be added to.- Parameters:
key
- The name of the header.value
- AHeader
,String
,Collection<String>
orString[]
.
-
addAll
public void addAll(Map<? extends String,? extends Object> map)
A script compatible addAll method that will accept aHeader
,String
,Collection<String>
andString[]
value. Existing values for the headers will be added to.- Parameters:
map
- A map of header names to values.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,Object>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,Object>
-
asMapOfHeaders
public Map<String,Header> asMapOfHeaders()
TheHeaders
class extendsMap<String, Object>
to support flexible parameters in scripting. This method allows access to the underlyingMap<String, Header>
.- Returns:
- The map of header names to
Header
objects.
-
copyAsMultiMapOfStrings
public Map<String,List<String>> copyAsMultiMapOfStrings()
Returns a copy of these headers as a multi-valued map of strings. Changes to the returned map will not be reflected in these headers, nor will changes in these headers be reflected in the returned map.- Returns:
- a copy of these headers as a multi-valued map of strings.
-
-