org.clapper.util.classutil
Class RegexClassFilter

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

public class RegexClassFilter
extends java.lang.Object
implements ClassFilter

RegexClassFilter is a ClassFilter that matches class names using a regular expression. Multiple regular expression filters can be combined using AndClassFilter and/or OrClassFilter objects.

This class does not have to load the classes it's filtering; it matches on the class name only.

RegexClassFilter uses the java.util.regex regular expression classes.

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

Constructor Summary
RegexClassFilter(java.lang.String regex)
          Construct a new RegexClassFilter using the specified pattern.
RegexClassFilter(java.lang.String regex, int regexFlags)
          Construct a new RegexClassFilter using the specified pattern.
 
Method Summary
 boolean accept(ClassInfo classInfo, ClassFinder classFinder)
          Determine whether a class name is to be accepted or not, based on the regular expression specified to the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexClassFilter

public RegexClassFilter(java.lang.String regex)
                 throws java.util.regex.PatternSyntaxException
Construct a new RegexClassFilter using the specified pattern.

Parameters:
regex - the regular expression to add
Throws:
java.util.regex.PatternSyntaxException - bad regular expression

RegexClassFilter

public RegexClassFilter(java.lang.String regex,
                        int regexFlags)
                 throws java.util.regex.PatternSyntaxException
Construct a new RegexClassFilter using the specified pattern.

Parameters:
regex - the regular expression to add
regexFlags - regular expression compilation flags (e.g., Pattern.CASE_INSENSITIVE). See the Javadocs for java.util.regex for legal values.
Throws:
java.util.regex.PatternSyntaxException - bad regular expression
Method Detail

accept

public boolean accept(ClassInfo classInfo,
                      ClassFinder classFinder)
Determine whether a class name is to be accepted or not, based on the regular expression specified to the constructor.

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


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