Package adams.data.io.input
Class SqlDumpSpreadSheetReader.ChunkReader
- java.lang.Object
-
- 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$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description ChunkReader(SqlDumpSpreadSheetReader owner)
Initializes the low-level reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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.
-
-
Constructor Detail
-
ChunkReader
public 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 fromchunkSize
- the number of rows to read at a time- Returns:
- the spreadsheet or null in case of an error
-
-