Class Node

java.lang.Object
org.rumbledb.expressions.Node
Direct Known Subclasses:
Clause, Expression, FunctionDeclaration, Module, Program, Prolog, Statement, TypeDeclaration, VariableDeclaration

public abstract class Node extends Object
This is the top-level class for nodes in the intermediate representation of a JSONiq query. Nodes include expressions, clauses, function declarations, etc.
  • Field Details

    • highestExecutionMode

      protected ExecutionMode highestExecutionMode
  • Constructor Details

  • Method Details

    • setHighestExecutionMode

      public void setHighestExecutionMode(ExecutionMode newMode)
      Initializes the highest execution mode of this node, which determines whether evaluation will be done locally, with RDDs or with DataFrames. This method is used during the static analysis.
    • getHighestExecutionMode

      public ExecutionMode getHighestExecutionMode(VisitorConfig visitorConfig)
      Gets the highest execution mode of this node, which determines whether evaluation will be done locally, with RDDs or with DataFrames. This method is used during the static analysis. It is meant to be overridden by subclasses that support higher execution modes. By default, the highest execution mode is assumed to be local. When extending this method, make sure to perform a super() call to prevent UNSET accesses. if Node.suppressUnsetExecutionModeAccessedErrors is false, then an error is thrown if an UNSET mode is found. if Node.suppressUnsetExecutionModeAccessedErrors is true, it might silently return UNSET.
      Parameters:
      visitorConfig - the configuration of the visitor.
      Returns:
      the highest execution mode.
    • getHighestExecutionMode

      public ExecutionMode getHighestExecutionMode()
      Gets the highest execution mode of this node, which determines whether evaluation will be done locally, with RDDs or with DataFrames. This method is used during the static analysis. It is meant to be overridden by subclasses that support higher execution modes. By default, the highest execution mode is assumed to be local.
      Returns:
      the highest execution mode.
    • numberOfUnsetExecutionModes

      public int numberOfUnsetExecutionModes()
    • accept

      public abstract <T> T accept(AbstractNodeVisitor<T> visitor, T argument)
      Accept method for the visitor pattern.
      Type Parameters:
      T - the type of the objects returned by the visitor.
      Parameters:
      visitor - the visitor.
      argument - the input from the visitor.
      Returns:
      the object returned by this visitor
    • getChildren

      public abstract List<Node> getChildren()
      Returns all children nodes as a list. The list is new and can be modified at will by the caller.
      Returns:
      the children nodes as a list.
    • getDescendants

      public final List<Node> getDescendants()
      For gathering descendant nodes, as a depth-first search. The list is new and can be modified at will by the caller.
      Returns:
      the descendant nodes as a list.
    • getDescendantsMatching

      public final List<Node> getDescendantsMatching(Predicate<Node> predicate)
      For gathering descendant nodes that match a predicate. The list is new and can be modified at will by the caller.
      Parameters:
      predicate - a predicate to filter with.
      Returns:
      the descendant nodes as a list.
    • getMetadata

      public ExceptionMetadata getMetadata()
      Access the metadata of the node, i.e., the line and column number. This is used for displaying informative error messages.
      Returns:
      the metadata.
    • print

      public void print(StringBuffer buffer, int indent)
      Prints the node tree to a string buffer.
      Parameters:
      buffer - a string buffer to write to
      indent - the current level of indentation
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • serializeToJSONiq

      public abstract void serializeToJSONiq(StringBuffer sb, int indent)
    • indentIt

      protected void indentIt(StringBuffer buffer, int indent)
    • isContextDependent

      public boolean isContextDependent()
      Tells whether the expression is context dependent.
      Returns:
      true if it is context dependent, false otherwise.