com.taursys.model
Interface TextModel

All Known Subinterfaces:
CheckboxModel, SelectModel
All Known Implementing Classes:
DefaultCheckboxModel, DefaultSelectModel, DefaultTextModel

public interface TextModel

The TextModel is a foundation model for MapperXML. The TextModel provides access to the internal "state" or value via the getText and setText methods. It is the responsibility of theses methods to provide any required parsing or formatting as they transform the value between its String representation and actual internal representation (int, Date, BigDecimal, etc). There are 2 properties which govern the parse/format process: format and formatPattern. These use the standard java.text.Format objects and patterns.

The TextModel uses a ValueHolder to hold the actual "state" or value. A ValueHolder can provide storage for any data type. Implementations of the TextModel can create and use their own internal ValueHolder. They can also be assigned an external ValueHolder to use. Multiple TextModels can share the same ValueHolder. A specific property of the ValueHolder host object can also be targeted. The target property can be specified by setting the propertyName property. (Note: the ValueHolder itself must be one that actually supports access to individual properties for this feature to work, otherwise the propertyName setting is ignored).

The TextModel also provides notification to ChangeListeners whenever the "state" or value changes. Interested listeners can register or unregister to receive notification of ChangeEvents by using the addChangeListener or removeChangeListener methods.


Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds the specified change listener to receive change events from this text model.
 java.text.Format getFormat()
          Returns the Format to be used by the model or null if undefined.
 java.lang.String getFormatPattern()
          Returns the pattern used by the format
 java.lang.String getPropertyName()
          Returns the ValueObject's propertyName where the model value is stored.
 java.lang.String getText()
          Returns the model value as a String (using Format if defined)
 ValueHolder getValueHolder()
          Returns the valueHolder used by the model for storing the value.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes the specified change listener so that it no longer receives change events from this text model.
 void setFormat(java.text.Format format)
          Sets the Format to be used by the model or null if undefined.
 void setFormatPattern(java.lang.String newPattern)
          Sets the pattern used by the format
 void setPropertyName(java.lang.String newPropertyName)
          Sets the ValueObject's propertyName where the model value is stored.
 void setText(java.lang.String text)
          Parses the given String (using Format if defined) and sets model value.
 void setValueHolder(ValueHolder newValueHolder)
          Sets the valueHolder used by the model for storing the value.
 

Method Detail

getText

public java.lang.String getText()
                         throws ModelException
Returns the model value as a String (using Format if defined)

Throws:
ModelException

setText

public void setText(java.lang.String text)
             throws ModelException
Parses the given String (using Format if defined) and sets model value.

Throws:
ModelException

getFormat

public java.text.Format getFormat()
Returns the Format to be used by the model or null if undefined.


setFormat

public void setFormat(java.text.Format format)
Sets the Format to be used by the model or null if undefined.


getFormatPattern

public java.lang.String getFormatPattern()
Returns the pattern used by the format


setFormatPattern

public void setFormatPattern(java.lang.String newPattern)
Sets the pattern used by the format


setValueHolder

public void setValueHolder(ValueHolder newValueHolder)
Sets the valueHolder used by the model for storing the value.


getValueHolder

public ValueHolder getValueHolder()
Returns the valueHolder used by the model for storing the value.


setPropertyName

public void setPropertyName(java.lang.String newPropertyName)
Sets the ValueObject's propertyName where the model value is stored.


getPropertyName

public java.lang.String getPropertyName()
Returns the ValueObject's propertyName where the model value is stored.


removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes the specified change listener so that it no longer receives change events from this text model. Change events are generated whenever the contents of the value holder change.


addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds the specified change listener to receive change events from this text model. Change events are generated whenever the contents of the value holder change.



Copyright © 2007 Martin T Phelan. All Rights Reserved.