org.araneaframework.backend.list.helper
Class BaseListSqlHelper.BeanResultReader

java.lang.Object
  extended byorg.araneaframework.backend.list.helper.BaseListSqlHelper.BeanResultReader
All Implemented Interfaces:
ResultReader, RowCallbackHandler
Enclosing class:
BaseListSqlHelper

public class BaseListSqlHelper.BeanResultReader
extends Object
implements ResultReader

Resultset reader that uses beanToResultSetMapping in ListSqlHelper to construct a given type of Bean list.

Author:
Rein Raudjärv

Field Summary
protected  BeanMapper beanMapper
           
protected  String[] columnNames
           
protected  String[] fieldNames
           
protected  Class[] fieldTypes
           
protected  Class itemClass
           
protected  List results
           
 
Constructor Summary
BaseListSqlHelper.BeanResultReader(Class itemClass)
           
 
Method Summary
protected  Object createBean()
           
 List getResults()
          Returns the results.
 void init()
          Cache all the field names, field types and column names to be used for each row.
 void processRow(ResultSet rs)
          Processes ResultSet row passing it with the new Bean instance to readBeanFields(ResultSet, Object) method.
protected  void readBeanField(ResultSet rs, String rsColumn, Object bean, String beanField, Class fieldType)
          Reads the bean field from ResultSet.
protected  void readBeanFields(ResultSet rs, Object bean)
          Reads the bean from ResultSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemClass

protected Class itemClass

results

protected List results

beanMapper

protected BeanMapper beanMapper

fieldNames

protected String[] fieldNames

fieldTypes

protected Class[] fieldTypes

columnNames

protected String[] columnNames
Constructor Detail

BaseListSqlHelper.BeanResultReader

public BaseListSqlHelper.BeanResultReader(Class itemClass)
Parameters:
itemClass - Bean type.
Method Detail

init

public void init()
Cache all the field names, field types and column names to be used for each row.


processRow

public void processRow(ResultSet rs)
Processes ResultSet row passing it with the new Bean instance to readBeanFields(ResultSet, Object) method.

Specified by:
processRow in interface RowCallbackHandler
Parameters:
rs - the ResultSet to process

createBean

protected Object createBean()
Returns:
new Bean instance.

readBeanFields

protected void readBeanFields(ResultSet rs,
                              Object bean)
Reads the bean from ResultSet. Implementations may override it to read beans in a custom way.

Parameters:
rs - ResultSet containing the results of database query.
bean - bean to read.

readBeanField

protected void readBeanField(ResultSet rs,
                             String rsColumn,
                             Object bean,
                             String beanField,
                             Class fieldType)
Reads the bean field from ResultSet. Implementations may override it to read bean fields in a custom way. A usual situation would be when a bean field is read from more than one ResultSet field.

Parameters:
rs - ResultSet containing the results of database query.
rsColumn - name of the result set column to read from.
bean - bean to read.
beanField - name of the bean field to read to.
fieldType - type of the bean field.

getResults

public List getResults()
Returns the results.

Specified by:
getResults in interface ResultReader