org.pf.util
Class CollectorDictionary

java.lang.Object
  extended by org.pf.util.CollectorDictionary
All Implemented Interfaces:
java.util.Map

public class CollectorDictionary
extends java.lang.Object
implements java.util.Map

This class implements the java.util.Map interface. Its main difference to a java.util.Hashtable is that for duplicate key additions the corresponding values are kept in a list. All values of this class are lists (java.util.List)

Version:
1.2
Author:
Manfred Duchrow

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
CollectorDictionary()
          Initialize the new instance with default values.
CollectorDictionary(boolean allowDuplicates)
          Initialize the new instance with default values.
CollectorDictionary(int initialCapacity)
          Initialize the new instance with default values.
 
Method Summary
 void clear()
          Removes all mappings from this map (optional operation).
 boolean containsKey(java.lang.Object key)
          Returns true if this map contains a mapping for the specified key.
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more keys to the specified value.
 java.util.Set entrySet()
          Returns a set view of the mappings contained in this map.
 boolean equals(java.lang.Object obj)
          Compares the specified object with this map for equality.
 java.lang.Object get(java.lang.Object key)
           
 boolean getAcceptDuplicates()
           
 int hashCode()
          Returns the hash code value for this map.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 java.util.Iterator keys()
          Returns an iterator over all key objects in this map.
 java.util.Set keySet()
          Returns a set view of the keys contained in this map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Stores the given value object under the specified key object.
 void putAll(java.util.Map map)
          Copies all of the mappings from the specified map to this map.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from this map if present.
 void setAcceptDuplicates(boolean newValue)
           
 int size()
          Returns the number of key-value mappings in this map.
 java.util.Collection values()
          Returns a collection view of the values contained in this map.
 int valuesSize()
          Returns a collection view of the values contained in this map.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectorDictionary

public CollectorDictionary()
Initialize the new instance with default values.


CollectorDictionary

public CollectorDictionary(int initialCapacity)
Initialize the new instance with default values.


CollectorDictionary

public CollectorDictionary(boolean allowDuplicates)
Initialize the new instance with default values.

Method Detail

getAcceptDuplicates

public boolean getAcceptDuplicates()

setAcceptDuplicates

public void setAcceptDuplicates(boolean newValue)

clear

public void clear()
Removes all mappings from this map (optional operation).

Specified by:
clear in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)).

Specified by:
containsValue in interface java.util.Map
Parameters:
value - - value whose presence in this map is to be tested.
Returns:
true if this map maps one or more keys to the specified value.

entrySet

public java.util.Set entrySet()
Returns a set view of the mappings contained in this map.

Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object obj)
Compares the specified object with this map for equality. Returns true if the given object is also a map and the two Maps represent the same mappings.

Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns the hash code value for this map.

Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.

Specified by:
isEmpty in interface java.util.Map

keySet

public java.util.Set keySet()
Returns a set view of the keys contained in this map.

Specified by:
keySet in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Stores the given value object under the specified key object.

Specified by:
put in interface java.util.Map

putAll

public void putAll(java.util.Map map)
Copies all of the mappings from the specified map to this map.

Specified by:
putAll in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Removes the mapping for this key from this map if present.

Specified by:
remove in interface java.util.Map

size

public int size()
Returns the number of key-value mappings in this map.

Specified by:
size in interface java.util.Map

values

public java.util.Collection values()
Returns a collection view of the values contained in this map. In this case all elements of the returned collection are java.util.List objects which contain the real values !

Specified by:
values in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

keys

public java.util.Iterator keys()
Returns an iterator over all key objects in this map.


valuesSize

public int valuesSize()
Returns a collection view of the values contained in this map. In this case all elements of the returned collection are java.util.List objects which contain the real values !