net.sourceforge.pmd.lang.rule
Class XPathRule

java.lang.Object
  extended by net.sourceforge.pmd.AbstractPropertySource
      extended by net.sourceforge.pmd.lang.rule.AbstractRule
          extended by net.sourceforge.pmd.lang.rule.XPathRule
All Implemented Interfaces:
PropertySource, Rule

public class XPathRule
extends AbstractRule

Rule that tries to match an XPath expression against a DOM view of an AST.

This rule needs a "xpath" property value in order to function.


Field Summary
static EnumeratedProperty<String> VERSION_DESCRIPTOR
           
static StringProperty XPATH_DESCRIPTOR
           
 
Fields inherited from class net.sourceforge.pmd.AbstractPropertySource
propertyDescriptors, propertyValuesByDescriptor
 
Fields inherited from interface net.sourceforge.pmd.Rule
VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR
 
Constructor Summary
XPathRule()
           
XPathRule(String xPath)
           
 
Method Summary
 void apply(List<? extends Node> nodes, RuleContext ctx)
          Apply the rule to all nodes.
 String dysfunctionReason()
          Returns a description of why the receiver may be dysfunctional.
 void evaluate(Node node, RuleContext data)
          Evaluate the XPath query with the AST node.
 List<String> getRuleChainVisits()
          Gets the collection of AST node names visited by the Rule on the RuleChain.
 boolean hasXPathExpression()
           
 void setVersion(String version)
           
 void setXPath(String xPath)
           
 
Methods inherited from class net.sourceforge.pmd.lang.rule.AbstractRule
addExample, addRuleChainVisit, addRuleChainVisit, addViolation, addViolation, addViolation, addViolationWithMessage, addViolationWithMessage, addViolationWithMessage, deepCopyValuesTo, end, equals, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getParserOptions, getPriority, getRuleClass, getRuleSetName, getSince, hashCode, isDeprecated, setDeprecated, setDescription, setExternalInfoUrl, setLanguage, setMaximumLanguageVersion, setMessage, setMinimumLanguageVersion, setName, setPriority, setRuleClass, setRuleSetName, setSince, setUsesDFA, setUsesTypeResolution, start, usesDFA, usesRuleChain, usesTypeResolution
 
Methods inherited from class net.sourceforge.pmd.AbstractPropertySource
copyPropertyDescriptors, copyPropertyValues, definePropertyDescriptor, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, useDefaultValueFor, usesDefaultValues
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.pmd.PropertySource
definePropertyDescriptor, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, useDefaultValueFor, usesDefaultValues
 

Field Detail

XPATH_DESCRIPTOR

public static final StringProperty XPATH_DESCRIPTOR

VERSION_DESCRIPTOR

public static final EnumeratedProperty<String> VERSION_DESCRIPTOR
Constructor Detail

XPathRule

public XPathRule()

XPathRule

public XPathRule(String xPath)
Method Detail

setXPath

public void setXPath(String xPath)

setVersion

public void setVersion(String version)

apply

public void apply(List<? extends Node> nodes,
                  RuleContext ctx)
Apply the rule to all nodes.

Parameters:
nodes - the nodes
ctx - the rule context

evaluate

public void evaluate(Node node,
                     RuleContext data)
Evaluate the XPath query with the AST node. All matches are reported as violations.

Parameters:
node - The Node that to be checked.
data - The RuleContext.

getRuleChainVisits

public List<String> getRuleChainVisits()
Description copied from interface: Rule
Gets the collection of AST node names visited by the Rule on the RuleChain.

Specified by:
getRuleChainVisits in interface Rule
Overrides:
getRuleChainVisits in class AbstractRule
Returns:
the list of AST node names
See Also:
Rule.getRuleChainVisits()

hasXPathExpression

public boolean hasXPathExpression()

dysfunctionReason

public String dysfunctionReason()
Description copied from class: AbstractPropertySource
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.

Specified by:
dysfunctionReason in interface PropertySource
Overrides:
dysfunctionReason in class AbstractPropertySource
Returns:
String
See Also:
PropertySource.dysfunctionReason()


Copyright © 2002-2015 InfoEther. All Rights Reserved.