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 java.lang.Object implements XPathRuleQuery
This implementation of XPathRuleQuery provides support for RuleChain visits.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<PropertyDescriptor<?>,java.lang.Object>
properties
The properties.protected java.util.List<java.lang.String>
ruleChainVisits
Subclasses can manage RuleChain visits via this list.protected java.lang.String
version
The XPath version;protected java.lang.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 Description AbstractXPathRuleQuery()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.List<Node>
evaluate(Node node, RuleContext data)
Evaluate the XPath query against the given Node.java.util.List<java.lang.String>
getRuleChainVisits()
Indicates which AST Nodes (if any) should be used with the RuleChain.protected abstract boolean
isSupportedVersion(java.lang.String version)
Subclasses should implement to indicate whether an XPath version is supported.void
setProperties(java.util.Map<PropertyDescriptor<?>,java.lang.Object> properties)
Set the properties to use during the XPath query.void
setVersion(java.lang.String version)
Set the XPath version to be used.void
setXPath(java.lang.String xpath)
Set the XPath query string to be used.
-
-
-
Field Detail
-
xpath
protected java.lang.String xpath
The XPath query string.
-
version
protected java.lang.String version
The XPath version;
-
properties
protected java.util.Map<PropertyDescriptor<?>,java.lang.Object> properties
The properties.
-
ruleChainVisits
protected final java.util.List<java.lang.String> ruleChainVisits
Subclasses can manage RuleChain visits via this list.
-
-
Method Detail
-
setXPath
public void setXPath(java.lang.String xpath)
Description copied from interface:XPathRuleQuery
Set the XPath query string to be used.- Specified by:
setXPath
in interfaceXPathRuleQuery
- Parameters:
xpath
- The XPath query string.
-
setVersion
public void setVersion(java.lang.String version) throws java.lang.UnsupportedOperationException
Description copied from interface:XPathRuleQuery
Set the XPath version to be used.- Specified by:
setVersion
in interfaceXPathRuleQuery
- Parameters:
version
- The XPath version.- Throws:
java.lang.UnsupportedOperationException
- if the version cannot be handled.
-
isSupportedVersion
protected abstract boolean isSupportedVersion(java.lang.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(java.util.Map<PropertyDescriptor<?>,java.lang.Object> properties)
Description copied from interface:XPathRuleQuery
Set the properties to use during the XPath query.- Specified by:
setProperties
in interfaceXPathRuleQuery
-
getRuleChainVisits
public java.util.List<java.lang.String> getRuleChainVisits()
Description copied from interface:XPathRuleQuery
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 interfaceXPathRuleQuery
-
evaluate
public abstract java.util.List<Node> evaluate(Node node, RuleContext data)
Description copied from interface:XPathRuleQuery
Evaluate the XPath query against the given Node.- Specified by:
evaluate
in interfaceXPathRuleQuery
- Parameters:
node
- The Node.data
- The RuleContext.- Returns:
- The matching Nodes.
-
-