net.sourceforge.cobertura.instrument

Class ClassPattern


public class ClassPattern
extends java.lang.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

private static String
WEBINF_CLASSES
private Collection
excludeClassesRegexes
private Collection
includeClassesRegexes

Method Summary

(package private) void
addExcludeClassesRegex(String regex)
Add a regex to the list of class regexes to exclude.
(package private) void
addIncludeClassesRegex(String regex)
Add a regex to the list of class regexes to include.
(package private) boolean
isSpecified()
Returns true if any regular expressions have been specified by calling the add methods.
(package private) boolean
matches(String filename)
Check to see if a class matches this ClassPattern If a pattern has not been specified, this matches anything.
private String
removeAnyWebInfClassesString(String filename)

Field Details

WEBINF_CLASSES

private static final String WEBINF_CLASSES

excludeClassesRegexes

private Collection excludeClassesRegexes

includeClassesRegexes

private Collection includeClassesRegexes

Method Details

addExcludeClassesRegex

(package private)  void addExcludeClassesRegex(String regex)
Add a regex to the list of class regexes to exclude.
Parameters:
regex -

addIncludeClassesRegex

(package private)  void addIncludeClassesRegex(String regex)
Add a regex to the list of class regexes to include.
Parameters:
regex - A regular expression to add.

isSpecified

(package private)  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

(package private)  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)