|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap org.apache.commons.collections.MultiHashMap org.jopendocument.util.CollectionMap<K,V>
K
- type of the keysV
- type of elements in collectionspublic class CollectionMap<K,V>
Une MultiMap qui permet de ne pas renvoyer null
. De plus elle permet de choisir le
type de Collection utilisé.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
CollectionMap()
Une nouvelle map avec ArrayList comme collection. |
|
CollectionMap(Class aCollectionClass)
Une nouvelle map. |
|
CollectionMap(Class aCollectionClass,
int initialCapacity)
|
|
CollectionMap(Collection<V> collectionSpecimen)
|
|
CollectionMap(Collection<V> collectionSpecimen,
int initialCapacity)
A map that creates new collections by cloning collectionSpecimen. |
|
CollectionMap(int initialCapacity)
Une nouvelle map sans préciser le type de collection. |
Method Summary | ||
---|---|---|
Collection<V> |
createCollection(Collection coll)
|
|
Set<Map.Entry<K,Collection<V>>> |
entrySet()
|
|
Class |
getCollectionClass()
|
|
Collection<V> |
getNonNull(K key)
Renvoie la collection associée à la clef passée. |
|
Collection<V> |
getNull(K key)
Just for the generics. |
|
Set<K> |
keySet()
|
|
void |
merge(org.apache.commons.collections.MultiMap mm)
Fusionne la MultiMap avec celle-ci. |
|
boolean |
putAll(K key,
V... values)
|
|
void |
putAll(Map mapToCopy)
Copies all of the mappings from the specified map to this map. |
|
Collection<V> |
remove(Object key)
|
|
void |
removeAll(CollectionMap<? extends K,? extends V> mm)
|
|
void |
removeAll(Map<? extends K,? extends V> m)
|
|
static
|
singleton(K key,
Collection<V> values)
Create a map with a single entry. |
|
static
|
singleton(K key,
V... values)
|
|
static
|
singleton(K key,
V value)
|
|
Collection<V> |
values()
|
Methods inherited from class org.apache.commons.collections.MultiHashMap |
---|
clear, clone, containsValue, containsValue, getCollection, iterator, put, putAll, remove, size, totalSize |
Methods inherited from class java.util.HashMap |
---|
containsKey, get, isEmpty, size |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.commons.collections.MultiMap |
---|
get, size |
Methods inherited from interface java.util.Map |
---|
containsKey, equals, hashCode, isEmpty |
Constructor Detail |
---|
public CollectionMap()
public CollectionMap(Class aCollectionClass)
collectionClass
doit descendre de Collection, et posséder un
constructeur prenant une Collection (c'est le cas de la majorité des classes de java.util).
aCollectionClass
- le type de collection utilisé.public CollectionMap(int initialCapacity)
createCollection(Collection)
. Ce constructeur est donc
utile pour des raisons de performances (évite la réflexion nécessaire avec les autres).
initialCapacity
- the initial capacity.public CollectionMap(Class aCollectionClass, int initialCapacity)
public CollectionMap(Collection<V> collectionSpecimen)
public CollectionMap(Collection<V> collectionSpecimen, int initialCapacity)
collectionSpecimen
- the collection from which to all others will be cloned.initialCapacity
- the initial capacity
IllegalArgumentException
- is not a Cloneable.Method Detail |
---|
public static <K,V> CollectionMap<K,V> singleton(K key, Collection<V> values)
K
- type of key.V
- type of items.key
- the single key.values
- the values for key
.
public static <K,V> CollectionMap<K,V> singleton(K key, V... values)
public static <K,V> CollectionMap<K,V> singleton(K key, V value)
public Collection<V> getNonNull(K key)
key
- la clef.
getCollectionClass()
public Collection<V> getNull(K key)
key
- the key whose associated value is to be returned
null
if this map contains
no mapping for the key.public Collection<V> createCollection(Collection coll)
createCollection
in class org.apache.commons.collections.MultiHashMap
public Class getCollectionClass()
public void removeAll(CollectionMap<? extends K,? extends V> mm)
public void removeAll(Map<? extends K,? extends V> m)
public void merge(org.apache.commons.collections.MultiMap mm)
mm
- la MultiMap à fusionner.public void putAll(Map mapToCopy)
MultiHashMap.MultiHashMap(Map)
. NOTE: cannot use Map extends K, ? extends V> since
java complains (MultiHashMap not being generic).
putAll
in interface Map
putAll
in class HashMap
mapToCopy
- mappings to be stored in this mappublic boolean putAll(K key, V... values)
public Set<Map.Entry<K,Collection<V>>> entrySet()
entrySet
in interface Map
entrySet
in class HashMap
public Set<K> keySet()
keySet
in interface Map
keySet
in class HashMap
public Collection<V> values()
values
in interface Map
values
in interface org.apache.commons.collections.MultiMap
values
in class org.apache.commons.collections.MultiHashMap
public Collection<V> remove(Object key)
remove
in interface Map
remove
in interface org.apache.commons.collections.MultiMap
remove
in class HashMap
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |