Class XPathRule

  • All Implemented Interfaces:
    Rule, PropertySource

    public final class XPathRule
    extends AbstractRule
    Rule that tries to match an XPath expression against a DOM view of an AST.
    • Constructor Detail

      • XPathRule

        public XPathRule​(XPathVersion version,
                         String expression)
        Make a new XPath rule with the given version + expression
        Parameters:
        version - Version of the XPath language
        expression - XPath expression
        Throws:
        NullPointerException - If any of the arguments is null
    • Method Detail

      • deepCopy

        public Rule deepCopy()
        Description copied from interface: Rule
        Creates a new copy of this rule.
        Specified by:
        deepCopy in interface Rule
        Overrides:
        deepCopy in class AbstractRule
        Returns:
        A new exact copy of this rule
      • getXPathExpression

        public String getXPathExpression()
        Returns the XPath expression that implements this rule.
      • apply

        public void apply​(Node target,
                          RuleContext ctx)
        Description copied from interface: Rule
        Process the given node. The nodes that are fed to this method are the nodes selected by Rule.getTargetSelector().
        Parameters:
        target - Node on which to apply the rule
        ctx - Rule context, handling violations
      • initialize

        public void initialize​(LanguageProcessor languageProcessor)
        Description copied from interface: Rule
        Initialize the rule using the language processor if needed.
        Parameters:
        languageProcessor - The processor for the rule's language
      • dysfunctionReason

        public String dysfunctionReason()
        Description copied from interface: PropertySource
        Returns a description of why the receiver may be dysfunctional. Usually due to missing property values or some kind of conflict between values. Returns null if the receiver is ok.
        Returns:
        String