com.sapportals.portal.prt.util
Class MultiValuedHashMap

java.lang.Object
  |
  +--com.sapportals.portal.prt.util.MultiValuedHashMap
All Implemented Interfaces:
MultiValuedMap

public class MultiValuedHashMap
extends java.lang.Object
implements MultiValuedMap

Copyright (c) SAP Portals Europe GmbH 2001

Version:
$Revision: #3 $

Constructor Summary
MultiValuedHashMap()
          Constructor using defaults for the initial capacity
MultiValuedHashMap(int initialCapacity)
          Constructor with specified initial capacity, i.e. an assumption about how many keys will show up.
 
Method Summary
 void clear()
          Clears the map, i.e. removes all key to value assigments.
 void getKeys(java.lang.Object[] keys)
          Gets an Array of keys.
 java.util.Enumeration getKeysEnumeration()
          Gets an Enumeration of all keys
 java.lang.Object getValue(java.lang.Object key)
          Gets a single value assigned to one key.
 int getValueCount(java.lang.Object key)
          Gets the number of values assigned to a key.
 void getValues(java.lang.Object key, java.lang.Object[] values)
          Gets all values assigned to the specified key as an Array
 java.util.Iterator getValuesIterator(java.lang.Object key)
          Gets an Iterator of all values assigned to a key.
 void put(java.lang.Object key, java.lang.Object value)
          Adds a key->value couple to the map.
 void remove(java.lang.Object key)
          Removes a key with all its assigned values.
 void remove(java.lang.Object key, java.lang.Object value)
          Removes a key/value combination from the map.
 int size()
          Gets the number of keys that were assigned values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiValuedHashMap

public MultiValuedHashMap()
Constructor using defaults for the initial capacity

MultiValuedHashMap

public MultiValuedHashMap(int initialCapacity)
Constructor with specified initial capacity, i.e. an assumption about how many keys will show up.
Parameters:
initialCapacity - the initial capacity in terms of keys
Method Detail

put

public void put(java.lang.Object key,
                java.lang.Object value)
Adds a key->value couple to the map.
Specified by:
put in interface MultiValuedMap
Parameters:
key - the key identifying a set of values
value - one more value assignd to key

remove

public void remove(java.lang.Object key)
Removes a key with all its assigned values.
Specified by:
remove in interface MultiValuedMap
Parameters:
attribute - The name of the attribute.
key -  

remove

public void remove(java.lang.Object key,
                   java.lang.Object value)
Removes a key/value combination from the map.
Specified by:
remove in interface MultiValuedMap
Parameters:
key - The key.
value - The value that was possibly assigned to key and should be removed now.

getKeysEnumeration

public java.util.Enumeration getKeysEnumeration()
Gets an Enumeration of all keys
Specified by:
getKeysEnumeration in interface MultiValuedMap
Returns:
an Enumeration of all keys

getKeys

public void getKeys(java.lang.Object[] keys)
Gets an Array of keys.
Specified by:
getKeys in interface MultiValuedMap
Parameters:
an - keys an Array to contain all the keys that have values assigned.
keys -  

size

public int size()
Gets the number of keys that were assigned values.
Specified by:
size in interface MultiValuedMap
Returns:
the number of keys that were assigned values.

getValueCount

public int getValueCount(java.lang.Object key)
Gets the number of values assigned to a key.
Specified by:
getValueCount in interface MultiValuedMap
Parameters:
key - the key to retrieve the number of values assigned to
Returns:
the number of values assigned to the specified key.

getValuesIterator

public java.util.Iterator getValuesIterator(java.lang.Object key)
Gets an Iterator of all values assigned to a key.
Specified by:
getValuesIterator in interface MultiValuedMap
Parameters:
key - the key to get all values for.
Returns:
an Iterator of all values assigned to key, or possibly null if no value at all was assigned to key.

getValues

public void getValues(java.lang.Object key,
                      java.lang.Object[] values)
Gets all values assigned to the specified key as an Array
Specified by:
getValues in interface MultiValuedMap
Parameters:
key - The name of the queried key
values - An array of values of a key.

getValue

public java.lang.Object getValue(java.lang.Object key)
Gets a single value assigned to one key.
Specified by:
getValue in interface MultiValuedMap
Parameters:
key - the key to get the value for.
Returns:
The lone value of an attribute. Note: If the attribute is multi-valued, any one the values can be the result of a call to this method.

clear

public void clear()
Clears the map, i.e. removes all key to value assigments.
Specified by:
clear in interface MultiValuedMap