com.jenkov.mrpersister.impl
Class ResultSetProcessorBase

java.lang.Object
  extended by com.jenkov.mrpersister.impl.ResultSetProcessorBase
All Implemented Interfaces:
IResultSetProcessor

public class ResultSetProcessorBase
extends java.lang.Object
implements IResultSetProcessor

Author:
Jakob Jenkov - Copyright 2005 Jenkov Development

Field Summary
protected  java.lang.Object result
           
 
Constructor Summary
ResultSetProcessorBase()
           
 
Method Summary
 java.lang.Object getResult()
          Returns the result of the total processing.
 void init(java.sql.ResultSet result)
          Initializes the ResultSet.
 void process(java.sql.ResultSet result, IDaos daos)
          Processes a record in the ResultSet.
protected  void setResult(java.lang.Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

protected java.lang.Object result
Constructor Detail

ResultSetProcessorBase

public ResultSetProcessorBase()
Method Detail

init

public void init(java.sql.ResultSet result)
          throws java.sql.SQLException,
                 PersistenceException
Description copied from interface: IResultSetProcessor
Initializes the ResultSet. For instance, scrolls down to the correct first record etc.

Specified by:
init in interface IResultSetProcessor
Parameters:
result - The ResultSet to initialize.
Throws:
java.sql.SQLException - If the intialization fails.
PersistenceException - If something else fails during initialization.

process

public void process(java.sql.ResultSet result,
                    IDaos daos)
             throws java.sql.SQLException,
                    PersistenceException
Description copied from interface: IResultSetProcessor
Processes a record in the ResultSet. For instance reads the column values into a List, Map, or some other object. This method is called for each record in the ResultSet.

Specified by:
process in interface IResultSetProcessor
Parameters:
result - The ResultSet to process the record of.
daos - The IDaos instance where the IJdbcDao that called this method belongs to. Use it to, for instance, read an object from the current record using the IGenericDao.read(objectMappingKey, ResultSet).
Throws:
java.sql.SQLException - If something fails in the driver during the processing of the current record.
PersistenceException - If something else fails during the processing.

setResult

protected void setResult(java.lang.Object object)

getResult

public java.lang.Object getResult()
                           throws PersistenceException
Description copied from interface: IResultSetProcessor
Returns the result of the total processing. For instance, if the process method reads records into object and add them to a List, this method will return the List.

Specified by:
getResult in interface IResultSetProcessor
Returns:
The result of the total processing of the ResultSet.
Throws:
PersistenceException - If for some reason the returning of the result fails. This could be if the getResult() method builds a complex object from records read, and that this somehow fails (missing records, or invalid values).