Class FilterListIterator
- java.lang.Object
-
- org.apache.commons.collections.iterators.FilterListIterator
-
- All Implemented Interfaces:
java.util.Iterator
,java.util.ListIterator
public class FilterListIterator extends java.lang.Object implements java.util.ListIterator
Decorates anotherListIterator
using a predicate to filter elements.This iterator decorates the underlying iterator, only allowing through those elements that match the specified
Predicate
.- Since:
- Commons Collections 2.0
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ListIterator
iterator
The iterator being usedprivate int
nextIndex
The index of the element that would be returned bynext()
.private java.lang.Object
nextObject
The value of the next (matching) object, whennextObjectSet
is true.private boolean
nextObjectSet
Whether or not thenextObject
has been set (possibly tonull
).private Predicate
predicate
The predicate being usedprivate java.lang.Object
previousObject
The value of the previous (matching) object, whenpreviousObjectSet
is true.private boolean
previousObjectSet
Whether or not thepreviousObject
has been set (possibly tonull
).
-
Constructor Summary
Constructors Constructor Description FilterListIterator()
Constructs a newFilterListIterator
that will not function untilsetListIterator
andsetPredicate
are invoked.FilterListIterator(java.util.ListIterator iterator)
Constructs a newFilterListIterator
that will not function untilsetPredicate
is invoked.FilterListIterator(java.util.ListIterator iterator, Predicate predicate)
Constructs a newFilterListIterator
.FilterListIterator(Predicate predicate)
Constructs a newFilterListIterator
that will not function untilsetListIterator
is invoked.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.Object o)
Not supported.private void
clearNextObject()
private void
clearPreviousObject()
java.util.ListIterator
getListIterator()
Gets the iterator this iterator is using.Predicate
getPredicate()
Gets the predicate this iterator is using.boolean
hasNext()
boolean
hasPrevious()
java.lang.Object
next()
int
nextIndex()
java.lang.Object
previous()
int
previousIndex()
void
remove()
Not supported.void
set(java.lang.Object o)
Not supported.void
setListIterator(java.util.ListIterator iterator)
Sets the iterator for this iterator to use.private boolean
setNextObject()
void
setPredicate(Predicate predicate)
Sets the predicate this the iterator to use.private boolean
setPreviousObject()
-
-
-
Field Detail
-
iterator
private java.util.ListIterator iterator
The iterator being used
-
predicate
private Predicate predicate
The predicate being used
-
nextObject
private java.lang.Object nextObject
The value of the next (matching) object, whennextObjectSet
is true.
-
nextObjectSet
private boolean nextObjectSet
Whether or not thenextObject
has been set (possibly tonull
).
-
previousObject
private java.lang.Object previousObject
The value of the previous (matching) object, whenpreviousObjectSet
is true.
-
previousObjectSet
private boolean previousObjectSet
Whether or not thepreviousObject
has been set (possibly tonull
).
-
nextIndex
private int nextIndex
The index of the element that would be returned bynext()
.
-
-
Constructor Detail
-
FilterListIterator
public FilterListIterator()
Constructs a newFilterListIterator
that will not function untilsetListIterator
andsetPredicate
are invoked.
-
FilterListIterator
public FilterListIterator(java.util.ListIterator iterator)
Constructs a newFilterListIterator
that will not function untilsetPredicate
is invoked.- Parameters:
iterator
- the iterator to use
-
FilterListIterator
public FilterListIterator(java.util.ListIterator iterator, Predicate predicate)
Constructs a newFilterListIterator
.- Parameters:
iterator
- the iterator to usepredicate
- the predicate to use
-
FilterListIterator
public FilterListIterator(Predicate predicate)
Constructs a newFilterListIterator
that will not function untilsetListIterator
is invoked.- Parameters:
predicate
- the predicate to use.
-
-
Method Detail
-
add
public void add(java.lang.Object o)
Not supported.- Specified by:
add
in interfacejava.util.ListIterator
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator
- Specified by:
hasNext
in interfacejava.util.ListIterator
-
hasPrevious
public boolean hasPrevious()
- Specified by:
hasPrevious
in interfacejava.util.ListIterator
-
next
public java.lang.Object next()
- Specified by:
next
in interfacejava.util.Iterator
- Specified by:
next
in interfacejava.util.ListIterator
-
nextIndex
public int nextIndex()
- Specified by:
nextIndex
in interfacejava.util.ListIterator
-
previous
public java.lang.Object previous()
- Specified by:
previous
in interfacejava.util.ListIterator
-
previousIndex
public int previousIndex()
- Specified by:
previousIndex
in interfacejava.util.ListIterator
-
remove
public void remove()
Not supported.- Specified by:
remove
in interfacejava.util.Iterator
- Specified by:
remove
in interfacejava.util.ListIterator
-
set
public void set(java.lang.Object o)
Not supported.- Specified by:
set
in interfacejava.util.ListIterator
-
getListIterator
public java.util.ListIterator getListIterator()
Gets the iterator this iterator is using.- Returns:
- the iterator.
-
setListIterator
public void setListIterator(java.util.ListIterator iterator)
Sets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.- Parameters:
iterator
- the iterator to use
-
getPredicate
public Predicate getPredicate()
Gets the predicate this iterator is using.- Returns:
- the predicate.
-
setPredicate
public void setPredicate(Predicate predicate)
Sets the predicate this the iterator to use.- Parameters:
predicate
- the transformer to use
-
clearNextObject
private void clearNextObject()
-
setNextObject
private boolean setNextObject()
-
clearPreviousObject
private void clearPreviousObject()
-
setPreviousObject
private boolean setPreviousObject()
-
-