com.taursys.model
Interface CheckboxModel

All Superinterfaces:
TextModel
All Known Implementing Classes:
DefaultCheckboxModel

public interface CheckboxModel
extends TextModel

CheckboxModel is a model which maintains 2 states: selected or unselected. The CheckboxModel provides access to the internal "state" or value via the setText, getText, setSelected and isSelected methods.

The setSelected should result in either the selectedValue (true) or unselectedValue (false) value being parsed and stored in the valueHolder. The isSelected method should indicate whether or not the value stored in the valueHolder equals (or represents) the selectedValue.

It is the responsibility of the set/getText methods to provide any required parsing or formatting as they transform the value between its String representation and actual internal representation (int, Date, boolean, etc). There are 2 properties which govern the parse/format process: format and formatPattern. These use the standard java.text.Format objects and patterns.

If the setText method is invoked directly, the value passed to it must be equal to either the selectedValue or unselectedValue, otherwise an UnknownStateValueException will occur.

This model supports null as the "unselected" state. This is accomplished by setting the unselectedValue to blank (""). A initial null value in the value holder is treated as unselected by the isSelected and getText methods.

Version:
1.0
Author:
Marty Phelan

Method Summary
 java.lang.String getSelectedValue()
          Get the value used to indicate a selected state.
 java.lang.String getText()
          Returns text/display value of current state.
 java.lang.String getUnselectedValue()
          Get the value used to indicate an unselected state.
 boolean isSelected()
          Gets the current state as selected(true) or unselected(false).
 void setSelected(boolean newSelected)
          Sets the current state as selected(true) or unselected(false).
 void setSelectedValue(java.lang.String newSelectedValue)
          Set the value used to indicate a selected state.
 void setText(java.lang.String value)
          Sets the current state by matching the given value to the selected or unselected values.
 void setUnselectedValue(java.lang.String newUnselectedValue)
          Set the value used to indicate an unselected state.
 
Methods inherited from interface com.taursys.model.TextModel
addChangeListener, getFormat, getFormatPattern, getPropertyName, getValueHolder, removeChangeListener, setFormat, setFormatPattern, setPropertyName, setValueHolder
 

Method Detail

getText

public java.lang.String getText()
                         throws UnknownStateValueException,
                                ModelException
Returns text/display value of current state. If the underlying valueHolder value is null, the unselectedValue will be returned.

Specified by:
getText in interface TextModel
Throws:
UnknownStateValueException - if the given value does not match a known state text value.
ModelException - if problem while matching properties of valueHolder object to list object.

setText

public void setText(java.lang.String value)
             throws UnknownStateValueException,
                    ModelException
Sets the current state by matching the given value to the selected or unselected values.

Specified by:
setText in interface TextModel
Throws:
UnknownStateValueException - if the given value does not match a known state text value.
ModelException - if problem while setting properties of object in valueHolder.

setSelected

public void setSelected(boolean newSelected)
                 throws ModelException
Sets the current state as selected(true) or unselected(false).

Throws:
ModelException - if problem while setting properties of object in valueHolder.

isSelected

public boolean isSelected()
                   throws UnknownStateValueException,
                          ModelException
Gets the current state as selected(true) or unselected(false).

Throws:
UnknownStateValueException - if the internal value does not match a known state text value.
ModelException - if problem while setting properties of object in valueHolder.

setSelectedValue

public void setSelectedValue(java.lang.String newSelectedValue)
Set the value used to indicate a selected state.

Parameters:
newSelectedValue - the value used to indicate a selected state.

getSelectedValue

public java.lang.String getSelectedValue()
Get the value used to indicate a selected state.

Returns:
the value used to indicate a selected state.

setUnselectedValue

public void setUnselectedValue(java.lang.String newUnselectedValue)
Set the value used to indicate an unselected state.

Parameters:
newUnselectedValue - the value used to indicate a unselected state.

getUnselectedValue

public java.lang.String getUnselectedValue()
Get the value used to indicate an unselected state.

Returns:
the value used to indicate a unselected state.


Copyright © 2007 Martin T Phelan. All Rights Reserved.