Class RuleSetFactory

  • public class RuleSetFactory
    extends java.lang.Object
    RuleSetFactory is responsible for creating RuleSet instances from XML content. By default Rules will be loaded using the RulePriority.LOW priority, with Rule deprecation warnings off. By default, the ruleset compatibility filter is active, too. See RuleSetFactoryCompatibility.
    • Constructor Detail

      • RuleSetFactory

        public RuleSetFactory()
      • RuleSetFactory

        public RuleSetFactory​(ResourceLoader resourceLoader,
                              RulePriority minimumPriority,
                              boolean warnDeprecated,
                              boolean enableCompatibility)
      • RuleSetFactory

        public RuleSetFactory​(RuleSetFactory factory,
                              boolean warnDeprecated)
        Constructor copying all configuration from another factory.
        factory - The factory whose configuration to copy.
        warnDeprecated - Whether deprecation warnings are to be produced by this factory.
    • Method Detail

      • getRegisteredRuleSets

        public java.util.Iterator<RuleSet> getRegisteredRuleSets()
                                                          throws RuleSetNotFoundException
        Returns an Iterator of RuleSet objects loaded from descriptions from the "" resource for each Language with Rule support.
        An Iterator of RuleSet objects.
        RuleSetNotFoundException - if the ruleset file could not be found
      • createRuleSets

        public RuleSets createRuleSets​(java.util.List<RuleSetReferenceId> ruleSetReferenceIds)
                                throws RuleSetNotFoundException
        Create a RuleSets from a list of RuleSetReferenceIds. The currently configured ResourceLoader is used.
        ruleSetReferenceIds - The List of RuleSetReferenceId of the RuleSets to create.
        The new RuleSets.
        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 ResourceLoader is used.
        ruleSetReferenceId - The RuleSetReferenceId of the RuleSet to create.
        A new RuleSet.
        RuleSetNotFoundException - if unable to find a resource.
      • createRuleSetCopy

        public RuleSet createRuleSetCopy​(RuleSet original)
        Creates a copy of the given ruleset. All properties like name, description, fileName and exclude/include patterns are copied.

        Note: The rule instances are shared between the original and the new ruleset (copy-by-reference). This might lead to concurrency issues, if the original ruleset and the new ruleset are used in different threads.

        original - the original rule set to copy from
        the copy
      • createNewRuleSet

        public RuleSet createNewRuleSet​(java.lang.String name,
                                        java.lang.String description,
                                        java.lang.String fileName,
                                        java.util.Collection<java.lang.String> excludePatterns,
                                        java.util.Collection<java.lang.String> includePatterns,
                                        java.util.Collection<Rule> rules)
        Creates a new ruleset with the given metadata such as name, description, fileName, exclude/include patterns are used. The rules are taken from the given collection.

        Note: The rule instances are shared between the collection and the new ruleset (copy-by-reference). This might lead to concurrency issues, if the rules of the collection are also referenced by other rulesets and used in different threads.

        name - the name of the ruleset
        description - the description
        fileName - the filename
        excludePatterns - list of exclude patterns
        includePatterns - list of include patterns
        rules - the collection with the rules to add to the new ruleset
        the new ruleset
      • createSingleRuleRuleSet

        public RuleSet createSingleRuleRuleSet​(Rule rule)
        Creates a new RuleSet containing a single rule.
        rule - The rule being created
        The newly created RuleSet