org.datanucleus.util
Class MultiMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.datanucleus.util.MultiMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class MultiMap
extends java.util.HashMap

An implementation of a MultiMap, which is basically a Map with multiple values for a key. This will be removed when SUN see sense and include it in the JDK java.util package as standard.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
MultiMap()
          Constructor.
MultiMap(int initialCapacity)
          Constructor.
MultiMap(int initialCapacity, float loadFactor)
          Constructor.
MultiMap(MultiMap map)
          Constructor.
 
Method Summary
 void clear()
          Clear the map.
 java.lang.Object clone()
          Method to clone the Map.
 boolean containsValue(java.lang.Object value)
          Check if the map contains the passed value.
protected  java.util.Collection createCollection(java.util.Collection c)
          Creates a new instance of the map value Collection container.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Add a key, and its value, to the map.
 java.lang.Object remove(java.lang.Object key, java.lang.Object item)
          Removes a specific value from map.
 java.util.Collection values()
          Accessor for the values in the Map.
 
Methods inherited from class java.util.HashMap
containsKey, entrySet, get, isEmpty, keySet, putAll, remove, 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 java.util.Map
equals, hashCode
 

Constructor Detail

MultiMap

public MultiMap()
Constructor.


MultiMap

public MultiMap(int initialCapacity)
Constructor.

Parameters:
initialCapacity - the initial capacity

MultiMap

public MultiMap(int initialCapacity,
                float loadFactor)
Constructor.

Parameters:
initialCapacity - initial capacity
loadFactor - load factor for the Map.

MultiMap

public MultiMap(MultiMap map)
Constructor.

Parameters:
map - The initial Map.
Method Detail

containsValue

public boolean containsValue(java.lang.Object value)
Check if the map contains the passed value.

Specified by:
containsValue in interface java.util.Map
Overrides:
containsValue in class java.util.HashMap
Parameters:
value - the value to search for
Returns:
true if the list contains the value

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Add a key, and its value, to the map.

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.HashMap
Parameters:
key - the key to set
value - the value to set the key to
Returns:
the value added when successful, or null if an error

remove

public java.lang.Object remove(java.lang.Object key,
                               java.lang.Object item)
Removes a specific value from map. The item is removed from the collection mapped to the specified key.

Parameters:
key - the key to remove from
item - the value to remove
Returns:
the value removed (which was passed in)

clear

public void clear()
Clear the map.

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.HashMap

values

public java.util.Collection values()
Accessor for the values in the Map.

Specified by:
values in interface java.util.Map
Overrides:
values in class java.util.HashMap
Returns:
all of the values in the map

clone

public java.lang.Object clone()
Method to clone the Map. Performs a shallow copy of the entry set.

Overrides:
clone in class java.util.HashMap
Returns:
the cloned map

createCollection

protected java.util.Collection createCollection(java.util.Collection c)
Creates a new instance of the map value Collection container.

Parameters:
c - the collection to copy
Returns:
new collection


Copyright © 2009. All Rights Reserved.