1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gageot.excel.core;
18
19 import java.io.IOException;
20
21 import org.apache.poi.hssf.usermodel.HSSFSheet;
22 import org.springframework.dao.DataAccessException;
23
24 /***
25 * Callback interface used by ExcelTemplate's query methods.
26 * Implementations of this interface perform the actual work of extracting
27 * results, but don't need to worry about exception handling. IOExceptions
28 * will be caught and handled correctly by the ExcelTemplate class.
29 *
30 * <p>This interface is mainly used within the ExcelTemplate framework.
31 * A RowCallbackHandler is usually a simpler choice for HSSFSheet processing.
32 *
33 * <p>Note: In contrast to a RowCallbackHandler, a SheetExtractor object
34 * is typically stateless and thus reusable, as long as it doesn't access
35 * stateful resources or keep result state within the object.
36 *
37 * @author David Gageot
38 * @see ExcelTemplate
39 * @see RowCallbackHandler
40 */
41 public interface SheetExtractor {
42
43 /***
44 * Implementations must implement this method to process
45 * all rows in the HSSFSheet.
46 * @param sheet HSSFSheet to extract data from.
47 * @return an arbitrary result object, or <code>null</code> if none
48 * (the extractor will typically be stateful in the latter case).
49 * @throws IOException if a IOException is encountered getting column
50 * values or navigating (that is, there's no need to catch IOException)
51 * @throws DataAccessException in case of custom exceptions
52 */
53 Object extractData (HSSFSheet sheet) throws IOException, DataAccessException;
54 }