net.sourceforge.cobertura.instrument

Class ClassPattern

public class ClassPattern extends Object

This class represents a collection of regular expressions that will be used to see if a classname matches them. Regular expressions are specified by calling add methods. If no add methods are called, this class will match any classname.

Author: John Lewis

Field Summary
CollectionexcludeClassesRegexes
CollectionincludeClassesRegexes
static StringWEBINF_CLASSES
Method Summary
voidaddExcludeClassesRegex(String regex)
Add a regex to the list of class regexes to exclude.
voidaddIncludeClassesRegex(String regex)
Add a regex to the list of class regexes to include.
booleanisSpecified()
Returns true if any regular expressions have been specified by calling the add methods.
booleanmatches(String filename)
Check to see if a class matches this ClassPattern If a pattern has not been specified, this matches anything.
StringremoveAnyWebInfClassesString(String filename)

Field Detail

excludeClassesRegexes

private Collection excludeClassesRegexes

includeClassesRegexes

private Collection includeClassesRegexes

WEBINF_CLASSES

private static final String WEBINF_CLASSES

Method Detail

addExcludeClassesRegex

void addExcludeClassesRegex(String regex)
Add a regex to the list of class regexes to exclude.

Parameters: regex

addIncludeClassesRegex

void addIncludeClassesRegex(String regex)
Add a regex to the list of class regexes to include.

Parameters: regex A regular expression to add.

isSpecified

boolean isSpecified()
Returns true if any regular expressions have been specified by calling the add methods. If none are specified, this class matches anything.

Returns: true if any regular expressions have been specified

matches

boolean matches(String filename)
Check to see if a class matches this ClassPattern If a pattern has not been specified, this matches anything. This method also looks for "WEB-INF/classes" at the beginning of the classname. It is removed before checking for a match.

Parameters: filename Either a full classname or a full class filename

Returns: true if the classname matches this ClassPattern or if this ClassPattern has not been specified.

removeAnyWebInfClassesString

private String removeAnyWebInfClassesString(String filename)