com.perdues.db.typeHandlers
Class IDTypeHandler

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

public class IDTypeHandler
extends NumericTypeHandler
implements DBTypeHandler

Type handler for the ID type, integers starting with 1, used as unique IDs for rcords.. Checks that the field contains numerics only.


Constructor Summary
IDTypeHandler()
           
 
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 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 com.perdues.db.typeHandlers.NumericTypeHandler
numericValidator
 
Methods inherited from class com.perdues.db.typeHandlers.StringTypeHandler
storeToForm, storeToForm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.perdues.db.DBTypeHandler
storeToForm, storeToForm
 

Constructor Detail

IDTypeHandler

public IDTypeHandler()
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
Overrides:
renderForSQL in class StringTypeHandler

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
Overrides:
validate in class NumericTypeHandler