org.opensaml.xml.security
Class CriteriaFilteringIterator<T>

java.lang.Object
  extended by org.opensaml.xml.security.CriteriaFilteringIterator<T>
Type Parameters:
T - the type of candidate elements being evaluated
All Implemented Interfaces:
Iterator<T>

public class CriteriaFilteringIterator<T>
extends Object
implements Iterator<T>

This implementation of Iterator wraps another Iterator of a particular type, containing candidates which are to be evaluated against a given set of EvaluableCriteria. When the iterator is traversed, criteria evaluation is performed on each candidate element of the underlying wrapped iterator via EvaluableCriteria.evaluate(Object). Only those elements which satisfy the criteria indicated by the criteria set are returned by the Iterator, as follows.

If the parameter meetAllCriteria is true, then all criteria in the criteria set must be satisfied in order for the element to be returned. This in essence connects the criteria of the criteria set with a logical AND. If false, then if an element satisfies any of the criteria of the criteria set, it will be returned. This in essence connects the members of the criteria set with a logical OR.

If the parameter unevaluableSatisfies is true, then if a criteria's evaluation of the candidate via EvaluableCriteria.evaluate(Object) indicates that it is unable to evaluate the candidate, the criteria will be considered satisfied as far as the determination of whether to return the candidate. If false, then the criteria will be considered unsatisfied for purposes of this determination.

Care should be exercised in combining these two parameter values to achieve the desired result.


Field Summary
private  Iterator<? extends T> candidateIter
          The candidates to evaluate.
private  Set<EvaluableCriteria<T>> criteriaSet
          The set of criteria against which to evaluate the candidates.
private  T current
          The current candidate which will be returned by the next call to next().
private  boolean meetAll
          Flag indicating whether the candidate must satisfy all the criteria in the set, or just one.
private  boolean unevaledSatisfies
          Flag indicating how candidates which can not be evaluated by a criteria are to be handled.
 
Constructor Summary
CriteriaFilteringIterator(Iterator<? extends T> candidatesIterator, Set<EvaluableCriteria<T>> criteria, boolean meetAllCriteria, boolean unevaluableSatisfies)
          Constructor.
 
Method Summary
private  T getNextMatch()
          Get the next matching candidate.
 boolean hasNext()
          
private  boolean match(T candidate)
          Evaluate the candidate against all the criteria.
 T next()
          
 void remove()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

candidateIter

private Iterator<? extends T> candidateIter
The candidates to evaluate.


criteriaSet

private Set<EvaluableCriteria<T>> criteriaSet
The set of criteria against which to evaluate the candidates.


meetAll

private boolean meetAll
Flag indicating whether the candidate must satisfy all the criteria in the set, or just one.


unevaledSatisfies

private boolean unevaledSatisfies
Flag indicating how candidates which can not be evaluated by a criteria are to be handled.


current

private T current
The current candidate which will be returned by the next call to next().

Constructor Detail

CriteriaFilteringIterator

public CriteriaFilteringIterator(Iterator<? extends T> candidatesIterator,
                                 Set<EvaluableCriteria<T>> criteria,
                                 boolean meetAllCriteria,
                                 boolean unevaluableSatisfies)
Constructor.

Parameters:
candidatesIterator - the candidates to evaluate
criteria - the set of criteria against which to evaluate the candidates
meetAllCriteria - whether a candidate must meet all criteria, or just one
unevaluableSatisfies - whether a can-not-evaluate result of a particular criteria's evaluation is treated as the candidate having satisfied or not satisfied the criteria, for purposes of determinig whether to return the element
Method Detail

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator<T>

next

public T next()

Specified by:
next in interface Iterator<T>

remove

public void remove()

Specified by:
remove in interface Iterator<T>

getNextMatch

private T getNextMatch()
Get the next matching candidate.

Returns:
the next matching candidate

match

private boolean match(T candidate)
Evaluate the candidate against all the criteria.

Parameters:
candidate - the candidate to evaluate
Returns:
true if the candidate satisfies the set of criteria, false otherwise


Copyright © 1999-2013. All Rights Reserved.