Package com.yahoo.jdisc
Class HeaderFields
java.lang.Object
com.yahoo.jdisc.HeaderFields
This is an encapsulation of the header fields that belong to either a
Request
or a Response
. It is
a multimap from String to String, with some additional methods for convenience. The keys of this map are compared by
ignoring their case, so that get("foo")
returns the same entry as get("FOO")
.- Author:
- Simon Thoresen Hult
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given value to the entry of the specified key.void
Adds the given values to the entry of the specified key.void
Adds all the entries of the given map to this.void
clear()
boolean
Convenience method for checking whether or not a named header contains a specific value.boolean
containsIgnoreCase
(String key, String value) Convenience method for checking whether or not a named header contains a specific value, regardless of case.boolean
containsKey
(Object key) boolean
containsValue
(Object value) entries()
Returns an unmodifiable list of all key-value pairs of this.entrySet()
boolean
Convenience method for retrieving the first value of a named header field.int
hashCode()
boolean
isEmpty()
boolean
Convenience method for checking whether a named header field is true.keySet()
Convenience method to callput(String, List)
with a singleton list that contains the specified value.void
boolean
Removes the given value from the entry of the specified key.int
size()
toString()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
HeaderFields
public HeaderFields()
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
List<String>>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
List<String>>
-
contains
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
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:
-
add
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
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
Adds all the entries of the given map to this. This is the same as callingadd(String, List)
for each entry invalues
.- Parameters:
values
- the values to be added to this.
-
put
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
.
-
put
-
putAll
-
remove
-
remove
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.
-
clear
public void clear() -
get
-
getFirst
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
Convenience method for checking whether 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.
-
keySet
-
values
-
entrySet
-
toString
-
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
-
equals
-
hashCode
public int hashCode()
-