com.hp.hpl.jena.util
Class ConcatenatedIterator

java.lang.Object
  |
  +--com.hp.hpl.jena.util.ConcatenatedIterator
All Implemented Interfaces:
java.util.Iterator

public class ConcatenatedIterator
extends java.lang.Object
implements java.util.Iterator

An iterator that represents the concatenation of two individual iterators. The concatenated iterator will range over the elements of the first iterator, followed by the elements of the second.

Version:
CVS info: $Id: ConcatenatedIterator.java,v 1.2 2001/09/25 16:22:11 ijd Exp $
Author:
Ian Dickinson, HP Labs (email)

Constructor Summary
ConcatenatedIterator(java.lang.Object iter0, java.lang.Object iter1)
          Construct an iterator that is the concatenation of the two given iterators.
 
Method Summary
 boolean hasDefaultValue()
          Answer true if this iteration has a default value.
 boolean hasNext()
          Returns true if the iteration has more elements.
 java.lang.Object next()
          Returns the next element in the interation.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
 void setDefaultValue(java.lang.Object defaultValue)
          Set the default value for this iteration, which will be a value that is guaranteed to be returned as a member of the iteration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcatenatedIterator

public ConcatenatedIterator(java.lang.Object iter0,
                            java.lang.Object iter1)
Construct an iterator that is the concatenation of the two given iterators. Either iterator may be a Java iterator, or a Jena node or resource iterator.
Parameters:
iter0 - The first iterator. Elements of this iterator will appear first in the elements read from the concatenation.
iter1 - The second iterator. Elements of this iterator will appear second in the elements read from the concatenation.
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. This will be true if either of the underlying iterators 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 element in the interation.
Specified by:
next in interface java.util.Iterator
Returns:
The next object in the iteration, which will correspond to the next object in the underlying iteration, projected to the range of the projection function.
Throws:
java.util.NoSuchElementException - - iteration has no more elements.

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). Not supported on a concatenated iterator.
Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - - if the remove operation is not supported by this Iterator.
IllegalStateException - - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Set the default value for this iteration, which will be a value that is guaranteed to be returned as a member of the iteration. To guarantee that the default value is only returned if it has not already been returned by the iterator, setting the default value should occur before the first call to next().
Parameters:
defaultValue - The default value for the iteration, or null for there to be no default value. The default default value is null.

hasDefaultValue

public boolean hasDefaultValue()
Answer true if this iteration has a default value.
Returns:
true if there is a default value


Copyright 2001 Hewlett-Packard. All Rights Reserved.