infovis.table.io
Class CSVTableReader

java.lang.Object
  extended by infovis.io.AbstractReader
      extended by infovis.table.io.AbstractTableReader
          extended by infovis.table.io.CSVTableReader
Direct Known Subclasses:
TM3TreeReader, TQDTableReader

public class CSVTableReader
extends AbstractTableReader

Read an Excel CSV format into a table.

Version:
$Revision: 1.27 $
Author:
Jean-Daniel Fekete
InfoVis factory arguments:
TableReaderFactory csv

Constructor Summary
CSVTableReader(InputStream in, String name, Table table)
          Constructor.
CSVTableReader(InputStream in, Table table)
          Constructor.
 
Method Summary
 boolean addField(int column, String field)
          Adds the value of specified column.
 void addLabel(String name)
          Adds a label.
 String defaultFieldName(int index)
          Returns a default field name for a specified index.
 Column getColumnAt(int index)
          Returns the column at the specified index in the label table.
 String getField()
          Returns a string from the current buffer content.
 String getLabelAt(int index)
          Returns the label at the specified index.
 char getSeparator()
          Returns the column separator character.
 int getSkipLines()
          Returns the number of lines to skip at the begining of the file.
 boolean isConsideringQuotes()
          Returns the consideringQuotes.
 boolean isLabelLinePresent()
          Returns true if the first line contains labels.
 boolean isTypeLinePresent()
          Returns true if a line containing the types should be read.
 boolean load()
          Main method for loading the file.
static boolean load(File file, Table t)
          Loads the specified file in the specified table.
 boolean nextField(int col)
          Read the next field, storing it in buffer and returns false if it ends the line.
 void setConsideringQuotes(boolean consideringQuotes)
          Sets the consideringQuotes.
 void setLabelLinePresent(boolean labelLinePresent)
          Sets whether the first line contains labels.
 void setSeparator(char separator)
          Sets the column separator character.
 void setSkipLines(int skipLines)
          Sets the number of lines to skip at the begining of the file.
 void setTypeLinePresent(boolean typeLinePresent)
          Sets the typeLinePresent.
 
Methods inherited from class infovis.table.io.AbstractTableReader
close, getBuffer, getBufferedReader, getCommentChar, getIn, getTable, ignoreLine, isEof, read, readInt, readLine, readQuoted, setBuffer, setCommentChar, setEof, setTable, skipToEol
 
Methods inherited from class infovis.io.AbstractReader
createColumn, getEncoding, getName, guessFieldType, setEncoding, setIn, setName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVTableReader

public CSVTableReader(InputStream in,
                      Table table)
Constructor.

Parameters:
in - the input stream
table - the table

CSVTableReader

public CSVTableReader(InputStream in,
                      String name,
                      Table table)
Constructor.

Parameters:
in - the input stream
name - the name
table - the table
Method Detail

getSeparator

public char getSeparator()
Returns the column separator character.

Returns:
char the column separator character.

setSeparator

public void setSeparator(char separator)
Sets the column separator character.

Parameters:
separator - the column separator character. The separator to set

isLabelLinePresent

public boolean isLabelLinePresent()
Returns true if the first line contains labels.

Returns:
true if the first line contains labels.

setLabelLinePresent

public void setLabelLinePresent(boolean labelLinePresent)
Sets whether the first line contains labels.

Parameters:
labelLinePresent - true the first line contains labels.

isTypeLinePresent

public boolean isTypeLinePresent()
Returns true if a line containing the types should be read.

Returns:
true if a line containing the types should be read.

setTypeLinePresent

public void setTypeLinePresent(boolean typeLinePresent)
Sets the typeLinePresent.

Parameters:
typeLinePresent - The typeLinePresent to set

isConsideringQuotes

public boolean isConsideringQuotes()
Returns the consideringQuotes.

Returns:
boolean

setConsideringQuotes

public void setConsideringQuotes(boolean consideringQuotes)
Sets the consideringQuotes.

Parameters:
consideringQuotes - The consideringQuotes to set

getSkipLines

public int getSkipLines()
Returns the number of lines to skip at the begining of the file.

Returns:
the number of lines to skip at the begining of the file.

setSkipLines

public void setSkipLines(int skipLines)
Sets the number of lines to skip at the begining of the file.

Parameters:
skipLines - the number of lines to skip at the begining of the file.

nextField

public boolean nextField(int col)
                  throws IOException
Read the next field, storing it in buffer and returns false if it ends the line.

Parameters:
col - the column
Returns:
true if it ends the line.
Throws:
IOException - pass exception from BufferedReader

defaultFieldName

public String defaultFieldName(int index)
Returns a default field name for a specified index.

Parameters:
index - the index.
Returns:
a default field name for a specified index.

getLabelAt

public String getLabelAt(int index)
Returns the label at the specified index.

Parameters:
index - the index
Returns:
the label at the specified index.

addLabel

public void addLabel(String name)
Adds a label.

Parameters:
name - the label

getColumnAt

public Column getColumnAt(int index)
Returns the column at the specified index in the label table.

Parameters:
index - the index
Returns:
the column at the specified index in the label table or null if the index is invalid or no column of that name exist.

addField

public boolean addField(int column,
                        String field)
                 throws ParseException
Adds the value of specified column.

Parameters:
column - DOCUMENT ME!
field - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
ParseException - DOCUMENT ME!

load

public boolean load()
Description copied from class: AbstractReader
Main method for loading the file. The loading may fail at any point, leaving the table in an indefinite state if the methods returns false.

Specified by:
load in class AbstractReader
Returns:
true if the file has been loaded without error, false otherwise.
See Also:
AbstractReader.load()

getField

public String getField()
Returns a string from the current buffer content.

Overrides:
getField in class AbstractTableReader
Returns:
a string from the current buffer content.

load

public static boolean load(File file,
                           Table t)
Loads the specified file in the specified table.

Parameters:
file - the file
t - the table
Returns:
true if the loading was successful.


Copyright © 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.