sky.engine.field
Class SelectionField

java.lang.Object
  extended bysky.engine.field.BaseField
      extended bysky.engine.field.IntField
          extended bysky.engine.field.SelectionField
All Implemented Interfaces:
Field

public class SelectionField
extends IntField
implements Field


Field Summary
protected  boolean _isFirstInvalid
          True, if the first value from the specified list of values can also be selected.
protected  boolean _multiple
          True, if multiple values can be selected.
protected  java.util.ArrayList _options
          Actual list of values from which a subset of values can be selected.
protected  int _size
          Number of possible values.
 
Fields inherited from class sky.engine.field.BaseField
_aliases, _default, _defaulted, _maxlen, _minlen, _name, _required, _values, _vislen, STRINGS
 
Constructor Summary
SelectionField(java.lang.String name, boolean required)
          Constructor
SelectionField(java.lang.String name, boolean required, java.lang.String dflt, boolean isFirstInvalid, int size, boolean multiple)
          Constructor
 
Method Summary
 void addValue(java.lang.String value)
          Add a selected value to this field.
 java.lang.String checkValue(java.lang.String value)
          Check if input string is a valid value.
 void destory()
          Destroy this field.
protected  boolean hasValue(java.lang.String value)
          Determine if the input string contains a valid value for this field.
 void populateOptions()
          Override this method to fill the list of possible values.
 java.lang.String toHTML()
          Generate HTML code for a GUI component of this field.
 
Methods inherited from class sky.engine.field.IntField
getIntData
 
Methods inherited from class sky.engine.field.BaseField
addAlias, clear, getAliases, getData, getDataSize, getHTMLData, getName, getRequired, getSQLData, getStringData, hasAliases, removeAliases, removeValues, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sky.engine.field.Field
addAlias, clear, getAliases, getDataSize, getHTMLData, getName, getRequired, getSQLData, getStringData, hasAliases, removeAliases, removeValues, toString
 

Field Detail

_size

protected int _size
Number of possible values.


_options

protected java.util.ArrayList _options
Actual list of values from which a subset of values can be selected.


_multiple

protected boolean _multiple
True, if multiple values can be selected. False, if only one value can be selected.


_isFirstInvalid

protected boolean _isFirstInvalid
True, if the first value from the specified list of values can also be selected. In many cases the first item may just be a label and hence cannot be selected as a value.

Constructor Detail

SelectionField

public SelectionField(java.lang.String name,
                      boolean required)
               throws ErrorMessage
Constructor

Parameters:
name - field name
required - true if field value is required; else, false.
Throws:
ErrorMessage - if there is a problem in constructing this object.

SelectionField

public SelectionField(java.lang.String name,
                      boolean required,
                      java.lang.String dflt,
                      boolean isFirstInvalid,
                      int size,
                      boolean multiple)
               throws ErrorMessage
Constructor

Parameters:
name - field name
required - true if field value(s) are required; else, false.
dflt - default value if a value is not specified by the user.
isFirstInvalid - Is the first item from the list of possible values a valid value.
size - Maximum number of possible values.
multiple - true if multiple values can be selected; otherwise, false.
Throws:
ErrorMessage - if there is a problem in constructing this object.
Method Detail

populateOptions

public void populateOptions()
                     throws ErrorMessage
Override this method to fill the list of possible values.

Throws:
ErrorMessage - if there is any problem.

hasValue

protected boolean hasValue(java.lang.String value)
Determine if the input string contains a valid value for this field.

Overrides:
hasValue in class BaseField
Returns:
true if input string contains valid value; else, false.

checkValue

public java.lang.String checkValue(java.lang.String value)
                            throws ErrorMessage
Check if input string is a valid value. Override this method in your implementation. This method should check if the input string is actually one of the values specified in the arraylist of possible values.

Specified by:
checkValue in interface Field
Overrides:
checkValue in class IntField
Returns:
the original input string if the input string was a valid value.
Throws:
ErrorMessage - if the input string is not a valid value.

addValue

public void addValue(java.lang.String value)
              throws ErrorMessage
Add a selected value to this field. This method calls checkValue method to validate the input string value.

Specified by:
addValue in interface Field
Overrides:
addValue in class IntField
Parameters:
value - input string that represents an integer value.
Throws:
ErrorMessage - if there is any problem in adding input string as value.

toHTML

public java.lang.String toHTML()
Generate HTML code for a GUI component of this field.

Specified by:
toHTML in interface Field
Overrides:
toHTML in class BaseField
Returns:
HTML code.

destory

public void destory()
Destroy this field.

Specified by:
destory in interface Field
Overrides:
destory in class BaseField