Class XPathEvaluator


  • public final class XPathEvaluator
    extends java.lang.Object
    Evaluates XPath expressions.
    Since:
    6.0.0
    Author:
    Clément Fournier
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<net.sourceforge.pmd.lang.ast.Node> evaluateQuery​(net.sourceforge.pmd.lang.ast.Node compilationUnit, net.sourceforge.pmd.lang.LanguageVersion languageVersion, java.lang.String xpathVersion, java.lang.String xpathQuery, java.util.Map<java.lang.String,​java.lang.String> propertyValues, java.util.List<PropertyDescriptorSpec> properties)
      Evaluates an XPath query on the compilation unit.
      static java.util.List<net.sourceforge.pmd.lang.ast.Node> simpleEvaluate​(DesignerRoot root, java.lang.String query)
      Evaluates the query with default parameters on the global compilation unit and with the global language version.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • simpleEvaluate

        public static java.util.List<net.sourceforge.pmd.lang.ast.Node> simpleEvaluate​(DesignerRoot root,
                                                                                       java.lang.String query)
        Evaluates the query with default parameters on the global compilation unit and with the global language version. This method hides errors.
        Returns:
        The results, or an empty list if there was an error
      • evaluateQuery

        public static java.util.List<net.sourceforge.pmd.lang.ast.Node> evaluateQuery​(net.sourceforge.pmd.lang.ast.Node compilationUnit,
                                                                                      net.sourceforge.pmd.lang.LanguageVersion languageVersion,
                                                                                      java.lang.String xpathVersion,
                                                                                      java.lang.String xpathQuery,
                                                                                      java.util.Map<java.lang.String,​java.lang.String> propertyValues,
                                                                                      java.util.List<PropertyDescriptorSpec> properties)
                                                                               throws XPathEvaluationException
        Evaluates an XPath query on the compilation unit. Performs no side effects.
        Parameters:
        compilationUnit - AST root
        languageVersion - language version
        xpathVersion - XPath version
        xpathQuery - XPath query
        properties - Properties of the rule
        Throws:
        XPathEvaluationException - if there was an error during the evaluation. The cause is preserved