View Javadoc
1   package org.csveed.bean;
2   
3   import java.util.List;
4   
5   import org.csveed.api.Header;
6   import org.csveed.row.RowReader;
7   
8   /**
9   * <p>
10  *     The BeanReader is responsible for reading CSV rows and converting those into beans. There are two
11  *     ways to initialize a {@link org.csveed.bean.BeanReaderImpl}:
12  * </p>
13  *
14  * <ul>
15  *     <li>Point it to class. The {@link org.csveed.annotations} in the class are read, as is the order
16  *         of the properties within the class.</li>
17  *     <li>Roll your own. Pass a {@link BeanInstructions} implementation with your
18  *         own configuration settings</li>
19  * </ul>
20  *
21  * @param <T> the bean class into which the rows are converted
22  * @author Robert Bor
23  */
24  public interface BeanReader<T> {
25  
26      /**
27      * Reads all rows from the file and return these as beans.
28      * @return all beans read from the Reader
29      */
30      List<T> readBeans();
31  
32      /**
33      * Reads a single row and returns this as a bean. The RowReader will keep track of its state.
34      * @return Bean read from the Reader
35      */
36      T readBean();
37  
38      /**
39      * Returns the first readable line of the CSV file as header, regardless if useHeader==true.
40      * @return header
41      */
42      Header readHeader();
43  
44      /**
45      * Returns the line from which the bean was read. Note that a line is seen as a legitimate CSV row, not
46      * necessarily a printable line (unless multi-lines are used, these values are the same).
47      * @return current line number
48      */
49      int getCurrentLine();
50  
51      /**
52      * States whether the Reader is done with the file
53      * @return true if file is finished
54      */
55      boolean isFinished();
56  
57      /**
58      * Returns the underlying line reader for the bean reader
59      * @return the underlying line reader
60      */
61      RowReader getRowReader();
62  
63      /**
64      * The set of instructions for dealing with beans
65      * @return bean instructions
66      */
67      BeanInstructions getBeanInstructions();
68  
69  }