org.knime.base.node.io.filereader
Class FileTable

java.lang.Object
  extended by org.knime.base.node.io.filereader.FileTable
All Implemented Interfaces:
Iterable<DataRow>, DataTable

public class FileTable
extends Object
implements DataTable

Implements a DataTable that reads data from an ASCII file. To instantiate this table you need to specify FileReaderSettings and a DataTableSpec. File reader settings define from where and how to read the data, the table spec specifies the structure of the table to create.

Author:
Peter Ohl, University of Konstanz

Constructor Summary
FileTable(DataTableSpec tableSpec, FileReaderSettings frSettings, boolean[] skipColumns, ExecutionContext exec)
          Creates a new file table with the structure defined in tableSpec and using the settings in frSettings when the file is read.
FileTable(DataTableSpec tableSpec, FileReaderSettings frSettings, ExecutionContext exec)
          Creates a new file table with the structure defined in tableSpec and using the settings in frSettings when the file is read.
 
Method Summary
 void addStatusOfSettings(SettingsStatus status, boolean openDataFile)
          Adds its status messages to a passed status object.
 void dispose()
          Call this before releasing the last reference to this table and all its iterators.
protected  void finalize()
          
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
 SettingsStatus getStatusOfSettings(boolean openDataFile)
          Method to check consistency and completeness of the current settings.
 FileRowIterator iterator()
          Returns a row iterator which returns each row one-by-one from the table.
 String toString()
          Returns a string summary for this table which is the entire table content.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileTable

public FileTable(DataTableSpec tableSpec,
                 FileReaderSettings frSettings,
                 ExecutionContext exec)
Creates a new file table with the structure defined in tableSpec and using the settings in frSettings when the file is read.

Parameters:
tableSpec - a table spec defining the structure of the table to create
frSettings - FileReaderSettings specifying the wheres and hows for reading the ASCII data file
exec - the execution context the progress is reported to; if null, no progress is reported

FileTable

public FileTable(DataTableSpec tableSpec,
                 FileReaderSettings frSettings,
                 boolean[] skipColumns,
                 ExecutionContext exec)
Creates a new file table with the structure defined in tableSpec and using the settings in frSettings when the file is read.

Parameters:
tableSpec - a table spec defining the structure of the table to create
frSettings - FileReaderSettings specifying the wheres and hows for reading the ASCII data file
skipColumns - array with the element set to true if the corresponding column should be skipped (i.e. read but not be included in the row). The array must have the length of the 'original' column number (in the file), the specified table spec is the new one (with less columns).
exec - the execution context the progress is reported to; if null, no progress is reported
Method Detail

finalize

protected void finalize()
                 throws Throwable

Overrides:
finalize in class Object
Throws:
Throwable

dispose

public void dispose()
Call this before releasing the last reference to this table and all its iterators. It closes the underlying source for all iterators. Especially if an iterator didn't run to the end of the table, it is required to call this method. Otherwise the file handle is not released until the garbage collector cleans up. A call to next() of any iterator after disposing of the iterator has undefined behavior.


iterator

public FileRowIterator iterator()
Returns a row iterator which returns each row one-by-one from the table.

Specified by:
iterator in interface Iterable<DataRow>
Specified by:
iterator in interface DataTable
Returns:
row iterator
See Also:
DataRow

getDataTableSpec

public DataTableSpec getDataTableSpec()
Returns the DataTableSpec object of this table which gives information about the structure of this data table.

Specified by:
getDataTableSpec in interface DataTable
Returns:
the DataTableSpec of this table

getStatusOfSettings

public SettingsStatus getStatusOfSettings(boolean openDataFile)
Method to check consistency and completeness of the current settings. It will return a SettingsStatus object which contains info, warning and error messages. Or if the settings are alright it will return null.

Parameters:
openDataFile - tells whether or not this method should try to access the data file. This will - if set true - verify the accessibility of the data.
Returns:
a SettingsStatus object containing info, warning and error messages, or null if no messages were generated (i.e. all settings are just fine)

addStatusOfSettings

public void addStatusOfSettings(SettingsStatus status,
                                boolean openDataFile)
Adds its status messages to a passed status object.

Parameters:
status - the object to add messages to - if any.
openDataFile - specifies if we should check the accessibility of the data file.

toString

public String toString()
Returns a string summary for this table which is the entire table content. Note, this call might be time consuming since this method iterates over the table to retrieve all data.

Overrides:
toString in class Object


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.