|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.util.CompoundFilter<T>
public class CompoundFilter<T>
A filter that is composed of other filters.
The primary purpose of this class is to allow for the logical (AND / OR) joining of other filters -- including other compound filters. An individual filter uses only AND logic for its criteria. In those situations where you need to allow passage of particles through a filter under condition A OR condition B, create a filter for each condition and add them to a CompoundFilter using the logical OR operator.
Version Info:
$Revision: 819 $ |
$Date: 2007-08-13 16:25:44 -0600 (Mon, 13 Aug 2007) $ |
$Author: dharland $ (last person to modify) |
Constructor Summary | |
---|---|
CompoundFilter()
Creates a new wide open filter with the logical AND operator. |
|
CompoundFilter(Collection<? extends Filter<T>> filters,
LogicalOperator operator)
Creates a new compound filter with the given features. |
Method Summary | |
---|---|
CompoundFilter<T> |
add(Filter<T> newFilter)
Adds newFilter as a component of this compound filter. |
CompoundFilter<T> |
addAll(Collection<? extends Filter<T>> newFilters)
Adds each of the filters in the collection as components of this compound filter. |
boolean |
allows(T particle)
Returns true if this filter allows particle
to pass through. |
boolean |
blocks(T particle)
Returns true if this filter blocks particle
from passing through. |
CompoundFilter<T> |
remove(Filter<T> unwantedFilter)
The component filter to be removed from this compound filter. |
CompoundFilter<T> |
removeAll(Collection<? extends Filter<T>> unwantedFilters)
The component filters to be removed from this compound filter. |
CompoundFilter<T> |
removeAllFilters()
Removes all component filters from this compound filter. |
void |
setOperator(LogicalOperator newOperator)
Sets the operator to use when joining the component filters of this compound filter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompoundFilter()
AND
operator.
public CompoundFilter(Collection<? extends Filter<T>> filters, LogicalOperator operator)
filters
- the component filters for this compound filter.
If this value is null, it will be treated as
an empty collection.operator
- see setOperator(LogicalOperator)
.
IllegalArgumentException
- if operator
is neither
AND nor OR.Method Detail |
---|
public CompoundFilter<T> add(Filter<T> newFilter)
newFilter
as a component of this compound filter.
This filter will hold a reference to newFilter
, so
changes made to it after this call be reflected herein.
newFilter
- a new component filter.
public CompoundFilter<T> addAll(Collection<? extends Filter<T>> newFilters)
newFilters
- a collection of new component filters.
add(Filter)
public CompoundFilter<T> remove(Filter<T> unwantedFilter)
unwantedFilter
- the component filter to be removed.
public CompoundFilter<T> removeAll(Collection<? extends Filter<T>> unwantedFilters)
unwantedFilters
- the component filters to be removed.
public CompoundFilter<T> removeAllFilters()
public void setOperator(LogicalOperator newOperator)
LogicalOperator.AND
and LogicalOperator.OR
.
The operator is used when deciding whether or not a given particle may pass through this compound filter. In the case of AND, the particle must pass through all the component filters, while in the case of OR it pass through this filter if it passes through any of the component filters.
newOperator
- the operator for joining the component filters.
This value must be either AND
or OR
.
IllegalArgumentException
- if newOperator
is neither
AND nor OR.public boolean allows(T particle)
particle
to pass through.
This compound filter delegates filtering decisions to its component filters and uses its logical operator to combine those results. All component filters are subject to the same operator, either AND or OR. Short-circuit logic is used. That is, when using the AND operator, evaluation stops with the first component that blocks the particle; when using the OR operator, evaluation stops with the first component filter that allows passage of the particle.
allows
in interface Filter<T>
particle
- an object attempting to pass through this filter.
particle
.public boolean blocks(T particle)
particle
from passing through. This is
a convenience method that is equivalent to !allows(particle)
.
blocks
in interface Filter<T>
particle
- an object attempting to pass through this filter.
particle
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |