org.pf.util
Class NamedValue<V>

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

public class NamedValue<V>
extends Association<java.lang.String,V>
implements java.lang.Comparable

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

Version:
2.0
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, V 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.String newKey)
          Sets the new key.
 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,
                  V 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.String newKey)
Sets the new key. A null key will be ignored.

Overrides:
key in class Association<java.lang.String,V>

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