util
Class MultiValueMap
java.lang.Object
|
+--util.MultiValueMap
- All Implemented Interfaces:
- Serializable
- public class MultiValueMap
- extends Object
- implements Serializable
This class contains a bunch of static methods that make it easier
to deal with Maps (e.g. Hashtables, PersistentMaps) that contain
more than one value per key.
- See Also:
Serializable
, Serialized Form
Method Summary |
static boolean |
addValue(Map map,
Object key,
Object val)
Adds a value to a collection of values under a specific key. |
static boolean |
addValues(Map map,
Object key,
Collection vals)
Adds a whole collection of values to a collection of values
under a specific key. |
static boolean |
containsValue(Map map,
Object key,
Object val)
Returns true if the list of values for a key contains the
value; false otherwise |
static boolean |
removeValue(Map map,
Object key,
Object val)
Remove the value from the list of values associated with a
given key (there can be many values under the same key); if
this is the last value under the key, the key will be removed
as well. |
static boolean |
replaceValue(Map map,
Object key,
Object oldVal,
Object newVal)
Replaces one value in the list of values with another
one. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiValueMap
public MultiValueMap()
addValue
public static boolean addValue(Map map,
Object key,
Object val)
- Adds a value to a collection of values under a specific key. If
there already is a value under the key and it is not a
collection, this method does nothing and returns false;
otherwise it returns true. (if the value is already there, the
new one does not get added)
addValues
public static boolean addValues(Map map,
Object key,
Collection vals)
- Adds a whole collection of values to a collection of values
under a specific key. If there already is a value under the key
and it is not a collection, this method does nothing and
returns false; otherwise it returns true. (if the any of the
values is already there, the new one does not get added)
containsValue
public static boolean containsValue(Map map,
Object key,
Object val)
- Returns true if the list of values for a key contains the
value; false otherwise
removeValue
public static boolean removeValue(Map map,
Object key,
Object val)
- Remove the value from the list of values associated with a
given key (there can be many values under the same key); if
this is the last value under the key, the key will be removed
as well.
- Returns:
- true if there was something there, false otherwise
replaceValue
public static boolean replaceValue(Map map,
Object key,
Object oldVal,
Object newVal)
- Replaces one value in the list of values with another
one. Returns true if the old value was there and the new one
was added successfuly.