uk.ac.ebi.intact.application.goDensity.business.data
Class Key2HashSet

java.lang.Object
  |
  +--uk.ac.ebi.intact.application.goDensity.business.data.Key2HashSet
Direct Known Subclasses:
CalcBinInteractionData, FastGoDag

public class Key2HashSet
extends java.lang.Object

Key2HashSet with unique (!) Values for a key. That means, it is realated to a Hashtable: you have keys, and for each key you get a set of unique values / Objects (internally stored in a HashSet).

Version:
$Id: Key2HashSet.java,v 1.1 2003/09/02 15:08:32 markusbrosch Exp $
Author:
Markus Brosch (markus @ brosch.cc)

Field Summary
protected  java.util.Hashtable _key2HashSet
          All keys are stored in this Hashtable.
protected  java.util.HashSet _values
          Each value within the Hashtable _key2HashSet hast on HashSet - set of unique values
 
Constructor Summary
Key2HashSet()
          default Constructor
 
Method Summary
 boolean add(java.lang.String key, java.lang.Object value)
          Allows to add a key / value pair.
 boolean containsKey(java.lang.String key)
          test, if Key2HashSet already contains the String "key"
 java.util.Hashtable getAll()
          Allows to get all HashSets for all keys and all keys itself.
 java.util.Enumeration getKeys()
           
 java.util.HashSet getValueByKey(java.lang.String key)
          Allows to get the related HashSet by the unique key.
 java.lang.String toString()
          toString Method for Key2HashSet
Example output:
key: ac2 -> values: [10, 30, 20]
key: ac1 -> values: [2, 1]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_key2HashSet

protected java.util.Hashtable _key2HashSet
All keys are stored in this Hashtable.


_values

protected java.util.HashSet _values
Each value within the Hashtable _key2HashSet hast on HashSet - set of unique values

Constructor Detail

Key2HashSet

public Key2HashSet()
default Constructor

Method Detail

add

public boolean add(java.lang.String key,
                   java.lang.Object value)
Allows to add a key / value pair.

Parameters:
key - - the keyword
value - - Object, which should be added for the key parameter. Object "value" must implement the equals(Object o) and hasCode() method, otherwise it will not be added! If key has already a value, this value will be added as long as it is not already there (HashSet)
Returns:
if key/value pair was already contained
- true -> if the set did not already contain the specified element.

getValueByKey

public java.util.HashSet getValueByKey(java.lang.String key)
                                throws KeyNotFoundException
Allows to get the related HashSet by the unique key.

Parameters:
key - - key
Returns:
HashSet of Objects which belongs to one unique key
Throws:
KeyNotFoundException - - if key was not found

getAll

public java.util.Hashtable getAll()
Allows to get all HashSets for all keys and all keys itself.

Returns:
Hashtable:
- keys (String): the key for accessing one HashSet
- values: a HashSet for each key.

getKeys

public java.util.Enumeration getKeys()
Returns:
all keys (Strings) as a Enumeration

containsKey

public boolean containsKey(java.lang.String key)
test, if Key2HashSet already contains the String "key"

Parameters:
key - which should be tested if it is already added
Returns:
true if and only if the specified key is a key in this Key2HashSet; false otherwise.

toString

public java.lang.String toString()
toString Method for Key2HashSet
Example output:
key: ac2 -> values: [10, 30, 20]
key: ac1 -> values: [2, 1]

Overrides:
toString in class java.lang.Object
Returns:
String representation for Key2HashSet


IntAct Project - EMBL-EBI 2004 - intact-help@ebi.ac.uk