de.unidu.is.util
Class SequenceIterator

java.lang.Object
  extended byde.unidu.is.util.SequenceIterator
All Implemented Interfaces:
java.util.Iterator

public abstract class SequenceIterator
extends java.lang.Object
implements java.util.Iterator

A iterator that is a sequence of several iterators.

The sequence iterator has an iterator returning objects which can deliver iterators. The delivered iterators are traversed one after another by this iterator.

Since:
2001-06-29
Version:
$Revision: 1.6 $, $Date: 2005/02/28 22:27:55 $
Author:
Henrik Nottelmann

Field Summary
protected  boolean called
          Indicates if next() has ever been called.
protected  java.util.Iterator currentIterator
          The current iterator producing items which are returned by this class.
protected  java.util.Iterator iterator
          The iterator returning objects which can deliver iterators.
protected  java.lang.Object next
          The next object to be returned.
 
Constructor Summary
SequenceIterator(java.util.Iterator iterator)
          Creates a new sequence iterator.
 
Method Summary
protected  void calcNext()
          Calculates the next object to be returned.
abstract  java.util.Iterator createIterator(java.lang.Object object)
          Calls the speicified object to create an iterator.
 boolean hasNext()
          Returns true if this iterator has more elements.
 java.lang.Object next()
          Returns the next object.
 void remove()
          Removing objects is unsupported!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iterator

protected java.util.Iterator iterator
The iterator returning objects which can deliver iterators.


currentIterator

protected java.util.Iterator currentIterator
The current iterator producing items which are returned by this class.


next

protected java.lang.Object next
The next object to be returned.


called

protected boolean called
Indicates if next() has ever been called. This is needed for initialisation outside the constructor (because that does not work!).

Constructor Detail

SequenceIterator

public SequenceIterator(java.util.Iterator iterator)
Creates a new sequence iterator.

Parameters:
iterator - iterator returning objects which can deliver iterators
Method Detail

hasNext

public boolean hasNext()
Returns true if this iterator has more elements.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if the iterator has more elements

next

public java.lang.Object next()
Returns the next object.

Specified by:
next in interface java.util.Iterator
Returns:
next object
Throws:
java.util.NoSuchElementException - if there is no object available

calcNext

protected void calcNext()
Calculates the next object to be returned.


createIterator

public abstract java.util.Iterator createIterator(java.lang.Object object)
Calls the speicified object to create an iterator. This method has to be overridden!

Parameters:
object - object which should create an iterator
Returns:
iterator

remove

public void remove()
Removing objects is unsupported!

Specified by:
remove in interface java.util.Iterator