oracle.ide.util
Class IteratorFilter
java.lang.Object
oracle.ide.util.IteratorFilter
- All Implemented Interfaces:
- java.util.Iterator
- public abstract class IteratorFilter
- extends java.lang.Object
- implements java.util.Iterator
This class filters elements out of a base Iterator.
Method Summary |
boolean |
hasNext()
|
protected abstract boolean |
isValid(java.lang.Object o)
|
java.lang.Object |
next()
|
void |
remove()
Due to the filter mechanism, the remove() method will throw an
IllegalStateException if hasNext() has been called after next(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IteratorFilter
public IteratorFilter(java.util.Iterator baseIterator)
isValid
protected abstract boolean isValid(java.lang.Object o)
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
next
public java.lang.Object next()
- Specified by:
next
in interface java.util.Iterator
remove
public void remove()
- Due to the filter mechanism, the remove() method will throw an
IllegalStateException if hasNext() has been called after next().
The reason is that IteratorFilter.hasNext() must call next() on the base
iterator to determine if there are element matching the filter after the
current one. For example, the following code is INVALID
Iterator i = new IteratorFilter(baseIterator);
i.next();
i.hasNext();
i.remove(); // <== IllegalStateException because hasNext() has moved the
// current pointer on the baseIterator.
- Specified by:
remove
in interface java.util.Iterator
Copyright © 1997, 2004, Oracle. All rights reserved.