net.sourceforge.pmd

Class RuleSet

public class RuleSet extends Object

This class represents a collection of rules.

See Also: Rule

Method Summary
voidaddExcludePattern(String excludePattern)
voidaddExcludePatterns(List<String> excludePatterns)
voidaddIncludePattern(String includePattern)
voidaddIncludePatterns(List<String> includePatterns)
voidaddRule(Rule rule)
Add a new rule to this ruleset
voidaddRuleByReference(String ruleSetFileName, Rule rule)
Add a new rule by reference to this ruleset.
voidaddRuleSet(RuleSet ruleSet)
Add a whole RuleSet to this RuleSet
voidaddRuleSetByReference(RuleSet ruleSet, boolean allRules)
Add all rules by reference from one RuleSet to this RuleSet.
booleanapplies(File file)
Check if a given source file should be checked by rules in this RuleSet.
voidapply(List acuList, RuleContext ctx)
voidend(RuleContext ctx)
booleanequals(Object o)
StringgetDescription()
List<String>getExcludePatterns()
StringgetFileName()
List<String>getIncludePatterns()
LanguagegetLanguage()
StringgetName()
RulegetRuleByName(String ruleName)
Returns the Rule with the given name
Collection<Rule>getRules()
Returns the actual Collection of rules in this ruleset
inthashCode()
voidsetDescription(String description)
voidsetExcludePatterns(List<String> excludePatterns)
voidsetFileName(String fileName)
voidsetIncludePatterns(List<String> includePatterns)
voidsetLanguage(Language language)
voidsetName(String name)
intsize()
Returns the number of rules in this ruleset
voidstart(RuleContext ctx)
booleanusesDFA()
booleanusesTypeResolution()

Method Detail

addExcludePattern

public void addExcludePattern(String excludePattern)

addExcludePatterns

public void addExcludePatterns(List<String> excludePatterns)

addIncludePattern

public void addIncludePattern(String includePattern)

addIncludePatterns

public void addIncludePatterns(List<String> includePatterns)

addRule

public void addRule(Rule rule)
Add a new rule to this ruleset

Parameters: rule the rule to be added

addRuleByReference

public void addRuleByReference(String ruleSetFileName, Rule rule)
Add a new rule by reference to this ruleset.

Parameters: ruleSetFileName the ruleset which contains the rule rule the rule to be added

addRuleSet

public void addRuleSet(RuleSet ruleSet)
Add a whole RuleSet to this RuleSet

Parameters: ruleSet the RuleSet to add

addRuleSetByReference

public void addRuleSetByReference(RuleSet ruleSet, boolean allRules)
Add all rules by reference from one RuleSet to this RuleSet. The rules can be added as individual references, or collectively as an all rule reference.

Parameters: ruleSet the RuleSet to add allRules

applies

public boolean applies(File file)
Check if a given source file should be checked by rules in this RuleSet. A file should not be checked if there is an exclude pattern which matches the file, unless there is an include pattern which also matches the file. In other words, include patterns override exclude patterns.

Parameters: file the source file to check

Returns: true if the file should be checked, false otherwise

apply

public void apply(List acuList, RuleContext ctx)

end

public void end(RuleContext ctx)

equals

public boolean equals(Object o)

See Also: java.lang.Object#equals(java.lang.Object)

getDescription

public String getDescription()

getExcludePatterns

public List<String> getExcludePatterns()

getFileName

public String getFileName()

getIncludePatterns

public List<String> getIncludePatterns()

getLanguage

public Language getLanguage()

getName

public String getName()

getRuleByName

public Rule getRuleByName(String ruleName)
Returns the Rule with the given name

Parameters: ruleName the name of the rule to find

Returns: the rule or null if not found

getRules

public Collection<Rule> getRules()
Returns the actual Collection of rules in this ruleset

Returns: a Collection with the rules. All objects are of type Rule

hashCode

public int hashCode()

See Also: java.lang.Object#hashCode()

setDescription

public void setDescription(String description)

setExcludePatterns

public void setExcludePatterns(List<String> excludePatterns)

setFileName

public void setFileName(String fileName)

setIncludePatterns

public void setIncludePatterns(List<String> includePatterns)

setLanguage

public void setLanguage(Language language)

setName

public void setName(String name)

size

public int size()
Returns the number of rules in this ruleset

Returns: an int representing the number of rules

start

public void start(RuleContext ctx)

usesDFA

public boolean usesDFA()

Returns: true if any rule in the RuleSet needs the DFA layer

usesTypeResolution

public boolean usesTypeResolution()