© 1998-2002 McGraw-Hill

structure
Class Entry

java.lang.Object
  |
  +--structure.Entry
All Implemented Interfaces:
Map.Entry

public class Entry
extends Object
implements Map.Entry

An implementation of the the java.util.Map.Entry interface, Entry is a simple key value pair, from which both the key and the value can be accessed. Association and related classes also implement the Map interface and have expanded functionality.

Typical Usage:

 ...
     Entry e = new Entry(aKey, aValue);
     Object key = e.getKey();
     Object value = e.getValue();
     e.setValue(newValue);
 ...
 


Field Summary
protected  Object theKey
           
protected  Object theValue
          The mutable value.
 
Constructor Summary
Entry(Object key)
          Constructs a pair from a key; value is null.
Entry(Object key, Object value)
          Constructs a pair from a key and value.
 
Method Summary
 boolean equals(Object other)
          Standard comparison function.
 Object getKey()
          Fetch key from association.
 Object getValue()
          Fetch value from association.
 int hashCode()
          Standard hashcode function.
 Object setValue(Object value)
          Sets the value of the key-value pair.
 String toString()
          Standard string representation of an association.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

theKey

protected Object theKey

theValue

protected Object theValue
The mutable value. An arbitrary object.
Constructor Detail

Entry

public Entry(Object key,
             Object value)
Constructs a pair from a key and value.
Parameters:
key - A non-null object.
value - A (possibly null) object.

Entry

public Entry(Object key)
Constructs a pair from a key; value is null.
Parameters:
key - A non-null key value.
Method Detail

equals

public boolean equals(Object other)
Standard comparison function. Comparison based on keys only.
Specified by:
equals in interface Map.Entry
Overrides:
equals in class Object
Parameters:
other - Another association.
Precondition:
Other is non-null Entry
Postcondition:
Returns true iff the keys are equal
Returns:
True iff the keys are equal.

hashCode

public int hashCode()
Standard hashcode function.
Specified by:
hashCode in interface Map.Entry
Overrides:
hashCode in class Object
Postcondition:
Return hash code association with this association
Returns:
A hash code for association.
See Also:
Hashtable

getValue

public Object getValue()
Fetch value from association. May return null.
Specified by:
getValue in interface Map.Entry
Postcondition:
Returns value from association
Returns:
The value field of the association.

getKey

public Object getKey()
Fetch key from association. Should not return null.
Specified by:
getKey in interface Map.Entry
Postcondition:
Returns key from association
Returns:
Key of the key-value pair.

setValue

public Object setValue(Object value)
Sets the value of the key-value pair.
Specified by:
setValue in interface Map.Entry
Parameters:
value - The new value.
Postcondition:
Sets association's value to value

toString

public String toString()
Standard string representation of an association.
Overrides:
toString in class Object
Postcondition:
Returns string representation
Returns:
String representing key-value pair.

© 1998-2002 McGraw-Hill