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 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.FileNotFoundException
      Creates 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.FileNotFoundException
      Creates 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 call createInputStreamReader(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:
      reset in interface TableReader
      Overrides:
      reset in class AbstractTableReader
    • 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:
      close in interface TableReader
      Overrides:
      close in class AbstractTableReader
      See Also:
      TableReader.close()