Class HttpMultiMap<V>

java.lang.Object
jodd.http.HttpMultiMap<V>
All Implemented Interfaces:
Iterable<Map.Entry<String,V>>
Direct Known Subclasses:
HeadersMultiMap

public class HttpMultiMap<V> extends Object implements Iterable<Map.Entry<String,V>>
General purpose HTTP multi-map. It's optimized Linked-HashMap, designed for small number of items and String non-null keys. It stores keys in case-sensitive way, but, by default, you can read them in case-insensitive way.
  • Field Details

  • Constructor Details

    • HttpMultiMap

      protected HttpMultiMap(boolean caseSensitive)
  • Method Details

    • newCaseInsensitiveMap

      public static <T> HttpMultiMap<T> newCaseInsensitiveMap()
      Creates new case-insensitive multimap.
    • newCaseSensitiveMap

      public static <T> HttpMultiMap<T> newCaseSensitiveMap()
      Creates new case-insensitive map.
    • hash

      private int hash(String name)
      Calculates hash value of the input string.
    • index

      private static int index(int hash)
      Calculates bucket index from the hash.
    • eq

      private boolean eq(String name1, String name2)
      Returns true if two names are the same.
    • size

      public int size()
      Returns the number of keys. This is not the number of all elements. Not optimized.
    • clear

      public HttpMultiMap<V> clear()
      Clears the map.
    • contains

      public boolean contains(String name)
      Returns true if name exist.
    • isEmpty

      public boolean isEmpty()
      Returns true if map is empty.
    • toString

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

      private HttpMultiMap<V> _set(Iterable<Map.Entry<String,V>> map)
    • setAll

      public HttpMultiMap<V> setAll(HttpMultiMap<V> multiMap)
    • setAll

      public HttpMultiMap<V> setAll(Map<String,V> map)
    • set

      public HttpMultiMap<V> set(String name, V value)
    • setAll

      public HttpMultiMap<V> setAll(String name, Iterable<V> values)
    • add

      public HttpMultiMap<V> add(String name, V value)
    • addAll

      public HttpMultiMap<V> addAll(String name, Iterable<V> values)
    • addAll

      public HttpMultiMap<V> addAll(HttpMultiMap<V> map)
    • addAll

      public HttpMultiMap<V> addAll(Map<String,V> map)
    • _add

      private void _add(int hash, int index, String name, V value)
    • remove

      public HttpMultiMap<V> remove(String name)
    • _remove

      private void _remove(int hash, int index, String name)
    • get

      public V get(String name)
      Returns the first value from the map associated with the name. Returns null if name does not exist or if associated value is null.
    • getEntry

      public Map.Entry<String,V> getEntry(String name)
      Returns first entry for given name. Returns null if entry does not exist.
    • getAll

      public List<V> getAll(String name)
      Returns all values associated with the name.
    • iterator

      public Iterator<Map.Entry<String,V>> iterator()
      Returns iterator of all entries.
      Specified by:
      iterator in interface Iterable<V>
    • names

      public Set<String> names()
    • entries

      public List<Map.Entry<String,V>> entries()
      Returns all the entries of this map. Case sensitivity does not influence the returned list, it always contains all of the values.