net.sourceforge.pmd

Class RuleSets

public class RuleSets extends Object

Grouping of Rules per Language in a RuleSet.

Author: pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be

Constructor Summary
RuleSets()
Public constructor.
RuleSets(RuleSet ruleSet)
Public constructor.
Method Summary
voidaddRuleSet(RuleSet ruleSet)
Add a ruleset for a language.
booleanapplies(Language languageOfSource, Language languageOfRule)
Check if a source with given language should be checked by rules for a given language.
voidapply(List acuList, RuleContext ctx, Language language)
Apply all applicable rules to the compilation units.
SetgetAllRules()
Return all rules from all rulesets.
RuleSet[]getAllRuleSets()
Get all the RuleSets.
RulegetRuleByName(String ruleName)
Returns the Rule with the given name
booleanusesDFA(Language language)
Check if the rules that apply to a source of the given language use DFA.

Constructor Detail

RuleSets

public RuleSets()
Public constructor.

RuleSets

public RuleSets(RuleSet ruleSet)
Public constructor. Add the given rule set.

Parameters: ruleSet the RuleSet

Method Detail

addRuleSet

public void addRuleSet(RuleSet ruleSet)
Add a ruleset for a language. Only one ruleset can be added for a specific language. If ruleSet.getLanguage() is null, it is assumed to be a RuleSet of java rules.

Parameters: ruleSet the RuleSet

applies

public boolean applies(Language languageOfSource, Language languageOfRule)
Check if a source with given language should be checked by rules for a given language. This is the case if both languages are equal, or if the source is in java, and the language of the rules is unknown (for backward-compatibility reasons).

Parameters: languageOfSource language of a source; can not be null languageOfRule language of a ruleset; can be null

Returns:

apply

public void apply(List acuList, RuleContext ctx, Language language)
Apply all applicable rules to the compilation units. Applicable means the language of the rules must match the language of the source (@see applies).

Parameters: acuList the List of compilation units; the type these must have, depends on the source language ctx the RuleContext language the Language of the source

getAllRules

public Set getAllRules()
Return all rules from all rulesets.

Returns: Set

getAllRuleSets

public RuleSet[] getAllRuleSets()
Get all the RuleSets.

Returns: RuleSet[]

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

usesDFA

public boolean usesDFA(Language language)
Check if the rules that apply to a source of the given language use DFA.

Parameters: language the language of a source

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