Class DbRowProcessor
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
DatabaseTaskOptions.ProcessTaskOption,DatabaseTasks.ProcessTask,DatabaseUsers.ListDatabaseRoles,DatabaseUsers.ListDatabaseUsers,DatabaseUsers.ProcessVerifyCredentials,DatabaseUsers.RoleFetcher,DbBeanFetcher,ProcessSessionValidity
fetch method of a
DbQueryManager requires an instance of a
DbRowProcessor and calls its processRow
method each time it is called.
The DbRowProcessor instance can then work with the result set
and extract all needed data. It is free to implement any logic to be
able to return the retrieved data in an acceptable form to the user.
A class that extends DbRowProcessor can for example take a
Template instance as the argument of its constructor and
progressively fill in each resulting row in an HTML table. This, without
having to maintain the query results in memory to be able to provide it to a
separate method which is responsible for the handling of the output. Using a
DbRowProcessor thus allows for perfect separation and
abstraction of result processing without having to be burdened with possible
large memory usage or large object allocation.
- Since:
- 1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Simply clones the instance with the default clone method since this class contains no object member variables.abstract booleanprocessRow(ResultSet resultSet) This method has to be implemented by each class that extends theDbRowProcessorclass.final booleanIndicates whether the processing of the row was successful.
-
Constructor Details
-
DbRowProcessor
public DbRowProcessor()
-
-
Method Details
-
processRow
This method has to be implemented by each class that extends theDbRowProcessorclass. It has to contain all the logic that should be executed for each row of a result set.- Parameters:
resultSet- theResultSetinstance that was provided to theDbQueryManager'sfetchmethod.- Returns:
trueif the processing is considered successful; orfalseif the processing is considered failed.Note: this return value is purely indicative and unless the user does checks with the
wasSuccessful()method, it will have no influence on anything.- Throws:
SQLException- when a database error occurs, it's thus not necessary to catch all the possibleSQLExceptions inside this method. They'll be caught higher up and be transformed inDatabaseExceptions.- Since:
- 1.0
- See Also:
-
wasSuccessful
public final boolean wasSuccessful()Indicates whether the processing of the row was successful.- Returns:
trueif the processing was successful; orfalseif the processing was unsuccessful.- Since:
- 1.0
-
clone
Simply clones the instance with the default clone method since this class contains no object member variables.
-