Package org.htmlunit.xpath
Class XPathVisitor
- java.lang.Object
-
- org.htmlunit.xpath.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 Summary
Constructors Constructor Description XPathVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
visitBinaryOperation()
Visit a binary operation.boolean
visitFunction(Function func)
Visit a function.boolean
visitLocationPath()
Visit a LocationPath.boolean
visitMatchPattern()
Visit a match pattern.void
visitNumberLiteral()
Visit a number literal.boolean
visitPredicate(Expression pred)
Visit a predicate within a location path.boolean
visitStep()
Visit a step within a location path.void
visitStringLiteral()
Visit a string literal.boolean
visitUnaryOperation()
Visit a unary operation.boolean
visitUnionPath()
Visit a UnionPath.void
visitUnionPattern()
Visit a union pattern.
-
-
-
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.
-
-