harpoon.Util.Collections
Class PairMapEntry

java.lang.Object
  |
  +--harpoon.Util.Collections.AbstractMapEntry
        |
        +--harpoon.Util.Collections.PairMapEntry
All Implemented Interfaces:
Map.Entry

public class PairMapEntry
extends AbstractMapEntry

PairMapEntry is the easiest implementation of a Map.Entry ever: a pair! Basically saves coders the drugery of writing an inner class at the expense of an import statement. Note that PairMapEntrys are mutable: setValue(Object) is defined in this class. Using null as a key or value will not cause this class or AbstractMapEntry to fail, but be warned that several Map implementations do not like nulls in their internal structures.

Version:
$Id: PairMapEntry.java,v 1.2 2002/02/25 21:09:13 cananian Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>

Constructor Summary
PairMapEntry(Object key, Object value)
          Creates a PairMapEntry.
 
Method Summary
 Object getKey()
          Returns the key corresponding to this entry.
 Object getValue()
          Returns the value corresponding to this entry.
protected  Object setKey(Object newKey)
          For use in subclass implementations *only*.
 Object setValue(Object newValue)
          Replaces the value corresponding to this entry with the specified value (optional operation).
 
Methods inherited from class harpoon.Util.Collections.AbstractMapEntry
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PairMapEntry

public PairMapEntry(Object key,
                    Object value)
Creates a PairMapEntry.

Method Detail

getKey

public Object getKey()
Description copied from class: AbstractMapEntry
Returns the key corresponding to this entry.

Specified by:
getKey in interface Map.Entry
Specified by:
getKey in class AbstractMapEntry

getValue

public Object getValue()
Description copied from class: AbstractMapEntry
Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove() operation), the results of this call are undefined.

Specified by:
getValue in interface Map.Entry
Specified by:
getValue in class AbstractMapEntry

setKey

protected Object setKey(Object newKey)
For use in subclass implementations *only*.


setValue

public Object setValue(Object newValue)
Description copied from class: AbstractMapEntry
Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove() operation).

Specified by:
setValue in interface Map.Entry
Overrides:
setValue in class AbstractMapEntry
Returns:
old value corresponding to entry.