Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.util
Class AbstractMap.BasicMapEntry  view AbstractMap.BasicMapEntry download AbstractMap.BasicMapEntry.java

java.lang.Object
  extended byjava.util.AbstractMap.BasicMapEntry
All Implemented Interfaces:
Map.Entry
Direct Known Subclasses:
HashMap.HashEntry, Hashtable.HashEntry, TreeMap.Node
Enclosing class:
AbstractMap

static class AbstractMap.BasicMapEntry
extends java.lang.Object
implements Map.Entry

A class which implements Map.Entry. It is shared by HashMap, TreeMap, Hashtable, and Collections. It is not specified by the JDK, but makes life much easier.


Field Summary
(package private)  java.lang.Object key
          The key.
(package private)  java.lang.Object value
          The value.
 
Constructor Summary
(package private) AbstractMap.BasicMapEntry(java.lang.Object newKey, java.lang.Object newValue)
          Basic constructor initializes the fields.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified object with this entry.
 java.lang.Object getKey()
          Get the key corresponding to this entry.
 java.lang.Object getValue()
          Get the value corresponding to this entry.
 int hashCode()
          Returns the hash code of the entry.
 java.lang.Object setValue(java.lang.Object newVal)
          Replaces the value with the specified object.
 java.lang.String toString()
          This provides a string representation of the entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

java.lang.Object key
The key. Package visible for direct manipulation.


value

java.lang.Object value
The value. Package visible for direct manipulation.

Constructor Detail

AbstractMap.BasicMapEntry

AbstractMap.BasicMapEntry(java.lang.Object newKey,
                          java.lang.Object newValue)
Basic constructor initializes the fields.

Method Detail

equals

public final boolean equals(java.lang.Object o)
Compares the specified object with this entry. Returns true only if the object is a mapping of identical key and value. In other words, this must be:
(o instanceof Map.Entry)
       && (getKey() == null ? ((HashMap) o).getKey() == null
           : getKey().equals(((HashMap) o).getKey()))
       && (getValue() == null ? ((HashMap) o).getValue() == null
           : getValue().equals(((HashMap) o).getValue()))

Specified by:
equals in interface Map.Entry

getKey

public final java.lang.Object getKey()
Get the key corresponding to this entry.

Specified by:
getKey in interface Map.Entry

getValue

public final java.lang.Object getValue()
Get the value corresponding to this entry. If you already called Iterator.remove(), the behavior undefined, but in this case it works.

Specified by:
getValue in interface Map.Entry

hashCode

public final int hashCode()
Returns the hash code of the entry. This is defined as the exclusive-or of the hashcodes of the key and value (using 0 for null). In other words, this must be:
(getKey() == null ? 0 : getKey().hashCode())
       ^ (getValue() == null ? 0 : getValue().hashCode())

Specified by:
hashCode in interface Map.Entry

setValue

public java.lang.Object setValue(java.lang.Object newVal)
Replaces the value with the specified object. This writes through to the map, unless you have already called Iterator.remove(). It may be overridden to restrict a null value.

Specified by:
setValue in interface Map.Entry

toString

public final java.lang.String toString()
This provides a string representation of the entry. It is of the form "key=value", where string concatenation is used on key and value.