public abstract class AbstractCsvReader extends java.lang.Object implements ICsvReader
| Constructor and Description |
|---|
AbstractCsvReader(ITokenizer tokenizer,
CsvPreference preferences)
Constructs a new AbstractCsvReader, using a custom
Tokenizer (which should have already been set
up with the Reader, CsvPreference, and CsvContext). |
AbstractCsvReader(java.io.Reader reader,
CsvPreference preferences)
Constructs a new AbstractCsvReader, using the default
Tokenizer. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the Tokenizer and its associated Reader.
|
protected java.util.List<java.lang.Object> |
executeProcessors(java.util.List<java.lang.Object> processedColumns,
CellProcessor[] processors)
Executes the supplied cell processors on the last row of CSV that was read and populates the supplied List of
processed columns.
|
java.lang.String |
get(int n)
Get column N of the current line (column indexes begin at 1).
|
protected java.util.List<java.lang.String> |
getColumns()
Gets the tokenized columns.
|
java.lang.String[] |
getHeader(boolean firstLineCheck)
This method is used to get an optional header of the CSV file and move the file cursor to the first row
containing data (the second row from the top).
|
int |
getLineNumber()
Gets the current position in the file, where the first line of the file is line number 1.
|
protected CsvPreference |
getPreferences()
Gets the preferences.
|
int |
getRowNumber()
Gets the current row number (i.e.
|
java.lang.String |
getUntokenizedRow()
Returns the untokenized CSV row that was just read (which can potentially span multiple lines in the file).
|
int |
length()
Returns the length (i.e.
|
protected boolean |
readRow()
Calls the tokenizer to read a CSV row.
|
public AbstractCsvReader(java.io.Reader reader,
CsvPreference preferences)
Tokenizer.reader - the readerpreferences - the CSV preferencesjava.lang.NullPointerException - if reader or preferences are nullpublic AbstractCsvReader(ITokenizer tokenizer, CsvPreference preferences)
Tokenizer (which should have already been set
up with the Reader, CsvPreference, and CsvContext). This constructor should only be used if the default Tokenizer
doesn't provide the required functionality.tokenizer - the tokenizerpreferences - the CSV preferencesjava.lang.NullPointerException - if tokenizer or preferences are nullpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.lang.String get(int n)
get in interface ICsvReadern - the index of the column to getpublic java.lang.String[] getHeader(boolean firstLineCheck)
throws java.io.IOException
nameMapping array for read operations.getHeader in interface ICsvReaderfirstLineCheck - if true, ensures that this method is only called when reading the first line (as that's where the
header is meant to be)java.io.IOException - if an I/O exception occurspublic int getLineNumber()
getLineNumber in interface ICsvReaderpublic java.lang.String getUntokenizedRow()
getUntokenizedRow in interface ICsvReaderpublic int getRowNumber()
getRowNumber in interface ICsvReaderpublic int length()
length in interface ICsvReaderprotected java.util.List<java.lang.String> getColumns()
protected CsvPreference getPreferences()
protected boolean readRow()
throws java.io.IOException
getColumns().java.io.IOException - when an IOException occursSuperCsvException - on errors in parsing the inputprotected java.util.List<java.lang.Object> executeProcessors(java.util.List<java.lang.Object> processedColumns,
CellProcessor[] processors)
processedColumns - the List to populate with processed columnsprocessors - the cell processorsjava.lang.NullPointerException - if processedColumns or processors is nullSuperCsvConstraintViolationException - if a CellProcessor constraint failedSuperCsvException - if the wrong number of processors are supplied, or CellProcessor execution failedCopyright © 2007-2014 Super CSV. All Rights Reserved.