com.limegroup.gnutella.util
Class KeyValue

java.lang.Object
  extended bycom.limegroup.gnutella.util.KeyValue
All Implemented Interfaces:
java.util.Map.Entry

public class KeyValue
extends java.lang.Object
implements java.util.Map.Entry

This class stores a pair of a property key, and its corresponding value. It implements Map.Entry interface, so that other classes can use it in the same way, there's no backing Map though, unless stated otherwise.


Constructor Summary
KeyValue()
          Default Constructor
KeyValue(java.lang.Object key, java.lang.Object value)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the instance of this class with another instance.
 java.lang.Object getKey()
          Returns the key(key) in the key value pair
 java.lang.Object getValue()
          Returns the value corresponding to this entry.
 int hashCode()
          Returns the hash code value for this map entry.
 void set(java.lang.Object key, java.lang.Object value)
          Sets the key and value fields
 java.lang.Object setValue(java.lang.Object value)
          Replaces the value corresponding to this entry with the specified value.
 java.lang.String toString()
          Converts the key Value pair into a string representation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyValue

public KeyValue(java.lang.Object key,
                java.lang.Object value)
Constructor

Parameters:
key - key of the property
value - corresponding value of the property

KeyValue

public KeyValue()
Default Constructor

Method Detail

set

public void set(java.lang.Object key,
                java.lang.Object value)
Sets the key and value fields

Parameters:
key - key of the property
value - corresponding value of the property

equals

public boolean equals(java.lang.Object o)
Compares the instance of this class with another instance. Returns true, if the key field is same, regardless of the value.

Specified by:
equals in interface java.util.Map.Entry
Parameters:
o - Another instance of the KeyValue class to which it has to be compared.

toString

public java.lang.String toString()
Converts the key Value pair into a string representation


getKey

public java.lang.Object getKey()
Returns the key(key) in the key value pair

Specified by:
getKey in interface java.util.Map.Entry
Returns:
the key(key) in the key value pair

getValue

public java.lang.Object getValue()
Returns the value corresponding to this entry.

Specified by:
getValue in interface java.util.Map.Entry
Returns:
the value corresponding to this entry.

setValue

public java.lang.Object setValue(java.lang.Object value)
Replaces the value corresponding to this entry with the specified value.

Specified by:
setValue in interface java.util.Map.Entry
Parameters:
value - new value to be stored in this entry.
Returns:
old value corresponding to the entry.

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.

Specified by:
hashCode in interface java.util.Map.Entry
Returns:
the hash code value for this map entry.
See Also:
Object.hashCode(), Object.equals(Object), equals(Object)