com.jenkov.mrpersister.itf
Interface IResultSetProcessor

All Known Implementing Classes:
ResultSetProcessorBase

public interface IResultSetProcessor

Represents a processor capable of initializing and processing a ResultSet, and returning a result afterwards.

In most cases it is easiest to extend the ResultSetProcessorBase which has empty implementations for all methods. Then you only have to override the methods you need special behaviour in. Typically that will be the process method.

Author:
Jakob Jenkov - Copyright 2005 Jenkov Development

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.
 

Method Detail

init

void init(java.sql.ResultSet result)
          throws java.sql.SQLException,
                 PersistenceException
Initializes the ResultSet. For instance, scrolls down to the correct first record etc.

Parameters:
result - The ResultSet to initialize.
Throws:
java.sql.SQLException - If the intialization fails.
PersistenceException - If something else fails during initialization.

process

void process(java.sql.ResultSet result,
             IDaos daos)
             throws java.sql.SQLException,
                    PersistenceException
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.

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.

getResult

java.lang.Object getResult()
                           throws PersistenceException
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.

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).