|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.seas.iis.util.MultiValueMap
public class MultiValueMap
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.
Constructor Summary | |
---|---|
MultiValueMap()
Class constructor |
Method Summary | |
---|---|
static boolean |
addValue(java.util.Map map,
java.lang.Object key,
java.lang.Object val)
Adds a value to a collection of values under a specific key. |
static boolean |
addValues(java.util.Map map,
java.lang.Object key,
java.util.Collection vals)
Adds a whole collection of values to a collection of values under a specific key. |
static boolean |
containsValue(java.util.Map map,
java.lang.Object key,
java.lang.Object val)
Returns true if the list of values for a key contains the value; false otherwise |
static int |
getNumValuesFor(java.util.Map map,
java.lang.Object key)
Returns the number of values associated with a key |
static java.util.Vector |
getValues(java.util.Map map)
Returns a collection of all values contained in the map |
static boolean |
isEmpty(java.util.Map map)
Test if any keys in the map have values |
static boolean |
removeValue(java.util.Map map,
java.lang.Object key,
java.lang.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(java.util.Map map,
java.lang.Object key,
java.lang.Object oldVal,
java.lang.Object newVal)
Replaces one value in the list of values with another one. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultiValueMap()
Method Detail |
---|
public static boolean addValue(java.util.Map map, java.lang.Object key, java.lang.Object val)
map
- object holding the key-val(s) bindingkey
- identifier for a specific bindingval
- value to be referenced by key
val
already present,
False otherwisepublic static boolean addValues(java.util.Map map, java.lang.Object key, java.util.Collection vals)
map
- object holding the key-val(s) bindingkey
- identifier for a specific bindingvals
- a collection of values to be referenced by key
vals
already present,
False otherwisepublic static boolean containsValue(java.util.Map map, java.lang.Object key, java.lang.Object val)
map
- object holding the key-val(s) bindingkey
- identifier for a specific bindingval
- value to be referenced by key
public static boolean removeValue(java.util.Map map, java.lang.Object key, java.lang.Object val)
map
- object holding the key-val(s) bindingkey
- identifier for a specific bindingval
- value to be referenced by key
public static boolean replaceValue(java.util.Map map, java.lang.Object key, java.lang.Object oldVal, java.lang.Object newVal)
map
- object holding the key-val(s) bindingkey
- identifier for a specific bindingoldVal
- previous value to removenewVal
- value to insert
public static java.util.Vector getValues(java.util.Map map)
map
- input
public static boolean isEmpty(java.util.Map map)
map
-
public static int getNumValuesFor(java.util.Map map, java.lang.Object key)
map
- a particular map to be usedkey
- the key, whose values we want to count
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |