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

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

public class FileReaderPreviewTable
extends Object
implements DataTable

The data table displayed in the file reader's dialog's preview. We need an extra incarnation of a data table (different from from the FileTable) because if settings are not correct yet, the table in the preview must not throw any exception on unexpected or invalid data it reads (which the "normal" file table does). Thus, this table returns a row iterator that will create an error row when a error occurs during file reading. It will end the table after the erroneous element was read.

Author:
Peter Ohl, University of Konstanz

Constructor Summary
FileReaderPreviewTable(DataTableSpec tableSpec, FileReaderNodeSettings settings, ExecutionContext exec)
          Creates a new table, its like the "normal" FileTable, just not failing on invalid data files.
 
Method Summary
(package private)  void addChangeListener(ChangeListener listener)
          If someone wants to be notified if an error occurred he should register through this method.
 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.
(package private)  String getErrorDetail()
           
(package private)  int getErrorLine()
           
(package private)  String getErrorMsg()
           
(package private)  boolean getErrorOccurred()
           
 RowIterator iterator()
          Returns a row iterator which returns each row one-by-one from the table.
(package private)  void removeAllChangeListeners()
          Clears the list of change listeners
(package private)  void setError(FileReaderException fre)
          This sets the flag indicating that the row iterator ended the table with an error.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReaderPreviewTable

FileReaderPreviewTable(DataTableSpec tableSpec,
                       FileReaderNodeSettings settings,
                       ExecutionContext exec)
Creates a new table, its like the "normal" FileTable, just not failing on invalid data files.

Parameters:
settings - settings for the underlying FileTable
tableSpec - table spec for the underlying FileTable
exec - the execution context the progress is reported to
See Also:
FileTable
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. Especially if the iterators don'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() on any of the iterators of this table after disposing of the table has undefined behavior.


iterator

public RowIterator 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

setError

void setError(FileReaderException fre)
This sets the flag indicating that the row iterator ended the table with an error.

Parameters:
fre - the exception thrown by the error.

getErrorOccurred

boolean getErrorOccurred()
Returns:
true if an error occurred in an underlying row iterator. Meaning the table contains invalid data. NOTE: if false is returned it is not guaranteed that all data in the table is valid. It could be that no row iterator reached the invalid data yet.

getErrorMsg

String getErrorMsg()
Returns:
the error msg set by a row iterator that came across an error in the table. This is null if not set.

getErrorDetail

String getErrorDetail()
Returns:
a message containing more details about the error occurred. Could be null if no details are available.

getErrorLine

int getErrorLine()
Returns:
the line number where the error occurred - if an error occurred and an error line number was set. Otherwise -1 is returned.

addChangeListener

void addChangeListener(ChangeListener listener)
If someone wants to be notified if an error occurred he should register through this method.

Parameters:
listener - the object being notified when an error occurs.

removeAllChangeListeners

void removeAllChangeListeners()
Clears the list of change listeners

See Also:
addChangeListener(ChangeListener)


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.