java.lang.Object
com.yahoo.application.container.handler.Headers
All Implemented Interfaces:
Map<String,List<String>>

public class Headers extends Object implements Map<String,List<String>>
A multi-map for Request and Response header fields.
Author:
Einar M R Rosenvinge, Simon Thoresen Hult
See Also:
  • Constructor Details

    • Headers

      public Headers()
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Map<String,List<String>>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,List<String>>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,List<String>>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,List<String>>
    • get

      public List<String> get(Object key)
      Specified by:
      get in interface Map<String,List<String>>
    • put

      public List<String> put(String key, List<String> value)
      Specified by:
      put in interface Map<String,List<String>>
    • remove

      public List<String> remove(Object key)
      Specified by:
      remove in interface Map<String,List<String>>
    • putAll

      public void putAll(Map<? extends String,? extends List<String>> m)
      Specified by:
      putAll in interface Map<String,List<String>>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,List<String>>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,List<String>>
    • values

      public Collection<List<String>> values()
      Specified by:
      values in interface Map<String,List<String>>
    • entrySet

      public Set<Map.Entry<String,List<String>>> entrySet()
      Specified by:
      entrySet in interface Map<String,List<String>>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Map<String,List<String>>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,List<String>>
      Overrides:
      hashCode in class Object
    • contains

      public boolean contains(String key, 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

      public boolean containsIgnoreCase(String key, 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:
    • add

      public void add(String key, 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(String key, List<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(Map<? extends String,? extends List<String>> values)

      Adds all the entries of the given map to this. This is the same as calling add(String, List) for each entry in values.

      Parameters:
      values - The values to be added to this.
    • put

      public List<String> put(String key, 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, or null if there was no mapping for key.
    • remove

      public boolean remove(String key, 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 String getFirst(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(String key)
      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
    • entries

      public List<Map.Entry<String,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