[]
        
(Showing Draft Content)

NumberNode

Class NumberNode


public class NumberNode extends ConstNode
Represents a numeric literal node in a formula syntax tree.

This node stores a single double value and can be read or updated after creation.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("LEFT(sheet1!$B$3,1)");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 NumberNode numberNode = (NumberNode) functionNode.getChildren().get(1);
 double value = numberNode.getValue();
 

See ConstNode for other constant node types.

  • Constructor Details

    • NumberNode

      public NumberNode(double value)
      Creates a NumberNode from double value.

      This constructor initializes a numeric literal node in a formula syntax tree with the specified value.

      Parameters:
      value - The value of the new NumberNode. Must be a finite number.
      Throws:
      IllegalArgumentException - if value is NaN or infinite.
  • Method Details

    • getValue

      public final double getValue()
      Gets the numeric value stored in this node.

      Returns the double value represented by this NumberNode in the formula syntax tree.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("LEFT(sheet1!$B$3,1)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       NumberNode numberNode = (NumberNode) functionNode.getChildren().get(1);
       double value = numberNode.getValue();
       
      Returns:
      The double value of this node.
    • setValue

      public final void setValue(double value)
      Sets the numeric value stored in this node.

      sets the double value represented by this NumberNode in the formula syntax tree.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("LEFT(sheet1!$B$3,1)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       NumberNode numberNode = (NumberNode) functionNode.getChildren().get(1);
       numberNode.setValue(2);
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The double value of this node.