Package csv.impl
Class AbstractStreamTableReader
java.lang.Object
csv.impl.AbstractTableReader
csv.impl.AbstractStreamTableReader
- All Implemented Interfaces:
TableReader,Iterable<Object[]>,Iterator<Object[]>
- Direct Known Subclasses:
CSVReader,ExcelReader,XmlReader
An abstract implementation of TableReader.
This implementation takes care of simple stream handling.
- Author:
- RalphSchuster
-
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor.Creates a new instance of Reader.The constructor for a given input stream.Creates a new instance of Reader. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the reader and its underlying stream.protected InputStreamReadercreateInputStreamReader(InputStream stream) Creates the input stream reader that feeds the buffered reader.protected BufferedReaderCreates the buffered reader.Returns the charset decoder to be used.Returns the underlying input stream.protected BufferedReaderReturns the underlying reader.voidremove()This method throws an exception.voidreset()Resets the reader and its underlying stream.voidsetCharset(String charset) Sets the charset to be used on the input stream.voidsetCharset(Charset charset) Sets the charset to be used on the input stream.voidsetCharsetDecoder(CharsetDecoder charsetDecoder) Sets the charset decoder to be used on the input stream.voidSets the input stream.Methods inherited from class csv.impl.AbstractTableReader
convert, convert, convertArray, convertArray, get, getColumnIndex, getColumnType, getHeaderRow, getLineCount, getMapper, getMinimumColumnCount, getRowCount, hasHeaderRow, incrementLineCount, incrementRowCount, isHeaderRowRead, iterator, notifyComment, open, readHeaderRow, registerCommentCallBack, setColumnType, setHasHeaderRow, setHeaderRow, setHeaderRowRead, setMapper, setMinimumColumnCount, unregisterCommentCallBackMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next
-
Constructor Details
-
AbstractStreamTableReader
public AbstractStreamTableReader()Default Constructor. -
AbstractStreamTableReader
The constructor for a given input stream.- Parameters:
in- input stream
-
AbstractStreamTableReader
Creates a new instance of Reader.- Parameters:
file- file to read from- Throws:
FileNotFoundException- when the file could not be found.
-
AbstractStreamTableReader
Creates a new instance of Reader.- Parameters:
file- file to read from- Throws:
FileNotFoundException- when the file could not be found.
-
-
Method Details
-
setInputStream
Sets the input stream. This implementation throws an exception when the stream is already set.- Parameters:
in- the stream to set
-
getReader
Returns the underlying reader.- Returns:
- reader object
-
createReader
Creates the buffered reader. The method will callcreateInputStreamReader(InputStream)for the creation of the underlying reader.- Returns:
- the buffered reader.
-
createInputStreamReader
Creates the input stream reader that feeds the buffered reader.- Parameters:
stream- the original input stream- Returns:
- the stream reader
-
getCharsetDecoder
Returns the charset decoder to be used.- Returns:
- the charset decoder
-
setCharsetDecoder
Sets the charset decoder to be used on the input stream.- Parameters:
charsetDecoder- the charset decoder to set
-
setCharset
Sets the charset to be used on the input stream.- Parameters:
charset- the charset to set
-
setCharset
Sets the charset to be used on the input stream.- Parameters:
charset- the charset to set
-
getInputStream
Returns the underlying input stream.- Returns:
- the inputStream
-
reset
public void reset()Resets the reader and its underlying stream.- Specified by:
resetin interfaceTableReader- Overrides:
resetin classAbstractTableReader
-
remove
public void remove()This method throws an exception. Input streams cannot support the remove method. -
close
public void close()Closes the reader and its underlying stream.- Specified by:
closein interfaceTableReader- Overrides:
closein classAbstractTableReader- See Also:
-