[]
        
(Showing Draft Content)

TextNode

Class TextNode


public class TextNode extends ConstNode
Represents a string literal node in a formula syntax tree.

Use this class to create or inspect constant text values in expression trees. A TextNode stores a non- null string value and inherits constant-node behavior from ConstNode.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("SUM(5,\"6\",TRUE)");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 TextNode textNode = (TextNode) functionNode.getChildren().get(1);
 String text = textNode.getValue();
 
  • Constructor Details

    • TextNode

      public TextNode(String value)
      Creates a new TextNode from string.
      Parameters:
      value - The string value. The value can't be null (Nothing).
  • Method Details

    • getValue

      public final String getValue()
      Gets the text of this node.

      Returns the string literal represented by this TextNode in the formula syntax tree. The returned value is never null.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("SUM(5,\"6\",TRUE)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       TextNode textNode = (TextNode) functionNode.getChildren().get(1);
       String text = textNode.getValue();
       
      Returns:
      The text of this node. Never returns null.
    • setValue

      public final void setValue(String value)
      Sets the text of this node.

      sets the string literal represented by this TextNode in the formula syntax tree. The value must not be null.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("SUM(5,\"6\",TRUE)");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       TextNode textNode = (TextNode) functionNode.getChildren().get(1);
       textNode.setValue("7");
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The text of this node. Must not be null.