org.eclipse.jetty.util

## Class MultiMap<K>

- java.lang.Object
- - org.eclipse.jetty.util.MultiMap<K>

- Type Parameters:
    `K` - The key type of the map.
  All Implemented Interfaces:
    Serializable, ConcurrentMap<K,Object>, Map<K,Object>
  Direct Known Subclasses:
    UrlEncoded

      public class MultiMap<K>
      extends Object
      implements ConcurrentMap<K,Object>, Serializable

  A multi valued Map. This Map specializes HashMap and provides methods that operate on multi valued items.

  Implemented as a map of LazyList values

  See Also:
    `LazyList`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiMap()`
    `MultiMap(boolean concurrent)`
    `MultiMap(int capacity)`
    `MultiMap(Map<K,Object> map)`
    `MultiMap(MultiMap<K> map)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(K name, Object value)` Add value to multi valued entry.
    `void` | `addValues(K name, List<? extends Object> values)` Add values to multi valued entry.
    `void` | `addValues(K name, String[] values)` Add values to multi valued entry.
    `void` | `clear()`
    `boolean` | `containsKey(Object key)`
    `boolean` | `containsValue(Object value)`
    `Set<Map.Entry<K,Object>>` | `entrySet()`
    `boolean` | `equals(Object o)`
    `Object` | `get(Object name)`
    `String` | `getString(Object name)` Get value as String.
    `Object` | `getValue(Object name, int i)` Get a value from a multiple value.
    `List<Object>` | `getValues(Object name)` Get multiple values.
    `int` | `hashCode()`
    `boolean` | `isEmpty()`
    `Set<K>` | `keySet()`
    `Object` | `put(K name, Object value)` Put and entry into the map.
    `void` | `putAll(Map<? extends K,? extends Object> m)` Put all contents of map.
    `Object` | `putIfAbsent(K key, Object value)`
    `Object` | `putValues(K name, List<? extends Object> values)` Put multi valued entry.
    `Object` | `putValues(K name, String... values)` Put multi valued entry.
    `Object` | `remove(Object key)`
    `boolean` | `remove(Object key, Object value)`
    `boolean` | `removeValue(K name, Object value)` Remove value.
    `Object` | `replace(K key, Object value)`
    `boolean` | `replace(K key, Object oldValue, Object newValue)`
    `int` | `size()`
    `String` | `toString()`
    `Map<K,String[]>` | `toStringArrayMap()`
    `Collection<Object>` | `values()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### MultiMap

          public MultiMap()

    - #### MultiMap

          public MultiMap(Map<K,Object> map)

    - #### MultiMap

          public MultiMap(MultiMap<K> map)

    - #### MultiMap

          public MultiMap(int capacity)

    - #### MultiMap

          public MultiMap(boolean concurrent)

  - ### Method Detail

    - #### getValues

          public List<Object> getValues(Object name)

      Get multiple values. Single valued entries are converted to singleton lists.
      Parameters:
        `name` - The entry key.
      Returns:
        Unmodifieable List of values.

    - #### getValue

          public Object getValue(Object name,
                        int i)

      Get a value from a multiple value. If the value is not a multivalue, then index 0 retrieves the value or null.
      Parameters:
        `name` - The entry key.
        `i` - Index of element to get.
      Returns:
        Unmodifieable List of values.

    - #### getString

          public String getString(Object name)

      Get value as String. Single valued items are converted to a String with the toString() Object method. Multi valued entries are converted to a comma separated List. No quoting of commas within values is performed.
      Parameters:
        `name` - The entry key.
      Returns:
        String value.

    - #### get

          public Object get(Object name)

      Specified by:
        `get` in interface `Map<K,Object>`

    - #### put

          public Object put(K name,
                   Object value)

      Put and entry into the map.
      Specified by:
        `put` in interface `Map<K,Object>`
      Parameters:
        `name` - The entry key.
        `value` - The entry value.
      Returns:
        The previous value or null.

    - #### putValues

          public Object putValues(K name,
                         List<? extends Object> values)

      Put multi valued entry.
      Parameters:
        `name` - The entry key.
        `values` - The List of multiple values.
      Returns:
        The previous value or null.

    - #### putValues

          public Object putValues(K name,
                         String... values)

      Put multi valued entry.
      Parameters:
        `name` - The entry key.
        `values` - The String array of multiple values.
      Returns:
        The previous value or null.

    - #### add

          public void add(K name,
                 Object value)

      Add value to multi valued entry. If the entry is single valued, it is converted to the first value of a multi valued entry.
      Parameters:
        `name` - The entry key.
        `value` - The entry value.

    - #### addValues

          public void addValues(K name,
                       List<? extends Object> values)

      Add values to multi valued entry. If the entry is single valued, it is converted to the first value of a multi valued entry.
      Parameters:
        `name` - The entry key.
        `values` - The List of multiple values.

    - #### addValues

          public void addValues(K name,
                       String[] values)

      Add values to multi valued entry. If the entry is single valued, it is converted to the first value of a multi valued entry.
      Parameters:
        `name` - The entry key.
        `values` - The String array of multiple values.

    - #### removeValue

          public boolean removeValue(K name,
                            Object value)

      Remove value.
      Parameters:
        `name` - The entry key.
        `value` - The entry value.
      Returns:
        true if it was removed.

    - #### putAll

          public void putAll(Map<? extends K,? extends Object> m)

      Put all contents of map.
      Specified by:
        `putAll` in interface `Map<K,Object>`
      Parameters:
        `m` - Map

    - #### toStringArrayMap

          public Map<K,String[]> toStringArrayMap()

      Returns:
        Map of String arrays

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `Map<K,Object>`

    - #### containsKey

          public boolean containsKey(Object key)

      Specified by:
        `containsKey` in interface `Map<K,Object>`

    - #### containsValue

          public boolean containsValue(Object value)

      Specified by:
        `containsValue` in interface `Map<K,Object>`

    - #### entrySet

          public Set<Map.Entry<K,Object>> entrySet()

      Specified by:
        `entrySet` in interface `Map<K,Object>`

    - #### equals

          public boolean equals(Object o)

      Specified by:
        `equals` in interface `Map<K,Object>`
      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `Map<K,Object>`
      Overrides:
        `hashCode` in class `Object`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Map<K,Object>`

    - #### keySet

          public Set<K> keySet()

      Specified by:
        `keySet` in interface `Map<K,Object>`

    - #### remove

          public Object remove(Object key)

      Specified by:
        `remove` in interface `Map<K,Object>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `Map<K,Object>`

    - #### values

          public Collection<Object> values()

      Specified by:
        `values` in interface `Map<K,Object>`

    - #### putIfAbsent

          public Object putIfAbsent(K key,
                           Object value)

      Specified by:
        `putIfAbsent` in interface `ConcurrentMap<K,Object>`

    - #### remove

          public boolean remove(Object key,
                       Object value)

      Specified by:
        `remove` in interface `ConcurrentMap<K,Object>`

    - #### replace

          public boolean replace(K key,
                        Object oldValue,
                        Object newValue)

      Specified by:
        `replace` in interface `ConcurrentMap<K,Object>`

    - #### replace

          public Object replace(K key,
                       Object value)

      Specified by:
        `replace` in interface `ConcurrentMap<K,Object>`

Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.