Class XpathUtil

java.lang.Object
com.puppycrawl.tools.checkstyle.utils.XpathUtil

public final class XpathUtil extends Object
Contains utility methods for xpath.
  • Method Details

    • supportsTextAttribute

      public static boolean supportsTextAttribute(DetailAST ast)
      Checks, if specified node can have @text attribute.
      Parameters:
      ast - DetailAst element
      Returns:
      true if element supports @text attribute, false otherwise
    • getTextAttributeValue

      public static String getTextAttributeValue(DetailAST ast)
      Returns content of the text attribute of the ast element.
      Parameters:
      ast - DetailAst element
      Returns:
      text attribute of the ast element
    • printXpathBranch

      public static String printXpathBranch(String xpath, File file) throws CheckstyleException, IOException
      Returns xpath query results on file as string.
      Parameters:
      xpath - query to evaluate
      file - file to run on
      Returns:
      all results as string separated by delimiter
      Throws:
      CheckstyleException - if some parsing error happens
      IOException - if an error occurs