[]
        
(Showing Draft Content)

ArrayNode

Class ArrayNode


public class ArrayNode extends ConstNode
Represents an array literal node in a formula syntax tree.

An ArrayNode stores a two-dimensional array of constant values that can be used as a literal expression in the syntax tree. Array and element values cannot be null. Supported element types are double, String, boolean, and CalcError. Primitive numeric values such as byte, short, int, long, and float are accepted, but they are normalized to double if the node is converted to text and then parsed again. Floating-point values cannot be NaN or infinity.

The array must contain at least one element, and each nested array must use a zero-based lower bound.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("OR(A1={1,3,5})");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 OperatorNode operatorNode = (OperatorNode) functionNode.getChildren().get(0);
 ArrayNode arrayNode = (ArrayNode) operatorNode.getChildren().get(1);
 Object[][] elements = arrayNode.getElements();
 Object firstValue = elements[0][0];
 
  • Constructor Details

    • ArrayNode

      public ArrayNode(Object[][] elements)
      Creates a new ArrayNode from an array.

      The specified array defines the literal values stored by this node. The value cannot be null. Supported element types are double, String, boolean, and CalcError. Numeric values such as byte, short, int, long, and float are accepted, but they are normalized to double if the node is converted to text and then parsed again. Floating-point values cannot be NaN or infinity.

      Parameters:
      elements - The array elements. The value cannot be null (Nothing).
      Throws:
      IllegalArgumentException - if elements is null, is empty, contains an empty nested array, contains a null element, contains an unsupported element type, or contains NaN or infinite floating-point values.
  • Method Details

    • getElements

      public final Object[][] getElements()
      Gets the array elements of this node.

      The returned value is a two-dimensional array and is never null. Supported element types are double, String, boolean, and CalcError. Numeric values such as byte, short, int, long, and float are accepted, but they are normalized to double if the ArrayNode is converted to text and then parsed again. Floating-point values cannot be NaN or infinity.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("OR(A1={1,3,5})");
       FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
       OperatorNode operatorNode = (OperatorNode) functionNode.getChildren().get(0);
       ArrayNode arrayNode = (ArrayNode) operatorNode.getChildren().get(1);
       Object[][] elements = arrayNode.getElements();
       Object firstValue = elements[0][0];
       
      Returns:
      A two-dimensional array containing the elements of this node.
    • setElements

      public final void setElements(Object[][] value)
      Sets the array elements of this node.

      The specified value must be a two-dimensional array and must not be null. Supported element types are double, String, boolean, and CalcError. Numeric values such as byte, short, int, long, and float are accepted, but they are normalized to double if the ArrayNode is converted to text and then parsed again. Floating-point values cannot be NaN or infinity.

      
       ArrayNode node = new ArrayNode(new Object[][] {
           {1.0, "East"},
           {true, CalcError.Value}
       });
       node.setElements(new Object[][] {
           {2.0, "West"}
       });
       Object firstValue = node.getElements()[0][0];
       
      Parameters:
      value - A two-dimensional array containing the elements of this node.