|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.1.0) E17493-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.util.MultiMap<K,V>
public class MultiMap<K,V>
An object that maps keys to collections of values. MultiMap<K,V>
is, in fact, a subtype of Map<K,Collection<V>>
; this type adds a small number
of methods that accept values of V
directly, rather than
values of Collection<V>
.
MultiMap
uses an underlying map to store the keys and associated
collections, and uses reflection to create the collections when needed.
From the default constructor, the underlying map is a LinkedHashMap
,
and the collections class is ArrayList
; other constructors allow
other classes to be specified (for example, ArraySortedSet
for the
collections class).
If the collection of values associated with a key becomes empty for any
reason, the collection is removed from the map. This ensures, for example,
that isEmpty() == (valuesSize() == 0)
and that
containsKey(key) == (valuesSize(key) > 0)
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Constructor Summary | |
---|---|
|
MultiMap()
Creates a new MultiMap based on a map of type LinkedHashMap
and collections of type ArrayList . |
|
MultiMap(java.lang.Class<? extends java.util.Collection> collectionClass)
Creates a new MultiMap based on a map of type LinkedHashMap
and collections of a specified type. |
|
MultiMap(java.lang.Class<? extends java.util.Map> mapClass,
java.lang.Class<? extends java.util.Collection> collectionClass)
Creates a new MultiMap based on a map of a specified type and
collections of a specified type. |
protected |
MultiMap(java.util.Map<K,java.util.Collection<V>> delegate,
java.lang.Class<? extends java.util.Collection> collectionClass)
|
|
MultiMap(MultiMap<K,V> map)
|
Method Summary | ||
---|---|---|
boolean |
add(K key,
V value)
Adds a value to the collection associated with a key. |
|
boolean |
addAll(K key,
java.util.Collection<V> values)
Adds a colleciton of values to the collection associated with a key. |
|
boolean |
addAll(K key,
V... values)
Adds an array of values to the collection associated with a key. |
|
boolean |
addAll(java.util.Map<? extends K,V> map)
Adds each value in a map to the collection associated with its key. |
|
void |
clear()
|
|
boolean |
contains(K key,
V value)
Gets whether the collection associated with a key contains a value. |
|
boolean |
containsKey(java.lang.Object key)
|
|
boolean |
containsValue(java.lang.Object value)
|
|
java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> |
entrySet()
|
|
boolean |
equals(java.lang.Object o)
|
|
java.util.Collection<V> |
get(java.lang.Object key)
|
|
static
|
getMultiMap()
Creates a new MultiMap based on a map of type LinkedHashMap
and collections of type ArrayList . |
|
static
|
getMultiMap(java.lang.Class<? extends java.util.Collection> collectionClass)
Creates a new MultiMap based on a map of type LinkedHashMap
and collections of a specified type. |
|
static
|
getMultiMap(java.lang.Class<? extends java.util.Map> mapClass,
java.lang.Class<? extends java.util.Collection> collectionClass)
Creates a new MultiMap based on a map of a specified type and
collections of a specified type. |
|
int |
hashCode()
|
|
boolean |
isEmpty()
|
|
java.util.Set<K> |
keySet()
|
|
int |
keysSize()
Gets the number of keys in this map. |
|
java.util.Collection<V> |
put(K key,
java.util.Collection<V> values)
|
|
void |
putAll(java.util.Map<? extends K,? extends java.util.Collection<V>> map)
|
|
V |
remove(K key,
V value)
Removes a value from the collection associated with a key. |
|
java.util.Collection<V> |
remove(java.lang.Object key)
|
|
int |
size()
|
|
java.lang.String |
toString()
|
|
java.util.Collection<java.util.Collection<V>> |
values()
|
|
int |
valuesSize()
Gets the number of values in this map. |
|
int |
valuesSize(K key)
Gets the number of values in this map associated with a key. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MultiMap()
MultiMap
based on a map of type LinkedHashMap
and collections of type ArrayList
.
public MultiMap(java.lang.Class<? extends java.util.Collection> collectionClass)
MultiMap
based on a map of type LinkedHashMap
and collections of a specified type.
public MultiMap(java.lang.Class<? extends java.util.Map> mapClass, java.lang.Class<? extends java.util.Collection> collectionClass)
MultiMap
based on a map of a specified type and
collections of a specified type.
protected MultiMap(java.util.Map<K,java.util.Collection<V>> delegate, java.lang.Class<? extends java.util.Collection> collectionClass)
public MultiMap(MultiMap<K,V> map)
Method Detail |
---|
public static <K,V> MultiMap<K,V> getMultiMap()
MultiMap
based on a map of type LinkedHashMap
and collections of type ArrayList
.
public static <K,V> MultiMap<K,V> getMultiMap(java.lang.Class<? extends java.util.Collection> collectionClass)
MultiMap
based on a map of type LinkedHashMap
and collections of a specified type.
public static <K,V> MultiMap<K,V> getMultiMap(java.lang.Class<? extends java.util.Map> mapClass, java.lang.Class<? extends java.util.Collection> collectionClass)
MultiMap
based on a map of a specified type and
collections of a specified type.
public int keysSize()
size()
, but
provided for symmetry with valuesSize()
.
public int valuesSize()
public int valuesSize(K key)
public boolean contains(K key, V value)
Map.containsValue(Object)
,
Collection.contains(java.lang.Object)
public boolean add(K key, V value)
put(K, java.util.Collection)
,
Collection.add(E)
public boolean addAll(K key, java.util.Collection<V> values)
public boolean addAll(K key, V... values)
public boolean addAll(java.util.Map<? extends K,V> map)
putAll(java.util.Map extends K, ? extends java.util.Collection>)
,
Collection.addAll(java.util.Collection extends E>)
public V remove(K key, V value)
remove(Object)
,
Collection.remove(java.lang.Object)
public int size()
size
in interface java.util.Map<K,java.util.Collection<V>>
public boolean isEmpty()
isEmpty
in interface java.util.Map<K,java.util.Collection<V>>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,java.util.Collection<V>>
public boolean containsValue(java.lang.Object value)
Because of the potential ambiguity about whether the value is a V
or a Collection<V>
, this implementation returns true in
either case.
containsValue
in interface java.util.Map<K,java.util.Collection<V>>
public java.util.Collection<V> get(java.lang.Object key)
get
in interface java.util.Map<K,java.util.Collection<V>>
public java.util.Collection<V> put(K key, java.util.Collection<V> values)
put
in interface java.util.Map<K,java.util.Collection<V>>
java.lang.IllegalArgumentException
- if the type of the collection of values
is not assignable to the collection class with which this multimap was
constructed.public java.util.Collection<V> remove(java.lang.Object key)
remove
in interface java.util.Map<K,java.util.Collection<V>>
public void putAll(java.util.Map<? extends K,? extends java.util.Collection<V>> map)
putAll
in interface java.util.Map<K,java.util.Collection<V>>
java.lang.IllegalArgumentException
- if the type of a collection of values
is not assignable to the collection class with which this multimap was
constructed.public void clear()
clear
in interface java.util.Map<K,java.util.Collection<V>>
public java.util.Set<K> keySet()
keySet
in interface java.util.Map<K,java.util.Collection<V>>
public java.util.Collection<java.util.Collection<V>> values()
values
in interface java.util.Map<K,java.util.Collection<V>>
public java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> entrySet()
entrySet
in interface java.util.Map<K,java.util.Collection<V>>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<K,java.util.Collection<V>>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Map<K,java.util.Collection<V>>
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.1.0) E17493-02 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |