Package edu.umd.cs.findbugs
Class ClassScreener
java.lang.Object
edu.umd.cs.findbugs.ClassScreener
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedList
<Matcher> private final LinkedList
<Matcher> private static final String
regular expression fragment to match a char of a class or package name.private static final org.slf4j.Logger
private static final String
regular expression fragment to match a directory separator.private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllowedClass
(String className) Add the name of a class to be matched by the screener.void
addAllowedPackage
(String packageName) Add the name of a package to be matched by the screener.void
addAllowedPrefix
(String prefix) Add the name of a prefix to be matched by the screener.private static Matcher
classMatcher
(String className) private static String
dotsToRegex
(String dotsName) replace the dots in a fully-qualified class/package name to a regular expression fragment that will match file names.boolean
Return whether or not the name of the given file matches.private static Matcher
packageMatcher
(String packageName) private static Matcher
prefixMatcher
(String prefix) boolean
vacuous()
Does the class screener always return true?
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
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:
-
START
- See Also:
-
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:
-
includePatternList
-
excludePatternList
-
-
Constructor Details
-
ClassScreener
public ClassScreener()Constructor. By default, the ClassScreener will match all class files. Once addAllowedClass() and addAllowedPackage() are called, the ClassScreener will only match the explicitly included classes and packages unless explicitly excluded.
-
-
Method Details
-
dotsToRegex
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
Add the name of a class to be matched by the screener.- Parameters:
className
- name of a class to be matched
-
classMatcher
-
addAllowedPackage
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
-
addAllowedPrefix
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
-
matches
Description copied from interface:IClassScreener
Return whether or not the name of the given file matches.- Specified by:
matches
in interfaceIClassScreener
-
vacuous
public boolean vacuous()Description copied from interface:IClassScreener
Does the class screener always return true?- Specified by:
vacuous
in interfaceIClassScreener
-