org.pf.util
Class NamedValue

java.lang.Object
  extended by org.pf.util.Association
      extended by org.pf.util.NamedValue
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, java.util.Map.Entry
Direct Known Subclasses:
MultiValueAttribute, NamedText

public class NamedValue
extends Association
implements java.lang.Comparable

This specialized Association allows only strings as key.
Access to key and value is provided by

Version:
1.1
Author:
Manfred Duchrow
See Also:
Serialized Form

Constructor Summary
NamedValue(java.lang.String name)
          Initialize the new instance with a name and a null value.
NamedValue(java.lang.String name, java.lang.Object value)
          Initialize the new instance with a name and an associated value.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for order.
 NamedValue copyNamedValue()
          Returns a copy of this object
 void key(java.lang.Object newKey)
          Sets the key of the association.
 void key(java.lang.String newKey)
          Sets the key (name) of the association.
 java.lang.String name()
          Returns the name (key) of the association.
 void name(java.lang.String newName)
          Sets the name (key) of the association.
 
Methods inherited from class org.pf.util.Association
copyAssociation, equals, getKey, getValue, hashCode, key, setValue, toString, value, value
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedValue

public NamedValue(java.lang.String name)
Initialize the new instance with a name and a null value. If name is null it will be transformed to an empty String ("").


NamedValue

public NamedValue(java.lang.String name,
                  java.lang.Object value)
Initialize the new instance with a name and an associated value. If name is null it will be transformed to an empty String ("").

Method Detail

key

public void key(java.lang.Object newKey)
Sets the key of the association. Only strings are allowed.

Overrides:
key in class Association

key

public void key(java.lang.String newKey)
Sets the key (name) of the association.

Parameters:
newKey - The new key (must not be null !)

name

public void name(java.lang.String newName)
Sets the name (key) of the association.

Parameters:
newName - The new key (must not be null !)

name

public java.lang.String name()
Returns the name (key) of the association.


compareTo

public int compareTo(java.lang.Object obj)
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.
Here the comparison will be done on the names of the NamedValue objects.

Specified by:
compareTo in interface java.lang.Comparable

copyNamedValue

public NamedValue copyNamedValue()
Returns a copy of this object