[]
        
(Showing Draft Content)

ErrorNode

Class ErrorNode


public class ErrorNode extends ConstNode
Represents an error literal node in a formula syntax tree.

An ErrorNode represents an error literal in a formula syntax tree.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("IFERROR(A2/A3, #DIV/0!)");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 ErrorNode errorNode = (ErrorNode) functionNode.getChildren().get(1);
 CalcError error = errorNode.getValue();
 
  • Constructor Details

    • ErrorNode

      public ErrorNode(CalcError value)
      Creates a new ErrorNode from CalcError.

      This constructor initializes an error literal node in the formula syntax tree with the specified error value.

      Parameters:
      value - The error value. Must be a valid CalcError value.
  • Method Details

    • getValue

      public final CalcError getValue()
      Gets the error value stored in this node.

      This method returns the CalcError that represents the error literal associated with this ErrorNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("IFERROR(A2/A3, #DIV/0!)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       ErrorNode errorNode = (ErrorNode) functionNode.getChildren().get(1);
       CalcError error = errorNode.getValue();
       
      Returns:
      The CalcError value of this node.
    • setValue

      public final void setValue(CalcError value)
      Sets the error value stored in this node.

      This method updates the CalcError that represents the error literal associated with this ErrorNode.

      
       ErrorNode node = new ErrorNode(CalcError.Div0);
       node.setValue(CalcError.Name);
       CalcError error = node.getValue();
       
      Parameters:
      value - The error value to store in the node. Must be a defined CalcError value and must not be null.
      Throws:
      IllegalArgumentException - if value is not a defined CalcError value.