com.perdues.db.typeHandlers
Class StringTypeHandler

java.lang.Object
  |
  +--com.perdues.db.typeHandlers.StringTypeHandler
All Implemented Interfaces:
DBTypeHandler
Direct Known Subclasses:
EmailTypeHandler, IntegerTypeHandler, NumericTypeHandler, PhoneTypeHandler

public class StringTypeHandler
extends java.lang.Object
implements DBTypeHandler

This handler generally treats missing fields of the Form as empty Strings. It does not treat them as database nulls. When validating, it also normalizes the Form value by trimming leading and trailing whitespace. If the field is marked as "required" in the schema, an missing or empty normalized value is not valid.


Constructor Summary
StringTypeHandler()
           
 
Method Summary
 java.lang.String renderForSQL(ColumnInfo col, Form form, java.lang.String field)
          Renders an SQL string literal for the field, or null if it is not present in the Form.
 void storeToForm(ColumnInfo col, java.sql.ResultSet rs, int rsField, Form form, java.lang.String field)
          Stores the value of the numbered field of the ResultSet into the given field of the form.
 void storeToForm(ColumnInfo col, java.sql.ResultSet rs, java.lang.String rsField, Form form, java.lang.String field)
          Stores the value of the named field of the ResultSet into the given field of the form.
 void validate(ColumnInfo col, Form form, java.util.Hashtable errs)
          Validates a Form field based on type information from the extended database schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTypeHandler

public StringTypeHandler()
Method Detail

renderForSQL

public java.lang.String renderForSQL(ColumnInfo col,
                                     Form form,
                                     java.lang.String field)
Renders an SQL string literal for the field, or null if it is not present in the Form.
Specified by:
renderForSQL in interface DBTypeHandler

storeToForm

public void storeToForm(ColumnInfo col,
                        java.sql.ResultSet rs,
                        java.lang.String rsField,
                        Form form,
                        java.lang.String field)
                 throws java.sql.SQLException
Description copied from interface: DBTypeHandler
Stores the value of the named field of the ResultSet into the given field of the form.
Specified by:
storeToForm in interface DBTypeHandler

storeToForm

public void storeToForm(ColumnInfo col,
                        java.sql.ResultSet rs,
                        int rsField,
                        Form form,
                        java.lang.String field)
                 throws java.sql.SQLException
Description copied from interface: DBTypeHandler
Stores the value of the numbered field of the ResultSet into the given field of the form.
Specified by:
storeToForm in interface DBTypeHandler

validate

public void validate(ColumnInfo col,
                     Form form,
                     java.util.Hashtable errs)
Description copied from interface: DBTypeHandler
Validates a Form field based on type information from the extended database schema. For any validation problems, the method should add entries to errors, a Hashtable with String keys that are fully-qualified database field names and values that are String messages describing what is required for the form field. A validator is required to check validity as fully as practical. This validation is intended for data entry, to check as far as possible that each data item can be properly stored into the database.

TableInfo.validateRecord calls this for every column of the table so it can accommodate "virtual" form fields that don't map 1-to-1 onto columns.

Specified by:
validate in interface DBTypeHandler