org.springframework.util
Class LinkedMultiValueMap<K,V>

java.lang.Object
  extended by org.springframework.util.LinkedMultiValueMap<K,V>
All Implemented Interfaces:
java.util.Map<K,java.util.List<V>>, MultiValueMap<K,V>

public class LinkedMultiValueMap<K,V>
extends java.lang.Object
implements MultiValueMap<K,V>

Simple implementation of MultiValueMap that wraps a plain Map (by default a LinkedHashMap, storing multiple values in a LinkedList.

This Map implementation is generally not thread-safe. It is primarily designed for data structures exposed from request objects, for use in a single thread only.

Since:
3.0
Author:
Arjen Poutsma, Juergen Hoeller

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
LinkedMultiValueMap()
          Create a new SimpleMultiValueMap that wraps a newly created LinkedHashMap.
LinkedMultiValueMap(int initialCapacity)
          Create a new SimpleMultiValueMap that wraps a newly created LinkedHashMap with the given initial capacity.
LinkedMultiValueMap(java.util.Map<K,java.util.List<V>> targetMap)
          Create a new SimpleMultiValueMap that wraps the given target Map.
 
Method Summary
 void add(K key, V value)
          Add the given single value to the current list of values for the given key.
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<K,java.util.List<V>>> entrySet()
           
 boolean equals(java.lang.Object obj)
           
 java.util.List<V> get(java.lang.Object key)
           
 V getFirst(K key)
          Return the first value for the given key.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set<K> keySet()
           
 java.util.List<V> put(K key, java.util.List<V> value)
           
 void putAll(java.util.Map<? extends K,? extends java.util.List<V>> m)
           
 java.util.List<V> remove(java.lang.Object key)
           
 void set(K key, V value)
          Set the given single value under the given key.
 int size()
           
 java.lang.String toString()
           
 java.util.Collection<java.util.List<V>> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkedMultiValueMap

public LinkedMultiValueMap()
Create a new SimpleMultiValueMap that wraps a newly created LinkedHashMap.


LinkedMultiValueMap

public LinkedMultiValueMap(int initialCapacity)
Create a new SimpleMultiValueMap that wraps a newly created LinkedHashMap with the given initial capacity.

Parameters:
initialCapacity - the initial capacity

LinkedMultiValueMap

public LinkedMultiValueMap(java.util.Map<K,java.util.List<V>> targetMap)
Create a new SimpleMultiValueMap that wraps the given target Map.

Note: The given Map will be used as active underlying Map. Any changes in the underlying map will be reflected in the MultiValueMap object, and vice versa.

Parameters:
targetMap - the target Map to wrap
Method Detail

add

public void add(K key,
                V value)
Description copied from interface: MultiValueMap
Add the given single value to the current list of values for the given key.

Specified by:
add in interface MultiValueMap<K,V>
Parameters:
key - the key
value - the value to be added

getFirst

public V getFirst(K key)
Description copied from interface: MultiValueMap
Return the first value for the given key.

Specified by:
getFirst in interface MultiValueMap<K,V>
Parameters:
key - the key
Returns:
the first value for the specified key, or null

set

public void set(K key,
                V value)
Description copied from interface: MultiValueMap
Set the given single value under the given key.

Specified by:
set in interface MultiValueMap<K,V>
Parameters:
key - the key
value - the value to set

size

public int size()
Specified by:
size in interface java.util.Map<K,java.util.List<V>>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,java.util.List<V>>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<K,java.util.List<V>>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<K,java.util.List<V>>

get

public java.util.List<V> get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,java.util.List<V>>

put

public java.util.List<V> put(K key,
                             java.util.List<V> value)
Specified by:
put in interface java.util.Map<K,java.util.List<V>>

remove

public java.util.List<V> remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<K,java.util.List<V>>

putAll

public void putAll(java.util.Map<? extends K,? extends java.util.List<V>> m)
Specified by:
putAll in interface java.util.Map<K,java.util.List<V>>

clear

public void clear()
Specified by:
clear in interface java.util.Map<K,java.util.List<V>>

keySet

public java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,java.util.List<V>>

values

public java.util.Collection<java.util.List<V>> values()
Specified by:
values in interface java.util.Map<K,java.util.List<V>>

entrySet

public java.util.Set<java.util.Map.Entry<K,java.util.List<V>>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,java.util.List<V>>

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Map<K,java.util.List<V>>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<K,java.util.List<V>>
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object