Package org.forgerock.http.protocol
Class Headers
- java.lang.Object
 - 
- org.forgerock.http.protocol.Headers
 
 
- 
- 
Constructor Summary
Constructors Constructor Description Headers()Constructs aHeadersobject that is case-insensitive for header names. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String key, Object value)A script compatible add method that will accept aHeader,String,Collection<String>andString[]value.voidadd(Header header)An add method to add a particularHeaderinstance.voidaddAll(Map<? extends String,? extends Object> map)A script compatible addAll method that will accept aHeader,String,Collection<String>andString[]value.Map<String,Header>asMapOfHeaders()TheHeadersclass extendsMap<String, Object>to support flexible parameters in scripting.voidclear()booleancontainsKey(Object key)booleancontainsValue(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 specifiedHeaderor {code null} if the header is not included in the message.Headerget(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.StringgetFirst(Class<? extends Header> key)Gets the first value of the header, or null if the header does not exist.StringgetFirst(String key)Gets the first value of the header, or null if the header does not exist.booleanisEmpty()Set<String>keySet()Headerput(String key, Object value)A script compatible put method that will accept aHeader,String,Collection<String>andString[]value.Headerput(Header header)A put method to add a particularHeaderinstance.voidputAll(Map<? extends String,? extends Object> m)A script compatible putAll method that will acceptHeader,String,Collection<String>andString[]values.Headerremove(Object key)Rich-type friendly remove method.intsize()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 specifiedHeaderor {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 theHeaderobject for the given header name. 
- 
put
public Header put(Header header)
A put method to add a particularHeaderinstance. Will overwrite any existing value for this header name.- Parameters:
 header- The header instance.- Returns:
 - The previous 
Headervalue for the header with the same name, or null. 
 
- 
add
public void add(Header header)
An add method to add a particularHeaderinstance. 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:
 containsKeyin interfaceMap<String,Object>
 
- 
containsValue
public boolean containsValue(Object value)
- Specified by:
 containsValuein interfaceMap<String,Object>
 
- 
asMapOfHeaders
public Map<String,Header> asMapOfHeaders()
TheHeadersclass 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 
Headerobjects. 
 
- 
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.
 
 
 - 
 
 -