|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xshare.base.iterator.GlueingIterator
This iterator allows to concatenate two or more iterators
and to handle them like a single one.
Constructor Summary | |
GlueingIterator(java.util.Iterator[] pIters)
Creates an iterator which knits all iterators in a given array together. |
|
GlueingIterator(java.util.Iterator pIter1,
java.util.Iterator pIter2)
Creates an iterator which knits two other iterators together. |
Method Summary | |
void |
addIterator(java.util.Iterator pIterator)
Attaches another iteration to the GlueingIterator
after the already attached iterations.
|
boolean |
hasNext()
Checks if all elements of the underlying iterations have been returned or not. |
boolean |
isRunning()
Checks if the iterator is in use or not. |
java.lang.Object |
next()
Returns the next element of the underlying iterations. |
void |
remove()
Removes the last element returned by next()
from the underlaying iteration by forwarding the remove call
to it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GlueingIterator(java.util.Iterator pIter1, java.util.Iterator pIter2)
pIter1
- an Iterator
representing the
elements of the first iteration to add.pIter2
- an Iterator
representing the
elements of the second iteration to add.
java.lang.NullPointerException
- if one of both iterations given
as argument is null
.public GlueingIterator(java.util.Iterator[] pIters)
pIters
- an Iterator[]
array
containing all the iterations to link by this
iterator.
java.lang.NullPointerException
- if the given array of
iterators
is empty.Method Detail |
public boolean isRunning()
next()
or hasNext()
.
boolean
value which is true
if the iterator is running. Otherwise false
is
returned.public void addIterator(java.util.Iterator pIterator)
GlueingIterator
after the already attached iterations.
This operation is only allowed if the iterator is not in use.
Being in use means in this case, that someone called next()
or hasNext()
.
pIterator
- an Iterator
representing the
iteration to add to this iterator.
java.lang.IllegalStateException
- if isRunning()
returns
true
.
java.lang.NullPointerException
- if null
is passed
as argument to this method.public void remove()
next()
from the underlaying iteration by forwarding the remove call
to it.
remove
in interface java.util.Iterator
java.lang.UnsupportedOperationException
- if the source iteration
doesn't support this operation.public java.lang.Object next()
next
in interface java.util.Iterator
Object
representing the next
element in the concatenation of the all underlying
iterations.
java.util.NoSuchElementException
- if there are no more
elements left to return, indicated by hasNext()
.hasNext()
public boolean hasNext()
hasNext
in interface java.util.Iterator
boolean
value which is true
if not all elements have been returned or in other words:
it returns true
if there are some elements to return
by next()
. If this method did not return true
it will return false
. Another return value beside
true
or false
is improbably.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |