ch.sahits.datastructure
Class Pair

java.lang.Object
  extended by ch.sahits.datastructure.Pair
All Implemented Interfaces:
java.util.Map.Entry<java.lang.String,java.lang.Object>

public class Pair
extends java.lang.Object
implements java.util.Map.Entry<java.lang.String,java.lang.Object>

This data structure holds a key value pair. The key is a string the value can be an abitrairy data type. The Pair is used as a list element where each key may only occure once.

Author:
Andi Hotz

Constructor Summary
Pair(java.lang.String key, java.lang.Object value)
          Constructor initializes the key value pair
 
Method Summary
 boolean equals(java.lang.Object obj)
          Since a Pair is always part of a list where a key may only occure once the equals method does only check for the equality of the key.
 java.lang.String getKey()
          Retrieve the key
 java.lang.Object getValue()
          Retrieve the value
 int hashCode()
          
 java.lang.Object setValue(java.lang.Object value)
          Doe nothing.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair(java.lang.String key,
            java.lang.Object value)
Constructor initializes the key value pair

Parameters:
key -
value -
Method Detail

getKey

public java.lang.String getKey()
Retrieve the key

Specified by:
getKey in interface java.util.Map.Entry<java.lang.String,java.lang.Object>
Returns:
key value

getValue

public java.lang.Object getValue()
Retrieve the value

Specified by:
getValue in interface java.util.Map.Entry<java.lang.String,java.lang.Object>
Returns:
value

hashCode

public int hashCode()

Specified by:
hashCode in interface java.util.Map.Entry<java.lang.String,java.lang.Object>
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)
Since a Pair is always part of a list where a key may only occure once the equals method does only check for the equality of the key.

Specified by:
equals in interface java.util.Map.Entry<java.lang.String,java.lang.Object>
Overrides:
equals in class java.lang.Object
Parameters:
obj - Objekt to be compared
Returns:
true if the key is equal

setValue

public java.lang.Object setValue(java.lang.Object value)
Doe nothing. Initialize the value at constructor time

Specified by:
setValue in interface java.util.Map.Entry<java.lang.String,java.lang.Object>
Parameters:
value - null
Returns:
RuntimeException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()