net.sourceforge.pmd.lang.rule.xpath

## Class AbstractXPathRuleQuery

- java.lang.Object
- - net.sourceforge.pmd.lang.rule.xpath.AbstractXPathRuleQuery

- All Implemented Interfaces:
    XPathRuleQuery
  Direct Known Subclasses:
    JaxenXPathRuleQuery, SaxonXPathRuleQuery

      public abstract class AbstractXPathRuleQuery
      extends Object
      implements XPathRuleQuery

  This implementation of XPathRuleQuery provides support for RuleChain visits.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<PropertyDescriptor<?>,Object>` | `properties` The properties.
    `protected List<String>` | `ruleChainVisits` Subclasses can manage RuleChain visits via this list.
    `protected String` | `version` The XPath version;
    `protected String` | `xpath` The XPath query string.

    - ### Fields inherited from interface net.sourceforge.pmd.lang.rule.xpath.XPathRuleQuery

      `XPATH_1_0, XPATH_1_0_COMPATIBILITY, XPATH_2_0`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractXPathRuleQuery()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract List<Node>` | `evaluate(Node node, RuleContext data)` Evaluate the XPath query against the given Node.
    `List<String>` | `getRuleChainVisits()` Indicates which AST Nodes (if any) should be used with the RuleChain.
    `protected abstract boolean` | `isSupportedVersion(String version)` Subclasses should implement to indicate whether an XPath version is supported.
    `void` | `setProperties(Map<PropertyDescriptor<?>,Object> properties)` Set the properties to use during the XPath query.
    `void` | `setVersion(String version)` Set the XPath version to be used.
    `void` | `setXPath(String xpath)` Set the XPath query string to be used.

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

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

- - ### Field Detail

    - #### xpath

          protected String xpath

      The XPath query string.

    - #### version

          protected String version

      The XPath version;

    - #### properties

          protected Map<PropertyDescriptor<?>,Object> properties

      The properties.

    - #### ruleChainVisits

          protected final List<String> ruleChainVisits

      Subclasses can manage RuleChain visits via this list.

  - ### Constructor Detail

    - #### AbstractXPathRuleQuery

          public AbstractXPathRuleQuery()

  - ### Method Detail

    - #### setXPath

          public void setXPath(String xpath)

      Set the XPath query string to be used.
      Specified by:
        `setXPath` in interface `XPathRuleQuery`
      Parameters:
        `xpath` - The XPath query string.

    - #### setVersion

          public void setVersion(String version)
                          throws UnsupportedOperationException

      Set the XPath version to be used.
      Specified by:
        `setVersion` in interface `XPathRuleQuery`
      Parameters:
        `version` - The XPath version.
      Throws:
        `UnsupportedOperationException` - if the version cannot be handled.

    - #### isSupportedVersion

          protected abstract boolean isSupportedVersion(String version)

      Subclasses should implement to indicate whether an XPath version is supported.
      Parameters:
        `version` - The XPath version.
      Returns:
        `true` if the XPath version is supported, `false` otherwise.

    - #### setProperties

          public void setProperties(Map<PropertyDescriptor<?>,Object> properties)

      Set the properties to use during the XPath query.
      Specified by:
        `setProperties` in interface `XPathRuleQuery`

    - #### getRuleChainVisits

          public List<String> getRuleChainVisits()

      Indicates which AST Nodes (if any) should be used with the RuleChain. Use of the RuleChain will allow the query execute on a targed sub-tree of the AST, instead of the entire AST from the root. This can result in great performance benefits.
      Specified by:
        `getRuleChainVisits` in interface `XPathRuleQuery`

    - #### evaluate

          public abstract List<Node> evaluate(Node node,
                            RuleContext data)

      Evaluate the XPath query against the given Node.
      Specified by:
        `evaluate` in interface `XPathRuleQuery`
      Parameters:
        `node` - The Node.
        `data` - The RuleContext.
      Returns:
        The matching Nodes.

Copyright © 2002-2013 InfoEther. All Rights Reserved.