org.gjt.lindfors.util
Class Pair

java.lang.Object
  extended byorg.gjt.lindfors.util.Pair
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Pair
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A container class for holding key, value pairs.

Every effort has been made to try to achieve thread-safety in Pair class. Of course, this doesn't mean bugs and nasty race conditions or dead locks don't exist. I'm just not aware of them :)

For more detailed documentation, refer to the Util Library Developer's Guide

Since:
JDK 1.1
Version:
$Revision: 1.6 $
Author:
Juha Lindfors
See Also:
Serialized Form

Constructor Summary
Pair(java.lang.Object key, java.lang.Object value)
          Constructs a key, value pair.
 
Method Summary
 java.lang.Object clone()
          Performs a shallow copy to this object.
 java.lang.Object getKey()
          Returns the key object of this pair.
 java.lang.Object getValue()
          Returns the value object of this pair.
 void setPair(java.lang.Object key, java.lang.Object value)
          Sets key and value for this pair.
 void setPair(Pair pair)
          Sets key and value for this pair.
 java.lang.String toString()
          Returns a textual representation of this object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair(java.lang.Object key,
            java.lang.Object value)
Constructs a key, value pair.

Parameters:
key - key of this pair
value - value of this pair
Method Detail

getValue

public java.lang.Object getValue()
Returns the value object of this pair.

Returns:
value

getKey

public java.lang.Object getKey()
Returns the key object of this pair.

Returns:
key

setPair

public void setPair(java.lang.Object key,
                    java.lang.Object value)
Sets key and value for this pair.

Parameters:
key - key of this pair
value - value of this pair

setPair

public void setPair(Pair pair)
Sets key and value for this pair.

Parameters:
pair - Pair to be copied into this object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Performs a shallow copy to this object. The key and value objects of this pair are not cloned.

Returns:
cloned pair
Throws:
java.lang.CloneNotSupportedException

toString

public java.lang.String toString()
Returns a textual representation of this object. Calls toString methods of both key and value objects to build the text string.

Returns:
textual representation of a pair object