com.arsdigita.util
Class Pair

java.lang.Object
  extended bycom.arsdigita.util.Pair
All Implemented Interfaces:
Cloneable, Map.Entry

public class Pair
extends Object
implements Map.Entry, Cloneable

The simplest possible implementation of Map.Entry. Instances of this class contains references to the key and value set in the constructor.

Version:
$Revision: #7 $ $Date: 2004/04/07 $
Author:
David Lutterkort

Field Summary
static String versionId
           
 
Constructor Summary
Pair(Object key, Object value)
           Creates a new Pair instance.
 
Method Summary
protected  Object clone()
           Return a shallow copy of this pair.
 boolean equals(Object o)
           Compare the specified object with this pair.
 Object getKey()
           Returns the key corresponding to this pair.
 Object getValue()
           Returns the value corresponding to this pair.
 int hashCode()
           The hash code for this pair.
 Object setValue(Object value)
           Replaces the value corresponding to this pair with the specified value.
 String toString()
           Convert this pair to a String.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

Pair

public Pair(Object key,
            Object value)

Creates a new Pair instance.

Parameters:
key - the key for this pair.
value - the value for this pair.
Method Detail

clone

protected Object clone()

Return a shallow copy of this pair. The key and value of the new pair refer to the same objects as the key and value in the pair being cloned.

Returns:
Object A new pair, referring to the same key and value

getKey

public final Object getKey()

Returns the key corresponding to this pair.

Specified by:
getKey in interface Map.Entry
Returns:
Object The key for this pair.

getValue

public final Object getValue()

Returns the value corresponding to this pair.

Specified by:
getValue in interface Map.Entry
Returns:
Object The value for this pair.

setValue

public Object setValue(Object value)

Replaces the value corresponding to this pair with the specified value.

Specified by:
setValue in interface Map.Entry
Returns:
Object Old value corresponding to the entry.

equals

public boolean equals(Object o)

Compare the specified object with this pair. Returns true if the given object is also a Map.Entry and its key and value are equal to those of this pair. More formally, two entries e1 and e2 represent the same mapping if

 (e1.getKey()==null ?
     e2.getKey()==null : e1.getKey().equals(e2.getKey()))  &&
 (e1.getValue()==null ?
     e2.getValue()==null : e1.getValue().equals(e2.getValue()))
 

Specified by:
equals in interface Map.Entry
Parameters:
o - object to be compared for equality with this pair.
Returns:
boolean true if the specified object is equal to this pair as a map entry.

hashCode

public int hashCode()

The hash code for this pair. The hash code is the bitwise exclusive or of the hash codes of the key and the value. If either of these entries is null, its hash code is taken to be 0 in the exclusive or.

Specified by:
hashCode in interface Map.Entry
Returns:
int The hash code of this pair.

toString

public String toString()

Convert this pair to a String. The returned string is of the form key=value where key and value are the entries in this pair, converted to String.

Returns:
String of the form key=value


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC