org.clapper.util.classutil
Class AndClassFilter

java.lang.Object
  extended by org.clapper.util.classutil.AndClassFilter
All Implemented Interfaces:
ClassFilter

public final class AndClassFilter
extends java.lang.Object
implements ClassFilter

An AndClassFilter logically ANDs other ClassFilter objects. When its accept() method is called, the AndClassFilter object passes the class name through the contained filters. The class name is only accepted if it is accepted by all contained filters. This class conceptually provides a logical "AND" operator for class name filters.

The contained filters are applied in the order they were added to the AndClassFilter object. This class's accept() method stops looping over the contained filters as soon as it encounters one whose accept() method returns false (implementing a "short-circuited AND" operation.)

Version:
$Revision: 6735 $
Author:
Copyright © 2006 Brian M. Clapper
See Also:
ClassFilter, OrClassFilter, NotClassFilter, ClassFinder

Constructor Summary
AndClassFilter()
          Construct a new AndClassFilter with no contained filters.
AndClassFilter(ClassFilter... filters)
          Construct a new AndClassFilter with a set of contained filters.
 
Method Summary
 boolean accept(ClassInfo classInfo, ClassFinder classFinder)
          Determine whether a class name is to be accepted or not, based on the contained filters.
 AndClassFilter addFilter(ClassFilter filter)
          Add a filter to the set of contained filters.
 java.util.Collection<ClassFilter> getFilters()
          Get the contained filters, as an unmodifiable collection.
 int getTotalFilters()
          Get the total number of contained filter objects (not counting any filter objects they, in turn, contain).
 void removeFilter(ClassFilter filter)
          Remove a filter from the set of contained filters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndClassFilter

public AndClassFilter()
Construct a new AndClassFilter with no contained filters.


AndClassFilter

public AndClassFilter(ClassFilter... filters)
Construct a new AndClassFilter with a set of contained filters. Additional filters may be added later, via calls to the addFilter() method.

Parameters:
filters - filters to add
Method Detail

addFilter

public AndClassFilter addFilter(ClassFilter filter)
Add a filter to the set of contained filters.

Parameters:
filter - the ClassFilter to add.
Returns:
this object, to permit chained calls.
See Also:
removeFilter(org.clapper.util.classutil.ClassFilter)

removeFilter

public void removeFilter(ClassFilter filter)
Remove a filter from the set of contained filters.

Parameters:
filter - the ClassFilter to remove.
See Also:
addFilter(org.clapper.util.classutil.ClassFilter)

getFilters

public java.util.Collection<ClassFilter> getFilters()
Get the contained filters, as an unmodifiable collection.

Returns:
the unmodifable Collection

getTotalFilters

public int getTotalFilters()
Get the total number of contained filter objects (not counting any filter objects they, in turn, contain).

Returns:
the total

accept

public boolean accept(ClassInfo classInfo,
                      ClassFinder classFinder)

Determine whether a class name is to be accepted or not, based on the contained filters. The class name is accepted if any one of the contained filters accepts it. This method stops looping over the contained filters as soon as it encounters one whose accept() method returns false (implementing a "short-circuited AND" operation.)

If the set of contained filters is empty, then this method returns true.

Specified by:
accept in interface ClassFilter
Parameters:
classInfo - the ClassInfo object to test
classFinder - the invoking ClassFinder object
Returns:
true if the name matches, false if it doesn't


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.