View Javadoc

1   /*
2    * Copyright 2002-2006 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }