Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Interface java.util.Map.Entry

Implementing Classes:
TreeMap.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:
entrySet()

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

Method Detail

getKey

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

getValue

public java.lang.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 java.lang.Object setValue(java.lang.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.
java.lang.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(java.lang.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 java.lang.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 java.lang.Object
See Also:
hashCode(), equals(Object), equals(Object)

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD