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.row;
12
13 import java.util.List;
14
15 import org.csveed.api.Header;
16 import org.csveed.api.Row;
17
18 /**
19 * LineReaders reads rows from the CSV file and returns those all at once, or one by one if desired.
20 */
21 public interface RowReader {
22
23 /**
24 * Reads all rows from the file and returns them as a List. After this, the RowReader will be finished
25 *
26 * @return all Rows read from the Reader
27 */
28 List<Row> readRows();
29
30 /**
31 * Reads a single row from the file and returns this. The RowReader will keep track of its state.
32 *
33 * @return Row read from the Reader
34 */
35 Row readRow();
36
37 /**
38 * Returns the line from which the row was read. Note that a line is seen as a legitimate CSV row, not necessarily a
39 * printable line (unless multi-lines are used, these values are the same).
40 *
41 * @return current line number
42 */
43 int getCurrentLine();
44
45 /**
46 * States whether the Reader is done with the file.
47 *
48 * @return true if file is finished
49 */
50 boolean isFinished();
51
52 /**
53 * Returns the first readable line of the CSV file as header, regardless if useHeader==true.
54 *
55 * @return header
56 */
57 Header readHeader();
58
59 /**
60 * Returns the header of the CSV file. Only possibly returns a value when useHeader==true
61 *
62 * @return header or null if the useHeader==false
63 */
64 Header getHeader();
65
66 /**
67 * The set of instructions for dealing with rows.
68 *
69 * @return row instructions
70 */
71 RowInstructions getRowInstructions();
72
73 }