Class Headers
- java.lang.Object
-
- com.yahoo.application.container.handler.Headers
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,java.util.List<java.lang.String>>
@NotThreadSafe @Beta public class Headers extends java.lang.Object implements java.util.Map<java.lang.String,java.util.List<java.lang.String>>
A multi-map for Request and Response header fields.
-
-
Constructor Summary
Constructors Constructor Description Headers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String key, java.lang.String value)
Adds the given value to the entry of the specified key.void
add(java.lang.String key, java.util.List<java.lang.String> values)
Adds the given values to the entry of the specified key.void
addAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> values)
Adds all the entries of the given map to this.void
clear()
boolean
contains(java.lang.String key, java.lang.String value)
Convenience method for checking whether or not a named header contains a specific value.boolean
containsIgnoreCase(java.lang.String key, java.lang.String value)
Convenience method for checking whether or not a named header contains a specific value, regardless of case.boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>>
entries()
Returns an unmodifiable list of all key-value pairs of this.java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>>
entrySet()
boolean
equals(java.lang.Object obj)
java.util.List<java.lang.String>
get(java.lang.Object key)
java.lang.String
getFirst(java.lang.String key)
Convenience method for retrieving the first value of a named header field.int
hashCode()
boolean
isEmpty()
boolean
isTrue(java.lang.String key)
Convenience method for checking whether or not a named header field is true.java.util.Set<java.lang.String>
keySet()
java.util.List<java.lang.String>
put(java.lang.String key, java.lang.String value)
Convenience method to callput(String, List)
with a singleton list that contains the specified value.java.util.List<java.lang.String>
put(java.lang.String key, java.util.List<java.lang.String> value)
void
putAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> m)
java.util.List<java.lang.String>
remove(java.lang.Object key)
boolean
remove(java.lang.String key, java.lang.String value)
Removes the given value from the entry of the specified key.int
size()
java.lang.String
toString()
java.util.Collection<java.util.List<java.lang.String>>
values()
-
-
-
Method Detail
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
get
public java.util.List<java.lang.String> get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
put
public java.util.List<java.lang.String> put(java.lang.String key, java.util.List<java.lang.String> value)
- Specified by:
put
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
remove
public java.util.List<java.lang.String> remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> m)
- Specified by:
putAll
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
keySet
public java.util.Set<java.lang.String> keySet()
- Specified by:
keySet
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
values
public java.util.Collection<java.util.List<java.lang.String>> values()
- Specified by:
values
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Map<java.lang.String,java.util.List<java.lang.String>>
- Overrides:
hashCode
in classjava.lang.Object
-
contains
public boolean contains(java.lang.String key, java.lang.String value)
Convenience method for checking whether or not a named header contains a specific value. If the named header is not set, or if the given value is not contained within that header's value list, this method returns false.
NOTE: This method is case-SENSITIVE.
- Parameters:
key
- The key whose values to search in.value
- The values to search for.- Returns:
- True if the given value was found in the named header.
- See Also:
containsIgnoreCase(java.lang.String, java.lang.String)
-
containsIgnoreCase
public boolean containsIgnoreCase(java.lang.String key, java.lang.String value)
Convenience method for checking whether or not a named header contains a specific value, regardless of case. If the named header is not set, or if the given value is not contained within that header's value list, this method returns false.
NOTE: This method is case-INSENSITIVE.
- Parameters:
key
- The key whose values to search in.value
- The values to search for, ignoring case.- Returns:
- True if the given value was found in the named header.
- See Also:
contains(java.lang.String, java.lang.String)
-
add
public void add(java.lang.String key, java.lang.String value)
Adds the given value to the entry of the specified key. If no entry exists for the given key, a new one is created containing only the given value.
- Parameters:
key
- The key with which the specified value is to be associated.value
- The value to be added to the list associated with the specified key.
-
add
public void add(java.lang.String key, java.util.List<java.lang.String> values)
Adds the given values to the entry of the specified key. If no entry exists for the given key, a new one is created containing only the given values.
- Parameters:
key
- The key with which the specified value is to be associated.values
- The values to be added to the list associated with the specified key.
-
addAll
public void addAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> values)
Adds all the entries of the given map to this. This is the same as calling
add(String, List)
for each entry invalues
.- Parameters:
values
- The values to be added to this.
-
put
public java.util.List<java.lang.String> put(java.lang.String key, java.lang.String value)
Convenience method to call
put(String, List)
with a singleton list that contains the specified value.- Parameters:
key
- The key of the entry to put.value
- The value to put.- Returns:
- The previous value associated with
key
, ornull
if there was no mapping forkey
.
-
remove
public boolean remove(java.lang.String key, java.lang.String value)
Removes the given value from the entry of the specified key.
- Parameters:
key
- The key of the entry to remove from.value
- The value to remove from the entry.- Returns:
- True if the value was removed.
-
getFirst
public java.lang.String getFirst(java.lang.String key)
Convenience method for retrieving the first value of a named header field. If the header is not set, or if the value list is empty, this method returns null.
- Parameters:
key
- The key whose first value to return.- Returns:
- The first value of the named header, or null.
-
isTrue
public boolean isTrue(java.lang.String key)
Convenience method for checking whether or not a named header field is true. To satisfy this, the header field needs to have at least 1 entry, and Boolean.valueOf() of all its values must parse as true.
- Parameters:
key
- The key whose values to parse as a boolean.- Returns:
- The boolean value of the named header.
-
entries
public java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> entries()
Returns an unmodifiable list of all key-value pairs of this. This provides a flattened view on the content of this map.
- Returns:
- The collection of entries.
-
-