adams.data.io.input
Class SqlDumpSpreadSheetReader.ChunkReader

java.lang.Object
  extended by adams.data.io.input.SqlDumpSpreadSheetReader.ChunkReader
All Implemented Interfaces:
Serializable
Enclosing class:
SqlDumpSpreadSheetReader

public static class SqlDumpSpreadSheetReader.ChunkReader
extends Object
implements Serializable

Reads CSV files chunk by chunk.

Version:
$Revision: 7020 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  int m_ChunkSize
          the chunk size.
protected  SpreadSheet m_Header
          the header.
protected  List<String> m_HeaderCells
          the header cells to use.
protected  SqlDumpSpreadSheetReader m_Owner
          the owning reader.
protected  BufferedReader m_Reader
          the reader in use.
protected  boolean m_UseBackslashes
          whether to backslashes are used for escaping single quotes.
 
Constructor Summary
SqlDumpSpreadSheetReader.ChunkReader(SqlDumpSpreadSheetReader owner)
          Initializes the low-level reader.
 
Method Summary
 boolean hasNext()
          Returns whether there is more data to be read.
 SpreadSheet next()
          Reads the next chunk.
 SpreadSheet read(Reader r, int chunkSize)
          Reads the spreadsheet content from the specified reader.
protected  List<String> readCells(Reader reader)
          Reads a row and breaks it up into cells.
protected  void removeTrailingCR(StringBuilder current)
          Removes a trailing CR.
protected  String unquote(String s)
          Unquotes the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Owner

protected SqlDumpSpreadSheetReader m_Owner
the owning reader.


m_Reader

protected BufferedReader m_Reader
the reader in use.


m_Header

protected SpreadSheet m_Header
the header.


m_ChunkSize

protected int m_ChunkSize
the chunk size.


m_UseBackslashes

protected boolean m_UseBackslashes
whether to backslashes are used for escaping single quotes.


m_HeaderCells

protected List<String> m_HeaderCells
the header cells to use.

Constructor Detail

SqlDumpSpreadSheetReader.ChunkReader

public SqlDumpSpreadSheetReader.ChunkReader(SqlDumpSpreadSheetReader owner)
Initializes the low-level reader.

Parameters:
owner - the owning reader
Method Detail

unquote

protected String unquote(String s)
Unquotes the given string.

Parameters:
s - the string to unquote, if necessary
Returns:
the processed string

removeTrailingCR

protected void removeTrailingCR(StringBuilder current)
Removes a trailing CR.

Parameters:
current - the current buffer

readCells

protected List<String> readCells(Reader reader)
                          throws IOException
Reads a row and breaks it up into cells.

Parameters:
reader - the reader to read from
Returns:
the cells, null if nothing could be read (EOF)
Throws:
IOException - if reading fails, e.g., due to IO error

next

public SpreadSheet next()
Reads the next chunk.

Returns:
the next chunk

hasNext

public boolean hasNext()
Returns whether there is more data to be read.

Returns:
true if more data available

read

public SpreadSheet read(Reader r,
                        int chunkSize)
Reads the spreadsheet content from the specified reader.

Parameters:
r - the reader to read from
chunkSize - the number of rows to read at a time
Returns:
the spreadsheet or null in case of an error


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.