1 /*
2 * CSVeed (https://github.com/42BV/CSVeed)
3 *
4 * Copyright 2013-2023 CSVeed.
5 *
6 * All rights reserved. This program and the accompanying materials
7 * are made available under the terms of The Apache Software License,
8 * Version 2.0 which accompanies this distribution, and is available at
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 */
11 package org.csveed.bean;
12
13 import java.util.List;
14
15 import org.csveed.api.Header;
16 import org.csveed.row.RowReader;
17
18 /**
19 * <p>
20 * The BeanReader is responsible for reading CSV rows and converting those into beans. There are two ways to initialize
21 * a {@link org.csveed.bean.BeanReaderImpl}:
22 * </p>
23 * <ul>
24 * <li>Point it to class. The {@link org.csveed.annotations} in the class are read, as is the order of the properties
25 * within the class.</li>
26 * <li>Roll your own. Pass a {@link BeanInstructions} implementation with your own configuration settings</li>
27 * </ul>
28 *
29 * @param <T>
30 * the bean class into which the rows are converted
31 */
32 public interface BeanReader<T> {
33
34 /**
35 * Reads all rows from the file and return these as beans.
36 *
37 * @return all beans read from the Reader
38 */
39 List<T> readBeans();
40
41 /**
42 * Reads a single row and returns this as a bean. The RowReader will keep track of its state.
43 *
44 * @return Bean read from the Reader
45 */
46 T readBean();
47
48 /**
49 * Returns the first readable line of the CSV file as header, regardless if useHeader==true.
50 *
51 * @return header
52 */
53 Header readHeader();
54
55 /**
56 * Returns the line from which the bean was read. Note that a line is seen as a legitimate CSV row, not necessarily
57 * a printable line (unless multi-lines are used, these values are the same).
58 *
59 * @return current line number
60 */
61 int getCurrentLine();
62
63 /**
64 * States whether the Reader is done with the file.
65 *
66 * @return true if file is finished
67 */
68 boolean isFinished();
69
70 /**
71 * Returns the underlying line reader for the bean reader.
72 *
73 * @return the underlying line reader
74 */
75 RowReader getRowReader();
76
77 /**
78 * The set of instructions for dealing with beans.
79 *
80 * @return bean instructions
81 */
82 BeanInstructions getBeanInstructions();
83
84 }