org.openbp.common.generic.taggedvalue
Class TaggedValue

java.lang.Object
  extended by org.openbp.common.generic.taggedvalue.TaggedValue
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, Copyable, Displayable

public class TaggedValue
extends java.lang.Object
implements Displayable, java.lang.Comparable, java.io.Serializable, java.lang.Cloneable, Copyable

A tagged value consists of a name and a string value.

Author:
Heiko Erhardt
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
TaggedValue()
          Default constructor.
TaggedValue(java.lang.String name, java.lang.String value)
          Value constructor.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this object.
 int compareTo(java.lang.Object o)
          Compares this object to another Object.
 void copyFrom(java.lang.Object source, int copyMode)
          Copies the values of the source object to this object.
 java.lang.String getDisplayText()
          Gets text that can be used to display this object.
 java.lang.String getName()
          Gets the name of the attribute.
 java.lang.String getValue()
          Gets the value of the attribute.
 void setName(java.lang.String name)
          Sets the name of the attribute.
 void setValue(java.lang.String value)
          Sets the value of the attribute.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaggedValue

public TaggedValue()
Default constructor.


TaggedValue

public TaggedValue(java.lang.String name,
                   java.lang.String value)
Value constructor.

Parameters:
name - Name of the attribute
value - Value of the attribute
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a clone of this object.

Specified by:
clone in interface Copyable
Overrides:
clone in class java.lang.Object
Returns:
The clone (a deep copy of this object)
Throws:
java.lang.CloneNotSupportedException - If the cloning of one of the contained members failed

copyFrom

public void copyFrom(java.lang.Object source,
                     int copyMode)
              throws java.lang.CloneNotSupportedException
Copies the values of the source object to this object.

Specified by:
copyFrom in interface Copyable
Parameters:
source - The source object. Must be of the same type as this object.
copyMode - Determines if a deep copy, a first level copy or a shallow copy is to be performed. See the constants of the org.openbp.common.generic.description.Copyable class.
Throws:
java.lang.CloneNotSupportedException - If the cloning of one of the contained objects failed

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The value

getDisplayText

public java.lang.String getDisplayText()
Gets text that can be used to display this object.

Specified by:
getDisplayText in interface Displayable
Returns:
The display text (should usually not be null)

compareTo

public int compareTo(java.lang.Object o)
Compares this object to another Object. If the object is a tagged value, it will compar the setName(java.lang.String) values of the two objects. Otherwise, it throws a ClassCastException (as TaggedValues are comparable only to other TaggedValues).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Object to be compared
Returns:
The value 0 if the argument is a string lexicographically equal to this object;
a value less than 0 if the argument is a string lexicographically greater than this object;
and a value greater than 0 if the argument is a string lexicographically less than this object.
Throws:
java.lang.ClassCastException - if the argument is not a TaggedValue.

getName

public java.lang.String getName()
Gets the name of the attribute.


setName

public void setName(java.lang.String name)
Sets the name of the attribute.


getValue

public java.lang.String getValue()
Gets the value of the attribute.


setValue

public void setValue(java.lang.String value)
Sets the value of the attribute.



Copyright © 2011. All Rights Reserved.