Class XPathVisitor

  • Direct Known Subclasses:
    HasPositionalPredChecker

    public class XPathVisitor
    extends java.lang.Object
    A derivation from this class can be passed to a class that implements the XPathVisitable interface, to have the appropriate method called for each component of the XPath. Aside from possible other uses, the main intention is to provide a reasonable means to perform expression rewriting.

    Each method has the form boolean visitComponentType(ExpressionOwner owner, ComponentType compType). The ExpressionOwner argument is the owner of the component, and can be used to reset the expression for rewriting. If a method returns false, the sub hierarchy will not be traversed.

    This class is meant to be a base class that will be derived by concrete classes, and doesn't much except return true for each method.

    • Constructor Detail

      • XPathVisitor

        public XPathVisitor()
    • Method Detail

      • visitLocationPath

        public boolean visitLocationPath()
        Visit a LocationPath.
        Returns:
        true if the sub expressions should be traversed.
      • visitUnionPath

        public boolean visitUnionPath()
        Visit a UnionPath.
        Returns:
        true if the sub expressions should be traversed.
      • visitStep

        public boolean visitStep()
        Visit a step within a location path.
        Returns:
        true if the sub expressions should be traversed.
      • visitPredicate

        public boolean visitPredicate​(Expression pred)
        Visit a predicate within a location path. Note that there isn't a proper unique component for predicates, and that the expression will be called also for whatever type Expression is.
        Parameters:
        pred - The predicate object.
        Returns:
        true if the sub expressions should be traversed.
      • visitBinaryOperation

        public boolean visitBinaryOperation()
        Visit a binary operation.
        Returns:
        true if the sub expressions should be traversed.
      • visitUnaryOperation

        public boolean visitUnaryOperation()
        Visit a unary operation.
        Returns:
        true if the sub expressions should be traversed.
      • visitFunction

        public boolean visitFunction​(Function func)
        Visit a function.
        Parameters:
        func - The function reference object.
        Returns:
        true if the sub expressions should be traversed.
      • visitMatchPattern

        public boolean visitMatchPattern()
        Visit a match pattern.
        Returns:
        true if the sub expressions should be traversed.
      • visitUnionPattern

        public void visitUnionPattern()
        Visit a union pattern.
      • visitStringLiteral

        public void visitStringLiteral()
        Visit a string literal.
      • visitNumberLiteral

        public void visitNumberLiteral()
        Visit a number literal.