Java Platform 1.2
Beta 4

Interface java.util.Map.Entry


public abstract static interface Map.Entry
A Map entry (key-value pair). The Map.entrySet method returns a Collection-view of the Map, whose elements are of this class. The only way to obtain a reference to a Map.Entry is from the iterator of this Collection-view. These Map.Entry objects are valid only for the duration of the iteration; more formally, the behavior of a Map.Entry is undefined if the backing Map has been modified after the Entry was returned by the Iterator, except through the Iterator's own remove operation, or through the setValue operation of Map.EntrySet returned by the Iterator.

See Also:
Map.entrySet()

Method Summary
 boolean equals(Object o)
          Compares the specified Object with this Entry for equality.
 Object getKey()
          Returns the key corresponding to this Entry.
 Object getValue()
          Returns the value corresponding to this Entry.
 int hashCode()
          Returns the hash code value for this Map.
 Object setValue(Object value)
          Replaces the value corresponding to this Entry with the specified value (optional operation).
 

Method Detail

getKey

public Object getKey()
Returns the key corresponding to this Entry.
Returns:
the key corresponding to this Entry.

getValue

public Object getValue()
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.
Returns:
the value corresponding to this Entry.

setValue

public Object setValue(Object value)
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).
Parameters:
New - value to be stored in this Entry.
Returns:
old value corresponding to the Entry.
Throws:
UnsupportedOperationException - put operation is not supported by the backing Map.
ClassCastException - class of the specified value prevents it from being stored in the backing Map.
IllegalArgumentException - some aspect of this value prevents it from being stored in the backing Map.
NullPointerException - the backing Map does not permit null values, and the specified value is null.

equals

public boolean equals(Object o)
Compares the specified Object with this Entry for equality. Returns true if the given object is also a Map.Entry and the two Entries represent the same mapping. 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())) . This ensures that the equals method works properly across different implementations of the Map.Entry interface.
Parameters:
o - Object to be compared for equality with this Map.Entry.
Returns:
true if the specified Object is equal to this Map.Entry.
Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code value for this Map.Entry. The hash code of a Map.Entry e is defined to be: (e.getKey()==null ? 0 : e.getKey().hashCode()) ^ (e.getValue()==null ? 0 : e.getValue().hashCode()) This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2, as required by the general contract of Object.hashCode.
Returns:
the hash code value for this Map.Entry.
Overrides:
hashCode in class Object
See Also:
Object.hashCode(), Object.equals(Object), equals(Object)

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.