01: package liquibase.database.template;
02:
03: import java.sql.ResultSet;
04:
05: /**
06: * An interface used by {@link JdbcTemplate} for processing rows of a
07: * {@link java.sql.ResultSet} on a per-row basis. Implementations of
08: * this interface perform the actual work of processing each row
09: * but don't need to worry about exception handling.
10: * {@link java.sql.SQLException SQLExceptions} will be caught and handled
11: * by the calling JdbcTemplate.
12: * <p/>
13: * <p>In contrast to a {@link ResultSetExtractor}, a RowCallbackHandler
14: * object is typically stateful: It keeps the result state within the
15: * object, to be available for later inspection.
16: * <p/>
17: * <p>Consider using a {@link RowMapper} instead if you need to map
18: * exactly one result object per row, assembling them into a List.
19: *
20: * @author Spring Framework
21: * @see JdbcTemplate
22: * @see RowMapper
23: * @see ResultSetExtractor
24: */
25: interface RowCallbackHandler {
26:
27: /**
28: * Implementations must implement this method to process each row of data
29: * in the ResultSet. This method should not call <code>next()</code> on
30: * the ResultSet; it is only supposed to extract values of the current row.
31: * <p>Exactly what the implementation chooses to do is up to it:
32: * A trivial implementation might simply count rows, while another
33: * implementation might build an XML document.
34: *
35: * @param rs the ResultSet to process (pre-initialized for the current row)
36: * @throws java.sql.SQLException if a SQLException is encountered getting
37: * column values (that is, there's no need to catch SQLException)
38: */
39: void processRow(ResultSet rs);
40:
41: }
|