Search this API

y.util
Class FilterIterator

java.lang.Object
  extended by y.util.FilterIterator
All Implemented Interfaces:
java.util.Iterator

public final class FilterIterator
extends java.lang.Object
implements java.util.Iterator

Decorator for Iterator instances that allows the elements of the decorated Iterator to be filtered using arbitrary Filter implementations.

 

Constructor Summary
FilterIterator(java.util.Iterator iterator, Filter filter)
          Constructs a new FilterIterator.
 
Method Summary
 Filter getFilter()
          Returns the Filter that is used to determine whether or not an element of the underlying Iterator should be returned by this FilterIterator, too.
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
          Throws UnsupportedOperationException; remove is not supported by FilterIterator.
 void setFilter(Filter filter)
          Specifies the Filter that is to be used in determining whether or not an element of the underlying Iterator should be returned by this FilterIterator, too.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterIterator

public FilterIterator(java.util.Iterator iterator,
                      Filter filter)
Constructs a new FilterIterator.

Parameters:
iterator - the Iterator whose elements are to be filtered. May not be null.
filter - the Filter to be used. If null, all elements of the underlying Iterator are accepted.
Method Detail

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()
Throws UnsupportedOperationException; remove is not supported by FilterIterator.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException

getFilter

public Filter getFilter()
Returns the Filter that is used to determine whether or not an element of the underlying Iterator should be returned by this FilterIterator, too.

Returns:
the Filter that is used to determine whether or not an element of the underlying Iterator should be returned by this FilterIterator, too.

setFilter

public void setFilter(Filter filter)
Specifies the Filter that is to be used in determining whether or not an element of the underlying Iterator should be returned by this FilterIterator, too.

Parameters:
filter - the Filter that is to be used in determining whether or not an element of the underlying Iterator should be returned by this FilterIterator, too.

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.