org.apache.commons.collections.iterators
public class FilterIterator extends ProxyIterator
Iterator
which takes a Predicate
instance to filter
out objects from an underlying Iterator
instance.
Only objects for which the
specified Predicate
evaluates to true
are
returned.Constructor and Description |
---|
FilterIterator()
Constructs a new
FilterIterator that will not function
until setIterator is invoked. |
FilterIterator(java.util.Iterator iterator)
Constructs a new
FilterIterator that will not function
until setPredicate is invoked. |
FilterIterator(java.util.Iterator iterator,
Predicate predicate)
Constructs a new
FilterIterator that will use the
given iterator and predicate. |
Modifier and Type | Method and Description |
---|---|
Predicate |
getPredicate()
Getter for property predicate.
|
boolean |
hasNext()
Returns true if the underlying iterator contains an object that
matches the predicate.
|
java.lang.Object |
next()
Returns the next object that matches the predicate.
|
void |
remove()
Always throws UnsupportedOperationException as this class
does look-ahead with its internal iterator.
|
void |
setPredicate(Predicate predicate)
Setter for property predicate.
|
getIterator, setIterator
public FilterIterator()
FilterIterator
that will not function
until setIterator
is invoked.public FilterIterator(java.util.Iterator iterator)
FilterIterator
that will not function
until setPredicate
is invoked.iterator
- the iterator to usepublic FilterIterator(java.util.Iterator iterator, Predicate predicate)
FilterIterator
that will use the
given iterator and predicate.iterator
- the iterator to usepredicate
- the predicate to usepublic Predicate getPredicate()
public boolean hasNext()
hasNext
in interface java.util.Iterator
hasNext
in class ProxyIterator
public java.lang.Object next()
next
in interface java.util.Iterator
next
in class ProxyIterator
java.util.NoSuchElementException
- if there are no more elements that
match the predicatepublic void remove()
remove
in interface java.util.Iterator
remove
in class ProxyIterator
java.lang.UnsupportedOperationException
- alwayspublic void setPredicate(Predicate predicate)
predicate
- New value of property predicate.Copyright © 2001-2004 Apache Software Foundation. Documenation generated March 13 2014.