Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Interface java.util.Map.Entry


public static interface Map.Entry
A Map entry (key-value pair). The Map.entries 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.Entries returned by the Iterator.

Since:
JDK1.2
See Also:
entries()

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.Entry.
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.

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.

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.
Overrides:
hashCode in class Object
See Also:
hashCode(), equals(Object), equals(Object)

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

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.