public class TextFileRowReader extends AbstractTextFileHandler implements RowReader
| Modifier and Type | Field and Description |
|---|---|
static int |
CONVERT_VALUES
Sets if the reader should attempt to convert values.
|
static int |
IGNORE_MULTIPLE_DELIMITERS
Sets if two more more delimiters are encountered together if these should
be treated as one delimiters
|
static int |
NO_OPTIONS
Sets no options, all options are set to false
|
static int |
PARSE_EMPTY_STRINGS
Sets if the reader should parse empty strings.
|
static int |
REMOVE_WHITE_SPACE
Sets if the reader remove any prefix or suffix white space for Strings
|
static int |
ROWS_SAME_SIZE
Sets if rows are adjusted to be all the same size as the first row
|
COMMA, TAB| Constructor and Description |
|---|
TextFileRowReader(BufferedReader bufferedReader) |
TextFileRowReader(Path path)
Constructs an initialised reader using a file.
|
TextFileRowReader(String reference)
Constructs an initialised reader using a string reference to a text file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the reader, disposing of any internal resources
|
protected String |
convertToken(String string) |
protected String |
convertTokenWithoutTrim(String string) |
protected String |
convertTokenWithTrim(String string) |
protected Object |
convertValue(String text) |
protected Object |
convertValue(String text,
int dataTypes) |
int[] |
getAllConversionTypes() |
Object |
getCell()
Gets the value of the current cell
|
boolean |
getCellAsBoolean()
Gets the value of the current cell as an boolean
|
double |
getCellAsDouble()
Gets the value of the current cell as a double
|
int |
getCellAsInt()
Gets the value of the current cell as an int
|
String |
getCellAsString()
Gets the value of the current cell as a string
|
int |
getConversionTypes(int index) |
protected int |
getDefaultConversionTypes() |
int |
getOptions()
Gets an int representing a bit array of options
|
List<Object> |
getRowCells()
Gets the current remaining unread row cell values
|
Object[] |
getRowCellsAsArray()
Gets the current remaining unread row cell values as an array
|
List<Boolean> |
getRowCellsAsBoolean()
Gets the current remaining unread row cell values
|
boolean[] |
getRowCellsAsBooleanArray()
Gets the current remaining unread row cell values as an array
|
List<Double> |
getRowCellsAsDouble()
Gets the current remaining unread row cell values
|
double[] |
getRowCellsAsDoubleArray()
Gets the current remaining unread row cell values as an array
|
List<Integer> |
getRowCellsAsInt()
Gets the current remaining unread row cell values
|
int[] |
getRowCellsAsIntArray()
Gets the current remaining unread row cell values as an array
|
List<String> |
getRowCellsAsString()
Gets the current remaining unread row cell values
|
String[] |
getRowCellsAsStringArray()
Gets the current remaining unread row cell values as an array
|
boolean |
hasNextColumn()
Determines if there another cell in the current column
|
boolean |
hasNextRow()
Determines if there is another row in the current data source
|
protected void |
initialise()
Initialises the reader.
|
boolean |
nextColumn()
Moves the reader on to the next cell in the column.
|
boolean |
nextRow()
Moves the reader on to the next row in the data source.
|
protected Object |
parseValue(String text,
int rowIndex,
int columnIndex) |
protected Object |
parseValue(String text,
int rowIndex,
int columnIndex,
int conversionTypes) |
List<List<Object>> |
readCells()
Read all cells from the data source at one time
|
Object[][] |
readCellsAsArray()
Read all cells from the data source at one time
|
boolean |
ready()
Check to see if the reader is ready to be used and if additional cells
can still be read
|
void |
setAllConversionTypes(int[] conversionTypes) |
void |
setConversionTypes(int conversionTypes,
int index) |
void |
setDefaultConversionTypes(int defaultConversionTypes) |
void |
setDelimiterString(String delimiter)
Sets the delimiter string.
|
void |
setOptions(int options)
Sets an int representing a bit array of options
|
getColumnCount, getColumnIndex, getCommentString, getDelimiterString, getPath, getPathReference, getRowCount, getRowIndex, getRowPosition, getRowSize, incrementColumnIndex, incrementRowIndex, incrementRowPosition, isInStrictMode, isInUse, isRowSizesEqual, isRowSizeSetExternally, resetCellIndex, setColumnIndex, setCommentString, setFileReference, setInStrictMode, setPath, setRowIndex, setRowPosition, setRowSize, setRowSizeInternal, updateRowFromSize, updateRowSizepublic static final int NO_OPTIONS
public static final int PARSE_EMPTY_STRINGS
public static final int CONVERT_VALUES
public static final int IGNORE_MULTIPLE_DELIMITERS
public static final int ROWS_SAME_SIZE
public static final int REMOVE_WHITE_SPACE
public TextFileRowReader(String reference) throws IOException, FileNotFoundException
reference - a text file name or URLFileNotFoundException - if the file to read is not foundIOException - if an I/O error occurspublic TextFileRowReader(Path path) throws IOException, FileNotFoundException
path - the Path to file to be read.FileNotFoundException - if the file to read is not foundIOException - if an I/O error occurspublic TextFileRowReader(BufferedReader bufferedReader) throws IOException
IOExceptionpublic final boolean ready()
ready in interface Readerready in class AbstractTextFileHandlertrue if the reader is ready to be used and if
additional cells can still be read, false otherwisepublic final void close()
close in interface AutoCloseableclose in interface Readerpublic final int getOptions()
public final void setOptions(int options)
throws IOException
options - an int preresenting a bit array of optionsIOExceptionpublic final void setDelimiterString(String delimiter) throws IOException
setDelimiterString in class AbstractTextFileHandlerdelimiter - the delimiter stringIOException - if the reader is already is usepublic final Object[][] readCellsAsArray() throws IOException
TableReaderreadCellsAsArray in interface TableReaderIOException - if the data source can not be readpublic final List<List<Object>> readCells() throws IOException
TableReaderreadCells in interface TableReaderIOException - if the data source can not be readpublic final boolean hasNextRow()
TableReaderhasNextRow in interface TableReadertrue if this is not the last cell in the row, false if it is the lastpublic final boolean nextRow()
throws IOException
TableReadernextRow in interface TableReadertrue if this is not the last cell in the row, false if it is the lastIOException - if the data source can not be readpublic boolean hasNextColumn()
TableReaderhasNextColumn in interface TableReadertrue if this is not the last cell in the column, false if it is the lastpublic boolean nextColumn()
throws IOException
TableReadernextColumn in interface TableReadertrue if this is not the last cell in the column, false if it is the lastIOException - if the data source can not be readpublic Object getCell() throws IOException
TableReadergetCell in interface TableReaderIOException - if the data source can not be readpublic String getCellAsString() throws IOException
TableReadergetCellAsString in interface TableReaderIOException - if the data source can not be read or can not be converted to Stringpublic double getCellAsDouble()
throws IOException
TableReadergetCellAsDouble in interface TableReaderIOException - if the data source can not be read or can not be converted to doublepublic int getCellAsInt()
throws IOException
TableReadergetCellAsInt in interface TableReaderIOException - if the data source can not be read or can not be converted to an intpublic boolean getCellAsBoolean()
throws IOException
TableReadergetCellAsBoolean in interface TableReaderIOException - if the data source can not be read or can not be converted to an booleanpublic final List<Object> getRowCells() throws IOException
RowReadergetRowCells in interface RowReaderIOException - if the data source can not be readpublic final List<String> getRowCellsAsString() throws IOException
RowReadergetRowCellsAsString in interface RowReaderIOException - if the data source can not be readpublic final List<Integer> getRowCellsAsInt() throws IOException
RowReadergetRowCellsAsInt in interface RowReaderIOException - if the data source can not be readpublic final List<Double> getRowCellsAsDouble() throws IOException
RowReadergetRowCellsAsDouble in interface RowReaderIOException - if the data source can not be readpublic final List<Boolean> getRowCellsAsBoolean() throws IOException
RowReadergetRowCellsAsBoolean in interface RowReaderIOException - if the data source can not be readpublic final Object[] getRowCellsAsArray() throws IOException
RowReadergetRowCellsAsArray in interface RowReaderIOException - if the data source can not be readpublic final String[] getRowCellsAsStringArray() throws IOException
RowReadergetRowCellsAsStringArray in interface RowReaderIOException - if the data source can not be readpublic final int[] getRowCellsAsIntArray()
throws IOException
RowReadergetRowCellsAsIntArray in interface RowReaderIOException - if the data source can not be readpublic final double[] getRowCellsAsDoubleArray()
throws IOException
RowReadergetRowCellsAsDoubleArray in interface RowReaderIOException - if the data source can not be readpublic final boolean[] getRowCellsAsBooleanArray()
throws IOException
RowReadergetRowCellsAsBooleanArray in interface RowReaderIOException - if the data source can not be readprotected Object parseValue(String text, int rowIndex, int columnIndex) throws IOException
IOExceptionprotected Object parseValue(String text, int rowIndex, int columnIndex, int conversionTypes) throws IOException
IOExceptionprotected Object convertValue(String text, int dataTypes) throws ConversionException
ConversionExceptionprotected final void initialise()
throws FileNotFoundException,
IOException
initialise in class AbstractTextFileHandlerFileNotFoundException - if the file to read is not foundIOException - if an I/O error occursprotected int getDefaultConversionTypes()
public final void setDefaultConversionTypes(int defaultConversionTypes)
public final int getConversionTypes(int index)
public final int[] getAllConversionTypes()
public final void setAllConversionTypes(int[] conversionTypes)
setAllConversionTypes in interface TableReaderpublic final void setConversionTypes(int conversionTypes,
int index)
Copyright © 2016. All rights reserved.