public class FilteredIterator extends Object implements Iterator
Iterator
. Because this class must advance
the underlying Iterator
to correctly implement hasNext()
, remove()
has unusual semantics. See the
javadocs for that method for details.Constructor and Description |
---|
FilteredIterator(Iterator delegate,
org.apache.commons.collections.Predicate predicate)
Creates a new
FilteredIterator . |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
Object |
next() |
void |
remove()
Removes from the last object returned by
next . |
protected void |
remove(Object object)
This method is called by
remove() if
hasNext() was called after the last calls to both
next() and remove() (if any) and
remove() has not been called after the last call
to next() . |
public FilteredIterator(Iterator delegate, org.apache.commons.collections.Predicate predicate)
FilteredIterator
.public void remove()
next
.
Because the underlying Iterator
must be advanced
to correctly implement hasNext()
, this method has
unusual semantics. These are the possible states that an
instance of this class may be in, and how this method will
behave:
next()
has not yet been called or
remove()
was called after the last call to
next()
, throws an
IllegalStateException
. These are the same
conditions under which any implementation of
Iterator.remove
should throw an exception.
next()
was called after the last calls
to both hasNext()
and remove()
(if any), delegates to the remove()
method
of the underlying Iterator
.
hasNext()
was called after the last
calls to both next()
and
remove()
(if any) and remove()
has not been called after the last call to
next()
, calls remove( Object )
with the element last returned by
next()
. In other words, the underlying
Iterator
has been advanced beyond the
element to be removed.
Description copied from interface: Iterator
protected void remove(Object object)
remove()
if
hasNext()
was called after the last calls to both
next()
and remove()
(if any) and
remove()
has not been called after the last call
to next()
. In other words, this method is called
if the call sequence goes something like next(),
hasNext(), remove()
, which means the underlying
Iterator
has been advanced beyond the element to
be removed. This provides an extension point for an
implementation to correctly handle this case if it is capable
of doing so.
This implementation throws an
IllegalStateException
.
See the Plexus project home, hosted by SourceForge.
Copyright ? 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.