structure5
Class Entry<K,V>

java.lang.Object
  extended by structure5.Entry<K,V>
All Implemented Interfaces:
java.util.Map.Entry<K,V>

public class Entry<K,V>
extends java.lang.Object
implements java.util.Map.Entry<K,V>

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

Field Detail

theKey

protected K theKey

theValue

protected V theValue
The mutable value. An arbitrary object.

Constructor Detail

Entry

public Entry(K key,
             V value)
Constructs a pair from a key and value.

Parameters:
key - A non-null object.
value - A (possibly null) object.
Precondition:
Key is non-null
Postcondition:
Constructs a key-value pair

Entry

public Entry(K key)
Constructs a pair from a key; value is null.

Parameters:
key - A non-null key value.
Precondition:
Key is non-null
Postcondition:
Constructs a key-value pair
Method Detail

equals

public boolean equals(java.lang.Object other)
Standard comparison function. Comparison based on keys only.

Specified by:
equals in interface java.util.Map.Entry<K,V>
Overrides:
equals in class java.lang.Object
Parameters:
other - Another association.
Returns:
True iff the keys are equal.
Precondition:
Other is non-null Entry
Postcondition:
Returns true iff the keys are equal

hashCode

public int hashCode()
Standard hashcode function.

Specified by:
hashCode in interface java.util.Map.Entry<K,V>
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code for association.
See Also:
Hashtable
Postcondition:
Return hash code association with this association

getValue

public V getValue()
Fetch value from association. May return null.

Specified by:
getValue in interface java.util.Map.Entry<K,V>
Returns:
The value field of the association.
Postcondition:
Returns value from association

getKey

public K getKey()
Fetch key from association. Should not return null.

Specified by:
getKey in interface java.util.Map.Entry<K,V>
Returns:
Key of the key-value pair.
Postcondition:
Returns key from association

setValue

public V setValue(V value)
Sets the value of the key-value pair.

Specified by:
setValue in interface java.util.Map.Entry<K,V>
Parameters:
value - The new value.
Postcondition:
Sets association's value to value

toString

public java.lang.String toString()
Standard string representation of an association.

Overrides:
toString in class java.lang.Object
Returns:
String representing key-value pair.
Postcondition:
Returns string representation