[]
        
(Showing Draft Content)

OperatorNode

Class OperatorNode


public class OperatorNode extends NonTerminalNode
Represents an operator call expression in a formula syntax tree.

An OperatorNode is a non-terminal syntax node whose operator type is defined by an OperatorKind. Use this class to inspect or modify the operator associated with an expression node.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("IF(A1<100000,A1*5%,A1*7.5%)");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 OperatorNode operatorNode = (OperatorNode) functionNode.getChildren().get(0);
 OperatorKind kind = operatorNode.getKind();
 
  • Constructor Details

    • OperatorNode

      public OperatorNode(OperatorKind kind)
      Creates a new OperatorNode from the type of the operator.

      This constructor initializes the node with the specified OperatorKind.

      Parameters:
      kind - The type of the operator.
  • Method Details

    • getKind

      public final OperatorKind getKind()
      Gets the type of the operator.

      Returns the OperatorKind currently associated with this OperatorNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("IF(A1<100000,A1*5%,A1*7.5%)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       OperatorNode operatorNode = (OperatorNode) functionNode.getChildren().get(0);
       OperatorKind kind = operatorNode.getKind();
       
      Returns:
      The type of the operator.
    • setKind

      public final void setKind(OperatorKind value)
      Sets the type of the operator.

      Use this method to change the OperatorKind associated with this OperatorNode after it has been created.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("A1<100000");
       OperatorNode operatorNode = (OperatorNode) syntaxTree.getRoot();
       operatorNode.setKind(OperatorKind.LessThanOrEqual);
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The operator type to assign to this node. May be null.