Package csv.impl
Class AbstractStreamTableReader
java.lang.Object
csv.impl.AbstractTableReader
csv.impl.AbstractStreamTableReader
- All Implemented Interfaces:
TableReader,java.lang.Iterable<java.lang.Object[]>,java.util.Iterator<java.lang.Object[]>
- Direct Known Subclasses:
CSVReader,ExcelReader,XmlReader
public abstract class AbstractStreamTableReader extends AbstractTableReader
An abstract implementation of TableReader.
This implementation takes care of simple stream handling.
- Author:
- RalphSchuster
-
Constructor Summary
Constructors Constructor Description AbstractStreamTableReader()Default Constructor.AbstractStreamTableReader(java.io.File file)Creates a new instance of Reader.AbstractStreamTableReader(java.io.InputStream in)The constructor for a given input stream.AbstractStreamTableReader(java.lang.String file)Creates a new instance of Reader. -
Method Summary
Modifier and Type Method Description voidclose()Closes the reader and its underlying stream.protected java.io.InputStreamReadercreateInputStreamReader(java.io.InputStream stream)Creates the input stream reader that feeds the buffered reader.protected java.io.BufferedReadercreateReader()Creates the buffered reader.java.nio.charset.CharsetDecodergetCharsetDecoder()Returns the charset decoder to be used.java.io.InputStreamgetInputStream()Returns the underlying input stream.protected java.io.BufferedReadergetReader()Returns the underlying reader.voidremove()This method throws an exception.voidreset()Resets the reader and its underlying stream.voidsetCharset(java.lang.String charset)Sets the charset to be used on the input stream.voidsetCharset(java.nio.charset.Charset charset)Sets the charset to be used on the input stream.voidsetCharsetDecoder(java.nio.charset.CharsetDecoder charsetDecoder)Sets the charset decoder to be used on the input stream.voidsetInputStream(java.io.InputStream in)Sets the input stream.Methods inherited from class csv.impl.AbstractTableReader
addCommentCallBack, convert, convert, convertArray, convertArray, get, getColumnIndex, getColumnType, getHeaderRow, getLineCount, getMinimumColumnCount, getRowCount, getTypeConversionHandler, hasHeaderRow, incrementLineCount, incrementRowCount, isHeaderRowRead, iterator, notifyComment, open, readHeaderRow, registerCommentCallBack, registerTypeConversionHandler, removeCommentCallBack, setColumnType, setHasHeaderRow, setHeaderRow, setHeaderRowRead, setMinimumColumnCount, unregisterCommentCallBack, unregisterTypeConversionHandler
-
Constructor Details
-
AbstractStreamTableReader
public AbstractStreamTableReader()Default Constructor. -
AbstractStreamTableReader
public AbstractStreamTableReader(java.io.InputStream in)The constructor for a given input stream.- Parameters:
in- input stream
-
AbstractStreamTableReader
public AbstractStreamTableReader(java.io.File file) throws java.io.FileNotFoundExceptionCreates a new instance of Reader.- Parameters:
file- file to read from- Throws:
java.io.FileNotFoundException- when the file could not be found.
-
AbstractStreamTableReader
public AbstractStreamTableReader(java.lang.String file) throws java.io.FileNotFoundExceptionCreates a new instance of Reader.- Parameters:
file- file to read from- Throws:
java.io.FileNotFoundException- when the file could not be found.
-
-
Method Details
-
setInputStream
public void setInputStream(java.io.InputStream in)Sets the input stream. This implementation throws an exception when the stream is already set.- Parameters:
in- the stream to set
-
getReader
protected java.io.BufferedReader getReader()Returns the underlying reader.- Returns:
- reader object
-
createReader
protected java.io.BufferedReader createReader()Creates the buffered reader. The method will callcreateInputStreamReader(InputStream)for the creation of the underlying reader.- Returns:
- the buffered reader.
-
createInputStreamReader
protected java.io.InputStreamReader createInputStreamReader(java.io.InputStream stream)Creates the input stream reader that feeds the buffered reader.- Parameters:
stream- the original input stream- Returns:
- the stream reader
-
getCharsetDecoder
public java.nio.charset.CharsetDecoder getCharsetDecoder()Returns the charset decoder to be used.- Returns:
- the charset decoder
-
setCharsetDecoder
public void setCharsetDecoder(java.nio.charset.CharsetDecoder charsetDecoder)Sets the charset decoder to be used on the input stream.- Parameters:
charsetDecoder- the charset decoder to set
-
setCharset
public void setCharset(java.nio.charset.Charset charset)Sets the charset to be used on the input stream.- Parameters:
charset- the charset to set
-
setCharset
public void setCharset(java.lang.String charset)Sets the charset to be used on the input stream.- Parameters:
charset- the charset to set
-
getInputStream
public java.io.InputStream 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:
TableReader.close()
-