org.speakright.core
Class ModelItemBase

java.lang.Object
  extended by org.speakright.core.ModelItemBase
All Implemented Interfaces:
java.io.Serializable, IModelItem
Direct Known Subclasses:
Model.BooleanItem, Model.BooleanItem, Model.IntItem, Model.IntItem, Model.StringItem, Model.StringItem, SRODateItem, SROOrdinalItem, SROStringItem, SROSubjectItem, TestListNavigator.MyFlightItem, TestRender.MyItem

public abstract class ModelItemBase
extends java.lang.Object
implements IModelItem, java.io.Serializable

Base class for model items. Each model item class defines get,set, and clear. The recommended way to get a model item's value is using its formatter. getFormatter()->formatItem(). Do not use toString (may cause stack overflow since DefaultItemFormatter uses toString as well!)

Author:
Ian Rae
See Also:
Serialized Form

Field Summary
protected  IItemFormatter m_formatter
           
protected  boolean m_isSet
           
protected  java.lang.String m_name
           
 
Constructor Summary
ModelItemBase()
           
 
Method Summary
 java.lang.String getFormattedItem()
          convenience function, equivalent to getFormatter->formatItem();
 IItemFormatter getFormatter()
          get the current formatter for rendering this item into a prompt.
 boolean isSet()
          has the model's set method been called.
protected  void log(java.lang.String s)
           
 void setFormatter(IItemFormatter formatter)
          Set the formatter of this item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.speakright.core.IModelItem
clear, rawValue
 

Field Detail

m_isSet

protected boolean m_isSet

m_formatter

protected IItemFormatter m_formatter

m_name

protected java.lang.String m_name
Constructor Detail

ModelItemBase

public ModelItemBase()
Method Detail

isSet

public boolean isSet()
has the model's set method been called.

Specified by:
isSet in interface IModelItem
Returns:
whether the item has been set.

getFormatter

public IItemFormatter getFormatter()
Description copied from interface: IModelItem
get the current formatter for rendering this item into a prompt. Items must initialize themselves with a default renderer (which may simply return toString)

Specified by:
getFormatter in interface IModelItem
Returns:

getFormattedItem

public java.lang.String getFormattedItem()
convenience function, equivalent to getFormatter->formatItem();

Returns:

setFormatter

public void setFormatter(IItemFormatter formatter)
Description copied from interface: IModelItem
Set the formatter of this item.

Specified by:
setFormatter in interface IModelItem
Parameters:
formatter - A formatter.

log

protected void log(java.lang.String s)