[]
        
(Showing Draft Content)

ReferenceNode

Class ReferenceNode


public class ReferenceNode extends TerminalNode
Represents a reference node in the formula syntax tree.

A ReferenceNode is a TerminalNode that wraps a Reference object so a cell, range, worksheet, or workbook reference can be represented as a terminal expression node.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("LEFT(sheet1!$B$3,1)");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 ReferenceNode referenceNode = (ReferenceNode) functionNode.getChildren().get(0);
 Reference reference = referenceNode.getReference();
 
  • Constructor Details

    • ReferenceNode

      public ReferenceNode(Reference reference)
      Creates a new ReferenceNode from a Reference.

      A ReferenceNode stores a formula reference as a terminal node in the syntax tree.

      Parameters:
      reference - The reference to associate with this node.
  • Method Details

    • getReference

      public final Reference getReference()
      Gets the reference of this node.

      Returns the Reference object that represents the reference expression stored in this ReferenceNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("LEFT(sheet1!$B$3,1)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       ReferenceNode referenceNode = (ReferenceNode) functionNode.getChildren().get(0);
       Reference reference = referenceNode.getReference();
       
      Returns:
      The reference of this node, or null if no reference has been assigned.
    • setReference

      public final void setReference(Reference value)
      Sets the reference of this node.

      Use this method to replace the Reference represented by the current ReferenceNode. The specified value is stored directly and can be retrieved later with getReference().

      
       Reference reference = new Reference();
       reference.setRow(0);
       reference.setColumn(0);
       ReferenceNode node = new ReferenceNode(reference);
       Reference updatedReference = new Reference();
       updatedReference.setRow(1);
       updatedReference.setColumn(2);
       node.setReference(updatedReference);
       Reference result = node.getReference();
       
      Parameters:
      value - The Reference to assign to this node. May be null.