Package csv
Interface TableReader
- All Known Implementing Classes:
AbstractColumnFilter,AbstractRowFilter,AbstractStreamTableReader,AbstractTableReader,CSVReader,DefaultColumnFilter,ExcelReader,IndexRowFilter,JdbcReader,JTableReader,XmlReader
Introduces an interface for other implementations
of table reading interfaces.
The Reader interface defines an important rule: header rows are never delivered
by
Iterator.next() but by getHeaderRow() instead. All implementations
of this class must follow this rule.- Author:
- RalphSchuster
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the reader.intgetColumnIndex(String name) Returns the column index of given column name.Object[]Returns the header row.intReturns the minimum number of columns to be returned byIterator.next().booleanTells whether the underlying stream has a header row or notvoidopen()Opens the reader or resets it.voidregisterCommentCallBack(CommentCallback callback) Registers a comment callback.voidreset()Resets the reader.voidsetHasHeaderRow(boolean hasHeaderRow) Tells the reader whether the underlying stream will treat first row as header row.voidsetMinimumColumnCount(int length) Sets the minimum number of columns to be returned byIterator.next().voidunregisterCommentCallBack(CommentCallback callback) Unregisters a comment callback.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
setHasHeaderRow
void setHasHeaderRow(boolean hasHeaderRow) Tells the reader whether the underlying stream will treat first row as header row.- Parameters:
hasHeaderRow- true if there is a header row.
-
hasHeaderRow
boolean hasHeaderRow()Tells whether the underlying stream has a header row or not- Returns:
- true if there is a header row.
-
getHeaderRow
Object[] getHeaderRow()Returns the header row. Please note that header rows are never delivered throughIterator.next().- Returns:
- header row if such was defined.
-
getColumnIndex
Returns the column index of given column name. The first column with given name will be returned.- Parameters:
name- name of column- Returns:
- index of column or -1 if it does not exist.
-
open
void open()Opens the reader or resets it. -
reset
void reset()Resets the reader. -
close
void close()Closes the reader. -
registerCommentCallBack
Registers a comment callback. The callback will be executed when a comment is detected in input. Note that not all implementations actually support comments.- Parameters:
callback- callback to be registered
-
unregisterCommentCallBack
Unregisters a comment callback. Note that not all implementations actually support comments.- Parameters:
callback- callback to be unregistered
-
setMinimumColumnCount
void setMinimumColumnCount(int length) Sets the minimum number of columns to be returned byIterator.next().- Parameters:
length- number of columns
-
getMinimumColumnCount
int getMinimumColumnCount()Returns the minimum number of columns to be returned byIterator.next().- Returns:
- length number of columns
-