Package edu.umd.cs.findbugs
Class ClassScreener
- java.lang.Object
-
- edu.umd.cs.findbugs.ClassScreener
-
- All Implemented Interfaces:
IClassScreener
public class ClassScreener extends java.lang.Object implements IClassScreener
Class to pre-screen class files, so that only a subset are analyzed. This supports the -onlyAnalyze command line option. Modified February 2006 in four ways: a) don't break windows platform by hard-coding '/' as the directory separator b) store list of Matchers, not Patterns, so we don't keep instantiating Matchers c) fix suffix bug, so FooBar and Foo$Bar no longer match Bar d) addAllowedPackage() can now handle unicode chars in filenames, though we still may not be handling every case mentioned in section 7.2.1 of the JLS- See Also:
FindBugs
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.LinkedList<java.util.regex.Matcher>excludePatternListprivate java.util.LinkedList<java.util.regex.Matcher>includePatternListprivate static java.lang.StringJAVA_IDENTIFIER_PARTregular expression fragment to match a char of a class or package name.private static org.slf4j.LoggerLOGprivate static java.lang.StringSEPregular expression fragment to match a directory separator.private static java.lang.StringSTART
-
Constructor Summary
Constructors Constructor Description ClassScreener()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllowedClass(java.lang.String className)Add the name of a class to be matched by the screener.voidaddAllowedPackage(java.lang.String packageName)Add the name of a package to be matched by the screener.voidaddAllowedPrefix(java.lang.String prefix)Add the name of a prefix to be matched by the screener.private static java.util.regex.MatcherclassMatcher(java.lang.String className)private static java.lang.StringdotsToRegex(java.lang.String dotsName)replace the dots in a fully-qualified class/package name to a regular expression fragment that will match file names.booleanmatches(java.lang.String fileName)Return whether or not the name of the given file matches.private static java.util.regex.MatcherpackageMatcher(java.lang.String packageName)private static java.util.regex.MatcherprefixMatcher(java.lang.String prefix)booleanvacuous()Does the class screener always return true?
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
SEP
private static final java.lang.String SEP
regular expression fragment to match a directory separator. note: could use File.separatorChar instead, but that could be argued to be not general enough- See Also:
- Constant Field Values
-
START
private static final java.lang.String START
- See Also:
- Constant Field Values
-
JAVA_IDENTIFIER_PART
private static final java.lang.String JAVA_IDENTIFIER_PART
regular expression fragment to match a char of a class or package name. Actually, we just allow any char except a dot or a directory separator.- See Also:
- Constant Field Values
-
includePatternList
private final java.util.LinkedList<java.util.regex.Matcher> includePatternList
-
excludePatternList
private final java.util.LinkedList<java.util.regex.Matcher> excludePatternList
-
-
Method Detail
-
dotsToRegex
private static java.lang.String dotsToRegex(java.lang.String dotsName)
replace the dots in a fully-qualified class/package name to a regular expression fragment that will match file names.- Parameters:
dotsName- such as "java.io" or "java.io.File"- Returns:
- regex fragment such as "java[/\\\\]io" (single backslash escaped twice)
-
addAllowedClass
public void addAllowedClass(java.lang.String className)
Add the name of a class to be matched by the screener.- Parameters:
className- name of a class to be matched
-
classMatcher
private static java.util.regex.Matcher classMatcher(java.lang.String className)
-
addAllowedPackage
public void addAllowedPackage(java.lang.String packageName)
Add the name of a package to be matched by the screener. All class files that appear to be in the package should be matched.- Parameters:
packageName- name of the package to be matched
-
packageMatcher
private static java.util.regex.Matcher packageMatcher(java.lang.String packageName)
-
addAllowedPrefix
public void addAllowedPrefix(java.lang.String prefix)
Add the name of a prefix to be matched by the screener. All class files that appear to be in the package specified by the prefix, or a more deeply nested package, should be matched.- Parameters:
prefix- name of the prefix to be matched
-
prefixMatcher
private static java.util.regex.Matcher prefixMatcher(java.lang.String prefix)
-
matches
public boolean matches(java.lang.String fileName)
Description copied from interface:IClassScreenerReturn whether or not the name of the given file matches.- Specified by:
matchesin interfaceIClassScreener
-
vacuous
public boolean vacuous()
Description copied from interface:IClassScreenerDoes the class screener always return true?- Specified by:
vacuousin interfaceIClassScreener
-
-