|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface MultiMap<K,V>
Defines a map that holds a collection of values against each key.
AMultiMap is a Map with slightly different semantics.
Putting a value into the map will add the value to a Collection at that key.
Getting a value will return a Collection, holding all the values put to that key.
For example:
MultiMap mhm = new MultiHashMap(); mhm.put(key, "A"); mhm.put(key, "B"); mhm.put(key, "C"); Collection coll = (Collection) mhm.get(key);
coll will be a collection containing "A", "B", "C".
NOTE: Additional methods were added to this interface in Commons Collections 3.1.
These were added solely for documentation purposes and do not change the interface
as they were defined in the superinterface Map anyway.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Method Summary | |
|---|---|
boolean |
containsValue(Object value)
Checks whether the map contains the value specified. |
Object |
get(Object key)
Gets the collection of values associated with the specified key. |
V |
put(Object key,
Object value)
Adds the value to the collection associated with the specified key. |
V |
remove(K key,
V item)
Removes a specific value from map. |
Object |
remove(Object key)
Removes all values associated with the specified key. |
int |
size()
Gets the number of keys in this map. |
Collection<V> |
values()
Gets a collection containing all the values in the map. |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, entrySet, equals, hashCode, isEmpty, keySet, putAll |
| Method Detail |
|---|
V remove(K key,
V item)
null from a subsequant get(Object), however
they may choose to return an empty collection.
key - the key to remove fromitem - the item to remove
UnsupportedOperationException - if the map is unmodifiable
ClassCastException - if the key or value is of an invalid type
NullPointerException - if the key or value is null and null is invalidint size()
size in interface MapObject get(Object key)
Collection. Implementations
are free to declare that they return Collection subclasses
such as List or Set.
Implementations typically return null if no values have
been mapped to the key, however the implementation may choose to
return an empty collection.
Implementations may choose to return a clone of the internal collection.
get in interface Mapkey - the key to retrieve
Collection of values, implementations should
return null for no mapping, but may return an empty collection
ClassCastException - if the key is of an invalid type
NullPointerException - if the key is null and null keys are invalidboolean containsValue(Object value)
containsValue in interface Mapvalue - the value to search for
ClassCastException - if the value is of an invalid type
NullPointerException - if the value is null and null value are invalid
V put(Object key,
Object value)
Map the previous value is not replaced.
Instead the new value is added to the collection stored against the key.
The collection may be a List, Set or other
collection dependent on implementation.
put in interface Mapkey - the key to store againstvalue - the value to add to the collection at the key
UnsupportedOperationException - if the map is unmodifiable
ClassCastException - if the key or value is of an invalid type
NullPointerException - if the key or value is null and null is invalid
IllegalArgumentException - if the key or value is invalidObject remove(Object key)
null from a subsequant
get(Object), however they may choose to return an empty collection.
remove in interface Mapkey - the key to remove values from
Collection of values removed, implementations should
return null for no mapping found, but may return an empty collection
UnsupportedOperationException - if the map is unmodifiable
ClassCastException - if the key is of an invalid type
NullPointerException - if the key is null and null keys are invalidCollection<V> values()
values in interface Map
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||