Interface FilterVisitor

  • All Known Implementing Classes:
    BranchNormalizedVisitor

    public interface FilterVisitor
    Filter expression tree node visitor interface. Note that this is a variation of the extrinsic visitor variation. It has the following advantages over the standard visitor pattern:
    • Visitor takes responsibility that a visitor can visit a node
    • Each visitor knows which types of concrete classes it can visit
    • New visitors can be created without changing the node class
    • New node classes can be added without having to change old visitors
    • Visitation order can be controled in every respect:
      • Visitation rejection with canVisit() and/or getOrder()
      • Recursive visitation ordering with isPrefix()
      • Child visitation ordering with getOrder()
    Author:
    Apache Directory Project
    • Method Detail

      • visit

        Object visit​(ExprNode node)
        Visits a filter expression AST using a specific visitation order.
        Parameters:
        node - the node to visit
        Returns:
        node the resulting modified node
      • canVisit

        boolean canVisit​(ExprNode node)
        Checks to see if a node can be visited.
        Parameters:
        node - the node to be visited
        Returns:
        whether or node the node should be visited
      • isPrefix

        boolean isPrefix()
        Determines whether the visitation order is prefix or postfix.
        Returns:
        true if the visitation is in prefix order, false otherwise.
      • getOrder

        List<ExprNodegetOrder​(BranchNode node,
                                List<ExprNode> children)
        Get the array of children to visit sequentially to determine the order of child visitations. Some children may not be returned at all if canVisit() returns false on them.
        Parameters:
        node - the parent branch node
        children - the child node array
        Returns:
        the new reordered array of children