com.hp.hpl.jena.util.iterator
Class ConcatenatedIterator<T>

java.lang.Object
  extended by com.hp.hpl.jena.util.iterator.ConcatenatedIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>

public class ConcatenatedIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

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 2009/10/06 13:04:44 ian_dickinson Exp $
Author:
Ian Dickinson, HP Labs (email)

Constructor Summary
ConcatenatedIterator(java.util.Iterator<? extends T> iter0, java.util.Iterator<? extends T> 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.
 T next()
          Returns the next element in the interation.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
<X extends T>
void
setDefaultValue(X 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.util.Iterator<? extends T> iter0,
                            java.util.Iterator<? extends T> 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<T>
Returns:
true if the iterator has more elements.

next

public T next()
Returns the next element in the interation.

Specified by:
next in interface java.util.Iterator<T>
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<T>
Throws:
java.lang.UnsupportedOperationException - - if the remove operation is not supported by this Iterator.
java.lang.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 <X extends T> void setDefaultValue(X 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 ? 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP