tribble.sql
Class FieldTypeMap

java.lang.Object
  extended by tribble.sql.FieldTypeMap

abstract class FieldTypeMap
extends java.lang.Object

Maps an SQL field (table column) to a class member variable or setter method.

This class acts as both a factory and a field mapper. As a factory, it creates a mapping object which assigns a single column from an SQL query result set row to a single member of the result object, either by calling a setter member method of the result class or by directly assigning the value to a member value of the result class.

Method getInstance() is used to find a factory object for a specific field type.

The create() methods are called from a factory object to create a mapping object for a specific query result field.

Source code:
Available at: http://david.tribble.com/src/java/tribble/sql/FieldTypeMap.java
Documentation:
Available at: http://david.tribble.com/docs/tribble/sql/FieldTypeMap.html

Since:
2008-09-04
Version:
@(#)$Revision: 1.5 $ $Date: 2008/09/06 19:06:00 $
Author:
David R. Tribble (david@tribble.com)

Copyright ©2008 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by by the United States Department of State as a terrorist, or terrorist government or agency, to use and distribute this source code provided that the original copyright notice remains present and unaltered.


Field Summary
(package private)  java.lang.reflect.Method m_setter
          Result type member setter method.
(package private)  java.lang.reflect.Field m_var
          Result type member variable.
(package private) static java.lang.String REV
           
 
Constructor Summary
FieldTypeMap()
          Default constructor.
FieldTypeMap(java.lang.reflect.Field var)
          Constructor.
FieldTypeMap(java.lang.reflect.Method meth)
          Constructor.
 
Method Summary
(package private) abstract  FieldTypeMap create(java.lang.reflect.Field var)
          Create a FieldTypeMap object for converting a specific column value from the current row of the result set and assigning it to the appropriate result class member variable.
(package private) abstract  FieldTypeMap create(java.lang.reflect.Method meth)
          Create a FieldTypeMap object for converting a specific column value from the current row of the result set and assigning it to the appropriate result class member setter method.
(package private) static FieldTypeMap getInstance(java.lang.Class type)
          Constructor.
(package private) abstract  boolean mapResultField(java.lang.Object result, int colNo, java.sql.ResultSet rset)
          Retrieve the column value from the current row of the result set and assign it to the appropriate result class member variable or setter method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
See Also:
Constant Field Values

m_var

java.lang.reflect.Field m_var
Result type member variable.


m_setter

java.lang.reflect.Method m_setter
Result type member setter method.

Constructor Detail

FieldTypeMap

FieldTypeMap()
Default constructor. Used for the factory objects derived from this class.

Since:
1.1, 2008-09-04

FieldTypeMap

FieldTypeMap(java.lang.reflect.Method meth)
Constructor. Used to create a mapping object derived from this class which assigns an SQL query result field to an object member setter method.

Parameters:
meth - Class member setter method of the result object type.
Since:
1.1, 2008-09-04

FieldTypeMap

FieldTypeMap(java.lang.reflect.Field var)
Constructor. Used to create a mapping object derived from this class which assigns an SQL query result field to an object member variable.

Parameters:
var - Class member variable of the result object type.
Since:
1.1, 2008-09-04
Method Detail

getInstance

static FieldTypeMap getInstance(java.lang.Class type)
Constructor.

Parameters:
type - A class type for a class member variable or setter method parameter.
Returns:
A factory object for creating a mapper for a field of the given type, or null if type is not a supported convertible type.
Since:
1.1, 2008-09-04

create

abstract FieldTypeMap create(java.lang.reflect.Method meth)
Create a FieldTypeMap object for converting a specific column value from the current row of the result set and assigning it to the appropriate result class member setter method.

Parameters:
meth - Class member setter method of the result object type.
Returns:
A subclass instance of class FieldTypeMap.
Since:
1.1, 2008-09-04

create

abstract FieldTypeMap create(java.lang.reflect.Field var)
Create a FieldTypeMap object for converting a specific column value from the current row of the result set and assigning it to the appropriate result class member variable.

Parameters:
var - Class member variable of the result object type.
Returns:
A subclass instance of class FieldTypeMap.
Since:
1.1, 2008-09-04

mapResultField

abstract boolean mapResultField(java.lang.Object result,
                                int colNo,
                                java.sql.ResultSet rset)
                         throws java.sql.SQLException,
                                java.lang.IllegalAccessException,
                                java.lang.reflect.InvocationTargetException
Retrieve the column value from the current row of the result set and assign it to the appropriate result class member variable or setter method.

Parameters:
result - The result object whose members are to be populated with the column values from the current result set row.
colNo - Column index to retrieve within the current result set row.
rset - Result set row, containing the column value to retrieve.
Returns:
True if the assignment succeeds, otherwise false (i.e., the column value is null).
Throws:
java.sql.SQLException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
Since:
1.1, 2008-09-04