org.jpox.util
Class MultiMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.jpox.util.MultiMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

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.

Version:
$Revision: 1.3 $
See Also:
Serialized Form

Constructor Summary
MultiMap()
          Constructor.
MultiMap(int initialCapacity)
          Constructor.
MultiMap(int initialCapacity, float loadFactor)
          Constructor.
MultiMap(java.util.Map 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(java.util.Map 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.

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.

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.


values

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

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.

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 © -2007 . All Rights Reserved.