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

java.lang.Object
  extended by org.knime.core.data.RowIterator
      extended by org.knime.base.node.io.filereader.FileRowIterator
All Implemented Interfaces:
Iterator<DataRow>

 class FileRowIterator
extends RowIterator

Row iterator for the FileTable.

The iterator provides a method

Author:
Peter Ohl, University of Konstanz
See Also:
RowIterator

Constructor Summary
FileRowIterator(FileReaderSettings frSettings, DataTableSpec tableSpec, boolean[] skipColumns, ExecutionContext exec)
          The RowIterator for the FileTable.
 
Method Summary
 void dispose()
          Call this before releasing the last reference to this iterator.
protected  void finalize()
          
 String getZipEntryName()
           
 boolean hasNext()
          Returns true if there are more rows and false otherwise.
 boolean iteratorEndedEarly()
          The settings allow for specifying a maximum number of rows.
 DataRow next()
          Returns the next DataRow.
 boolean zippedSourceHasMoreEntries()
          If the source read was a ZIP archive this method tests if there are more than one entry in the archive.
 
Methods inherited from class org.knime.core.data.RowIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileRowIterator

FileRowIterator(FileReaderSettings frSettings,
                DataTableSpec tableSpec,
                boolean[] skipColumns,
                ExecutionContext exec)
          throws IOException
The RowIterator for the FileTable.

Parameters:
frSettings - object containing the wheres and hows to read the data
tableSpec - the spec defining the structure of the rows to create (the result spec after applying the next argument 'skipColumns')
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 to report the progress to
Throws:
IOException - if it couldn't open the data file
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 iterator. It closes the underlying source. Especially if the 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() after disposing of the iterator has undefined behavior.


hasNext

public boolean hasNext()
Returns true if there are more rows and false otherwise.

Specified by:
hasNext in interface Iterator<DataRow>
Specified by:
hasNext in class RowIterator
Returns:
true if the iterator has more elements, otherwise false
See Also:
RowIterator.next()

next

public DataRow next()
Returns the next DataRow.

Specified by:
next in interface Iterator<DataRow>
Specified by:
next in class RowIterator
Returns:
the next row in the DataTable

iteratorEndedEarly

public boolean iteratorEndedEarly()
The settings allow for specifying a maximum number of rows. This method can be used to find out, if the source has more data than actually returned by the iterator. The result is only accurate, after the hasNext() method returned false.

Returns:
true, if the iterator didn't return all rows of the source (due to its settings). Only accurate after the iterator finished (hasNext() returned false).

zippedSourceHasMoreEntries

public boolean zippedSourceHasMoreEntries()
If the source read was a ZIP archive this method tests if there are more than one entry in the archive. If the source was not compressed or a gzip file, it always returns false. If the EOF has not been read from the source, the result is always false.

Returns:
true, if the source was read til the end and it is a ZIP archive with more than one entry

getZipEntryName

public String getZipEntryName()
Returns:
if the underlying source is a ZIP archive it returns the entry read. Null if not a ZIP source.


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.