prefuse.data.io
Class AbstractTextTableReader

java.lang.Object
  extended by prefuse.data.io.AbstractTableReader
      extended by prefuse.data.io.AbstractTextTableReader
All Implemented Interfaces:
TableReader
Direct Known Subclasses:
CSVTableReader, DelimitedTextTableReader, FixedWidthTextTableReader

public abstract class AbstractTextTableReader
extends AbstractTableReader

Abstract base class for TableReader instances that read in a table from a textual data file.

Author:
jeffrey heer

Constructor Summary
AbstractTextTableReader()
          Create a new AbstractTextTableReader using a default ParserFactory.
AbstractTextTableReader(ParserFactory parserFactory)
          Create a new AbstractTextTableReader.
 
Method Summary
protected  java.util.ArrayList getColumnNames()
          Subclasses can override this to provide column names through a custom mechanism.
static java.lang.String getDefaultHeader(int idx)
          Returns default column header names of the type "A", "B", ..., "Z", "AA", "AB", etc.
protected abstract  void read(java.io.InputStream is, TableReadListener trl)
          Scans the input stream, making call backs for each encountered entry on the provided TextReadListener.
 Table readTable(java.io.InputStream is)
          Read in a table from the given InputStream.
 void setHasHeader(boolean hasHeaderRow)
          Set whether or not the table data file includes a header row.
 
Methods inherited from class prefuse.data.io.AbstractTableReader
readTable, readTable, readTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTextTableReader

public AbstractTextTableReader()
Create a new AbstractTextTableReader using a default ParserFactory.


AbstractTextTableReader

public AbstractTextTableReader(ParserFactory parserFactory)
Create a new AbstractTextTableReader.

Parameters:
parserFactory - the ParserFactory to use for parsing text strings into table values.
Method Detail

setHasHeader

public void setHasHeader(boolean hasHeaderRow)
Set whether or not the table data file includes a header row.

Parameters:
hasHeaderRow - true if the the data file includes a header row, false otherwise.

readTable

public Table readTable(java.io.InputStream is)
                throws DataIOException
Description copied from interface: TableReader
Read in a table from the given InputStream.

Parameters:
is - the InputStream to read the table from
Returns:
the loaded Table
Throws:
DataIOException
See Also:
TableReader.readTable(java.io.InputStream)

getColumnNames

protected java.util.ArrayList getColumnNames()
Subclasses can override this to provide column names through a custom mechanism.

Returns:
an ArrayList of String instances indicating the column names

getDefaultHeader

public static java.lang.String getDefaultHeader(int idx)
Returns default column header names of the type "A", "B", ..., "Z", "AA", "AB", etc.

Parameters:
idx - the index of the column header
Returns:
a default column header name for the given index.

read

protected abstract void read(java.io.InputStream is,
                             TableReadListener trl)
                      throws java.io.IOException,
                             DataParseException
Scans the input stream, making call backs for each encountered entry on the provided TextReadListener.

Parameters:
is - the InputStream to read
trl - the TextReadListener that will receive callbacks
Throws:
java.io.IOException
DataParseException


Copyright © 2007 Regents of the University of California