kiwi.util
Class HolderObject

java.lang.Object
  extended bykiwi.util.HolderObject
Direct Known Subclasses:
BooleanHolder, DateHolder, DoubleHolder, FloatHolder, IntegerHolder, StringHolder

public abstract class HolderObject
extends java.lang.Object

An abstract base class for mutable holder objects. This base class declares a comparator method that may be used to determine the relative order of two holder objects, based on the cardinality of their respective values. It also introduces the notion of a subtype, which is an arbitrary integer that may be used to store additional information about the value stored in this holder. One possible use for the subtype field is to store a format type (such as one of the data format constants defined in the kiwi.text.FormatConstants interface); such information can be useful to tree and table cell renderers, for example.

Author:
Mark Lindner, PING Software Group
See Also:
kiwi.text.FormatConstants

Field Summary
protected  int subtype
          The subtype for the value stored by this holder.
 
Constructor Summary
protected HolderObject()
          Construct a new HolderObject.
protected HolderObject(int subtype)
          Construct a new HolderObject with the specified subtype.
 
Method Summary
abstract  int compareTo(HolderObject other)
          Compare the value in this HolderObject to the value in another HolderObject.
 int getSubtype()
          Get the subtype for the value stored by this holder.
 void setSubtype(int subtype)
          Set the subtype for the value stored by this holder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subtype

protected int subtype
The subtype for the value stored by this holder.

Constructor Detail

HolderObject

protected HolderObject()
Construct a new HolderObject.


HolderObject

protected HolderObject(int subtype)
Construct a new HolderObject with the specified subtype.

Parameters:
subtype - The subtype.
Method Detail

compareTo

public abstract int compareTo(HolderObject other)
Compare the value in this HolderObject to the value in another HolderObject. It is assumed that the two values are of the same type (hence that the holders are also of the same type).

Parameters:
other - The HolderObject to compare against.
Returns:
-1 if this object is "less than" the other object; 1 if this object is "greater than" the other object, and 0 if the objects are "equal."

setSubtype

public void setSubtype(int subtype)
Set the subtype for the value stored by this holder.

Parameters:
subtype - The new subtype.

getSubtype

public int getSubtype()
Get the subtype for the value stored by this holder.

Returns:
The current subtype. The default subtype is 0.