org.knime.base.node.preproc.filter.row
Class RowFilterIterator

java.lang.Object
  extended by org.knime.core.data.RowIterator
      extended by org.knime.base.node.preproc.filter.row.RowFilterIterator
All Implemented Interfaces:
Iterator<DataRow>

public class RowFilterIterator
extends RowIterator

Row iterator of the row filter table. Wraps a given row iterator and forwards only rows that are approved by a given RowFilter. Also a range of row numbers can be specified and a flag to only include or exclude rows within that range. (The range feature is ANDed to the filter match result. If another operation on the row number is required an appropreate filter has to be created.)
The order of which the conditions are evaluated is as follows: If a range is specified, the row number is checked against the specified range, only if it matches the filter is asked to do its match. If the row number range fails it is also checked if the end of the result table is reached due to the range restrictions. (This should speed up the atEnd() check as we don't have to traverse through the entire input table - which is actually the reason we handle the row number range not in a filter.)

Note: Iterating may be slow as the iterator must potentially skip many rows until it encounters a row to be returned. This iterator does also support cancelation/progress information using an ExecutionMonitor.

Author:
Peter Ohl, University of Konstanz

Nested Class Summary
static class RowFilterIterator.RuntimeCanceledExecutionException
          Runtime exception that's thrown when the execution monitor's ExecutionMonitor.checkCanceled() method throws a CanceledExecutionException.
 
Constructor Summary
RowFilterIterator(DataTable orig, RowFilter filter)
          Creates a new row iterator wrapping an existing one and delivering only rows that match the specified conditions.
RowFilterIterator(DataTable origTable, RowFilter filter, ExecutionMonitor exec)
          Creates a new row iterator wrapping an existing one and delivering only rows that match the specified conditions.
 
Method Summary
 boolean hasNext()
          Returns true if there are more rows and false otherwise.
 DataRow next()
          This implementation may throw an RuntimeCanceledExecutionException if this class has been initialized with a non-null execution monitor.
 
Methods inherited from class org.knime.core.data.RowIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowFilterIterator

public RowFilterIterator(DataTable origTable,
                         RowFilter filter,
                         ExecutionMonitor exec)
Creates a new row iterator wrapping an existing one and delivering only rows that match the specified conditions.

Parameters:
origTable - the original table from which we get the iterator and the row count, if any
filter - a filter object that will decide whether rows are included in the result or filtered out
exec - to report progress to and to check for cancel status

RowFilterIterator

public RowFilterIterator(DataTable orig,
                         RowFilter filter)
Creates a new row iterator wrapping an existing one and delivering only rows that match the specified conditions. No progress info or canceled status is available.

Parameters:
orig - the original table from which we get the iterator and the row count, if any
filter - a filter object that will decide whether rows are included in the result or filtered out
Method Detail

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()
             throws RowFilterIterator.RuntimeCanceledExecutionException
This implementation may throw an RuntimeCanceledExecutionException if this class has been initialized with a non-null execution monitor. Returns the next DataRow.

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


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.