org.jurvis.util
Class JvNamedValue

java.lang.Object
  extended by org.jurvis.util.JvNamedValue
All Implemented Interfaces:
Serializable, Comparable

public class JvNamedValue
extends Object
implements Serializable, Comparable

A class representing a value and its name.

Author:
Neil W. Weber
See Also:
Serialized Form

Constructor Summary
JvNamedValue(String name, Object value)
          Construct a new JvNamedValue object with the given name and value.
 
Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order.
 boolean equals(Object o)
          Compares the specified object with this entry for equality.
 String getName()
          Returns the name of the value
 Object getValue()
          Returns the value.
 int hashCode()
          Returns the hash code value for this map entry.
 void setValue(Object value)
          Replaces the value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JvNamedValue

public JvNamedValue(String name,
                    Object value)
Construct a new JvNamedValue object with the given name and value.

Parameters:
name - the name of the value
value - the value
Throws:
IllegalArgumentException - if the name is null or empty
Method Detail

getName

public String getName()
Returns the name of the value

Returns:
the name of the value

getValue

public Object getValue()
Returns the value.

Returns:
the value

setValue

public void setValue(Object value)
Replaces the value.

Parameters:
value - the new value

equals

public boolean equals(Object o)
Compares the specified object with this entry for equality. Returns true if the given object has the same name.

Overrides:
equals in class Object
Parameters:
o - object to be compared for equality with this named value
Returns:
true if the specified object is equal to this named value

hashCode

public int hashCode()
Returns the hash code value for this map entry. The hash code of a named value is just the hash code of the name;

Overrides:
hashCode in class Object
Returns:
the hash code value for this map entry.

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this Object.


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.