org.biomage.tools.xmlutils
Class MultiHashMap

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

public class MultiHashMap
extends java.util.HashMap
implements MultiMap

Utility class for associating multiple values with a key in a Synchronized Map.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
MultiHashMap()
          
MultiHashMap(int initial_capacity)
          
MultiHashMap(int initial_capacity, float load_factor)
          
MultiHashMap(java.util.Map copy_from)
          
MultiHashMap(MultiHashMap copy_from)
          Constructs a new MultiHashMap with the same mappings as the given MultiHashMap.
MultiHashMap(MultiMap copy_from)
          Constructs a new MultiHashMap with the same mappings as the given MultiMap.
 
Method Summary
 boolean containsValue(java.lang.Object value)
          
protected  java.util.Set createValuesSet()
          Factory method for instantiating objects of type Set for use as the containers of multiple values mapped to a single key.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           Note that this method will always return null.
 java.lang.Object remove(java.lang.Object key, java.lang.Object value)
          Remove the given ( key, value ) pair from this MultiMap.
 boolean removeAll(java.lang.Object obj)
          Remove all references to an Object (all values and a key, if any).
 java.util.Collection values()
          
 java.util.Collection valuesSets()
           
 
Methods inherited from class java.util.HashMap
clear, clone, 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
clear, containsKey, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size
 

Constructor Detail

MultiHashMap

public MultiHashMap()


MultiHashMap

public MultiHashMap(int initial_capacity)


MultiHashMap

public MultiHashMap(int initial_capacity,
                    float load_factor)


MultiHashMap

public MultiHashMap(MultiHashMap copy_from)
Constructs a new MultiHashMap with the same mappings as the given MultiHashMap.


MultiHashMap

public MultiHashMap(MultiMap copy_from)
Constructs a new MultiHashMap with the same mappings as the given MultiMap. Actually this just throws an UnsupportedOperationException, since we've no way to know how the given MultiMap is implemented.


MultiHashMap

public MultiHashMap(java.util.Map copy_from)

Method Detail

containsValue

public boolean containsValue(java.lang.Object value)

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

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Note that this method will always return null.

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

removeAll

public boolean removeAll(java.lang.Object obj)
Remove all references to an Object (all values and a key, if any).

Specified by:
removeAll in interface MultiMap
Returns:
true iff anything was removed.

values

public java.util.Collection values()

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

remove

public java.lang.Object remove(java.lang.Object key,
                               java.lang.Object value)
Remove the given ( key, value ) pair from this MultiMap. If that was the only entry for the given key, the key will be removed altogether.

Specified by:
remove in interface MultiMap
Returns:
The given value, or null if the given ( key, value ) pair was not in the MultiMap.

valuesSets

public java.util.Collection valuesSets()
Specified by:
valuesSets in interface MultiMap
Returns:
The Collection of Sets, one for each present key. Any set returned may be null or empty. The Collection may also be null or empty.

createValuesSet

protected java.util.Set createValuesSet()
Factory method for instantiating objects of type Set for use as the containers of multiple values mapped to a single key. This should be a Synchronized Set.