Class LogicNode

  • All Implemented Interfaces:
    ExpressionNode

    public class LogicNode
    extends Object
    implements ExpressionNode
    This class defines a logical expression of nodes. This implementation uses a stack to evaluate its content as to avoid deep recursions when building the parse tree.
    Author:
    Simon Thoresen Hult
    • Constructor Detail

      • LogicNode

        public LogicNode()
        Construct an empty logic expression.
    • Method Detail

      • add

        public LogicNode add​(String operator,
                             ExpressionNode node)
        Adds an (operator, node) pair to this expression.
        Parameters:
        operator - The operator that combines the previous with the node given.
        node - The node to add to this.
        Returns:
        This, to allow chaining.
      • evaluate

        public Object evaluate​(Context context)
        Description copied from interface: ExpressionNode
        Evaluate the content of this node based on document object, and return that value.
        Specified by:
        evaluate in interface ExpressionNode
        Parameters:
        context - the document to evaluate over
        Returns:
        the value of this
      • accept

        public void accept​(Visitor visitor)
        Description copied from interface: ExpressionNode
        Perform visitation of this node.
        Specified by:
        accept in interface ExpressionNode
        Parameters:
        visitor - the visitor that wishes to visit the node