com.perdues.db.typeHandlers
Class SSNTypeHandler

java.lang.Object
  |
  +--com.perdues.db.typeHandlers.SSNTypeHandler
All Implemented Interfaces:
DBTypeHandler

public class SSNTypeHandler
extends java.lang.Object
implements DBTypeHandler

On input, this handler accepts exactly 9 digits, with any number of blanks or '-' interspersed. This does not normalize the Form entry itself, but renders only the digits into the SQL. On retrieval, it adds '-' in the format of a personal Social Security number.


Constructor Summary
SSNTypeHandler()
           
 
Method Summary
 java.lang.String renderForSQL(ColumnInfo col, Form form, java.lang.String field)
          Renders a form field given by name into an SQL literal, based on the extended type given by the ColumnInfo.
 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.
static java.lang.String toDBForm(java.lang.String ssn)
           
static java.lang.String toDisplayForm(java.lang.String ssn)
           
 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

SSNTypeHandler

public SSNTypeHandler()
Method Detail

renderForSQL

public java.lang.String renderForSQL(ColumnInfo col,
                                     Form form,
                                     java.lang.String field)
Description copied from interface: DBTypeHandler
Renders a form field given by name into an SQL literal, based on the extended type given by the ColumnInfo. The type handler may also normalize the value that is actually in the form, for example stripping leading or trailing whitespace. Returns the literal in a String.

This method takes a field name as well as a ColumnInfo so code that calls this can try different variations on the field name to allow the field name to encode the table name as well as the column name. Must return null if the logical field 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

toDBForm

public static java.lang.String toDBForm(java.lang.String ssn)

toDisplayForm

public static java.lang.String toDisplayForm(java.lang.String ssn)