View Javadoc
1   package org.csveed.api;
2   
3   import org.csveed.report.RowReport;
4   
5   /**
6   * A Row is a line of content read from the CSV file. Note that a Row is never a Header. Rows can be iterated
7   * which yields the individual cells as Strings.
8   * @author Robert Bor
9   */
10  public interface Row extends Iterable<String> {
11  
12      /**
13      * The number of columns in the Row.
14      * @return number of columns
15      */
16      int size();
17  
18      /**
19      * Gets the content of the cell on the basis of its cell position within the Row. Counting is 0-based.
20      * @param columnIndex the position of the cell within the Row
21      * @return the content of the cell
22      */
23      String get(int columnIndex);
24  
25      /**
26      * Gets the content of the cell in the column named columnName. This method depends on the availability
27      * of a Header, or will otherwise throw an exception
28      * @param columnName the cell of the Row in the same column as the header with name columnName
29      * @return the content of the cell
30      */
31      String get(String columnName);
32  
33      /**
34      * Gets the column name belonging to the cell. This method depends on the availability of a Header, or
35      * will otherwise throw an exception
36      * @param columnIndex the position of the header cell within the Header line
37      * @return the name of the column
38      */
39      String getColumnName(int columnIndex);
40  
41      /**
42      * Returns true if a Header has been set for this Row.
43      * @return true if Header has been found
44      */
45      boolean hasHeader();
46  
47      /**
48      * Returns the Headers and throws an exception if it does not exist. Use hasHeader() if you want to prevent
49      * the throwing of an exception when a Header can lack
50      * @return the Header for the Row
51      */
52      Header getHeader();
53  
54      /**
55      * Generates a report on the Row with focus on the end of the row. This is internally used when there is
56      * a syntax error in the line. It could also be used when there is an error that can not be traced back
57      * to a single cell.
58      * @return report on the row with focus on the end of the row
59      */
60      RowReport reportOnEndOfLine();
61  
62      /**
63      * Generates a report on the Row with focus on a particular cell. The report can return lines for web
64      * consumption (assisting highlighting) or monospaced font printing with dual lines, the first holding the
65      * value of the line, the second showing where the error occurred.
66      * @param columnIndex the index of the column to focus the report on
67      * @return report on the row with focus on a particular cell
68      */
69      RowReport reportOnColumn(int columnIndex);
70  
71  }