blackboard.base
Class FilteringIterator

java.lang.Object
  extended by blackboard.base.FilteringIterator
All Implemented Interfaces:
java.util.Iterator
Direct Known Subclasses:
BbList.Iterator

public class FilteringIterator
extends java.lang.Object
implements java.util.Iterator

The FilteringIterator class provides a means of applying a set of "filters" to an iterator. This allows the records in an iterator to be screened, removing items that do not fit the applied filtered criteria.

Since:
Bb 5.5
Version:
$Revision: #1 $ $Date: 2005/06/27 $

Constructor Summary
FilteringIterator(java.util.Iterator iterator)
          Creates a FilteringIterator using the supplied Iterator.
FilteringIterator(java.util.Iterator iterator, ListFilter filter)
          Creates a FilteringIterator using the supplied Iterator and applying the "filtering" specified by the given ListFilter.
 
Method Summary
 void addFilter(ListFilter filter)
          Adds the given ListFilter to the list of filters applied to this iterator.
 void filterByAvailability(boolean targetAvailability)
          Applies the availability filter, AvailabilityFilter, to this FilteringIterator.
 boolean hasNext()
          Determines if any more elements that pass all applied filters exist in the iterator.
 java.lang.Object next()
          Returns the next object in the iterator which passes all applied filters.
 java.lang.Object nextObject()
          Deprecated. Use next() like a good Iterator should.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteringIterator

public FilteringIterator(java.util.Iterator iterator)
Creates a FilteringIterator using the supplied Iterator.

Parameters:
iterator - the Iterator to base this filtering iterator upon

FilteringIterator

public FilteringIterator(java.util.Iterator iterator,
                         ListFilter filter)
Creates a FilteringIterator using the supplied Iterator and applying the "filtering" specified by the given ListFilter.

Parameters:
iterator - The Iterator to base this filtering iterator upon
filter - The ListFilter to apply to the given iterator
Method Detail

hasNext

public boolean hasNext()
Determines if any more elements that pass all applied filters exist in the iterator.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if there are more elements, false otherwise

next

public java.lang.Object next()
Returns the next object in the iterator which passes all applied filters. If no more elements exist in the iterator, null is returned. To prevent problems, hasNext() method should be used prior to calling this method.

Specified by:
next in interface java.util.Iterator
Returns:
The next Object in the iterator that passes all applied filters

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

addFilter

public void addFilter(ListFilter filter)
Adds the given ListFilter to the list of filters applied to this iterator.

Parameters:
filter - the ListFilter to add to the list of filters

filterByAvailability

public void filterByAvailability(boolean targetAvailability)
Applies the availability filter, AvailabilityFilter, to this FilteringIterator.

Parameters:
targetAvailability - true if only "available" (availability flag is true) should be returned, false if only "unavailable" object should be returned
See Also:
AvailabilityFilter, Available

nextObject

public java.lang.Object nextObject()
Deprecated. Use next() like a good Iterator should.

Returns the next object in the iterator which passes all applied filters. If no more elements exist in the iterator, null is returned. To prevent problems, hasNext() method should be used prior to calling this method.

Returns:
The next Object in the iterator that passes all applied filters


Copyright © 2003 Blackboard, Inc. All Rights Reserved.