Class StreamingIterator

java.lang.Object
org.dbunit.dataset.stream.StreamingIterator
All Implemented Interfaces:
ITableIterator

public class StreamingIterator extends Object implements ITableIterator
Asynchronous table iterator that uses a new Thread for asynchronous processing.

The producer runs on a daemon thread that communicates with this iterator through a bounded channel. If this iterator is abandoned before the producer reaches the end of the dataset, the producer thread stays parked waiting to put its next element onto the channel until the JVM exits; there is no method to cancel it early.

Since:
Apr 17, 2003
Version:
$Revision$ $Date$
Author:
Manuel Laflamme, Last changed by: $Author$
  • Constructor Details

    • StreamingIterator

      public StreamingIterator(IDataSetProducer source) throws DataSetException
      Iterator that creates a table iterator by reading the input from the given source in an asynchronous way. Therefore a Thread is created.
      Parameters:
      source - The source of the data
      Throws:
      DataSetException - if the asynchronous producer thread is interrupted before producing its first element.
  • Method Details

    • next

      public boolean next() throws DataSetException
      Description copied from interface: ITableIterator
      Position this iterator to the next table. The iterator is initially positioned before the first table; the first call to the method next makes the first table the current table; the second call makes the second table the current table, and so on.
      Specified by:
      next in interface ITableIterator
      Returns:
      true if the new current table is valid; false if there are no more table
      Throws:
      DataSetException - if advancing to the next table fails.
    • getTableMetaData

      public ITableMetaData getTableMetaData() throws DataSetException
      Description copied from interface: ITableIterator
      Returns the metadata of the current table.
      Specified by:
      getTableMetaData in interface ITableIterator
      Returns:
      the metadata of the current table.
      Throws:
      DataSetException - if retrieving the metadata fails.
    • getTable

      public ITable getTable() throws DataSetException
      Description copied from interface: ITableIterator
      Returns the current table.
      Specified by:
      getTable in interface ITableIterator
      Returns:
      the current table.
      Throws:
      DataSetException - if retrieving the table fails.