net.sourceforge.pmd

## Class RuleSetFactory

- java.lang.Object
- - net.sourceforge.pmd.RuleSetFactory

    public class RuleSetFactory
    extends Object

RuleSetFactory is responsible for creating RuleSet instances from XML content. By default Rules will be loaded using the ClassLoader for this class, using the `RulePriority.LOW` priority, with Rule deprecation warnings off.

### Constructor Summary

Constructors
Constructor and Description
`RuleSetFactory()`

### Method Summary

Methods
`RuleSet` `createRuleSet(RuleSetReferenceId ruleSetReferenceId)` Create a RuleSet from a RuleSetReferenceId.
`RuleSet` `createRuleSet(String referenceString)` Create a RuleSet from a RuleSet reference ID string.
`RuleSets` `createRuleSets(List<RuleSetReferenceId> ruleSetReferenceIds)` Create a RuleSets from a list of RuleSetReferenceIds.
`RuleSets` `createRuleSets(String referenceString)` Create a RuleSets from a comma separated list of RuleSet reference IDs.
`Iterator<RuleSet>` `getRegisteredRuleSets()` Returns an Iterator of RuleSet objects loaded from descriptions from the "rulesets.properties" resource for each Language with Rule support.
`void` `setClassLoader(ClassLoader classLoader)` Set the ClassLoader to use when loading Rules.
`void` `setMinimumPriority(RulePriority minimumPriority)` Set the minimum rule priority threshold for all Rules which are loaded from RuleSets via reference.
`void` `setWarnDeprecated(boolean warnDeprecated)` Set whether warning messages should be logged for usage of deprecated Rules.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### RuleSetFactory

    public RuleSetFactory()

### Method Detail

#### setClassLoader

    public void setClassLoader(ClassLoader classLoader)

Set the ClassLoader to use when loading Rules.

Parameters:
  `classLoader` - The ClassLoader to use.

#### setMinimumPriority

    public void setMinimumPriority(RulePriority minimumPriority)

Set the minimum rule priority threshold for all Rules which are loaded from RuleSets via reference.

Parameters:
  `minimumPriority` - The minimum priority.

#### setWarnDeprecated

    public void setWarnDeprecated(boolean warnDeprecated)

Set whether warning messages should be logged for usage of deprecated Rules.

Parameters:
  `warnDeprecated` - `true` to log warning messages.

#### getRegisteredRuleSets

    public Iterator<RuleSet> getRegisteredRuleSets()
                                            throws RuleSetNotFoundException

Returns an Iterator of RuleSet objects loaded from descriptions from the "rulesets.properties" resource for each Language with Rule support.

Returns:
  An Iterator of RuleSet objects.
Throws:
  `RuleSetNotFoundException`

#### createRuleSets

    public RuleSets createRuleSets(String referenceString)
                            throws RuleSetNotFoundException

Create a RuleSets from a comma separated list of RuleSet reference IDs. This is a convenience method which calls `RuleSetReferenceId.parse(String)`, and then calls `createRuleSets(List)`. The currently configured ClassLoader is used.

Parameters:
  `referenceString` - A comma separated list of RuleSet reference IDs.
Returns:
  The new RuleSets.
Throws:
  `RuleSetNotFoundException` - if unable to find a resource.

#### createRuleSets

    public RuleSets createRuleSets(List<RuleSetReferenceId> ruleSetReferenceIds)
                            throws RuleSetNotFoundException

Create a RuleSets from a list of RuleSetReferenceIds. The currently configured ClassLoader is used.

Parameters:
  `ruleSetReferenceIds` - The List of RuleSetReferenceId of the RuleSets to create.
Returns:
  The new RuleSets.
Throws:
  `RuleSetNotFoundException` - if unable to find a resource.

#### createRuleSet

    public RuleSet createRuleSet(String referenceString)
                          throws RuleSetNotFoundException

Create a RuleSet from a RuleSet reference ID string. This is a convenience method which calls `RuleSetReferenceId.parse(String)`, gets the first item in the List, and then calls `createRuleSet(RuleSetReferenceId)`. The currently configured ClassLoader is used.

Parameters:
  `referenceString` - A comma separated list of RuleSet reference IDs.
Returns:
  A new RuleSet.
Throws:
  `RuleSetNotFoundException` - if unable to find a resource.

#### createRuleSet

    public RuleSet createRuleSet(RuleSetReferenceId ruleSetReferenceId)
                          throws RuleSetNotFoundException

Create a RuleSet from a RuleSetReferenceId. Priority filtering is ignored when loading a single Rule. The currently configured ClassLoader is used.

Parameters:
  `ruleSetReferenceId` - The RuleSetReferenceId of the RuleSet to create.
Returns:
  A new RuleSet.
Throws:
  `RuleSetNotFoundException` - if unable to find a resource.