[]
        
(Showing Draft Content)

TableItemNode

Class TableItemNode


public class TableItemNode extends TerminalNode
Represents a table item in the syntax tree.

A table item describes a structured reference to a table, including the table name, the referenced table part, and the source column or column range. Use this class to build or inspect syntax nodes for references such as headers, data, totals, or specific table columns.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Headers],[#Data],[ComPct]]");
 TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
 String tableName = tableItem.getTableName();
 TableItemType itemType = tableItem.getItemType();
 String columnName = tableItem.getColumnFrom();
 
  • Constructor Details

    • TableItemNode

      public TableItemNode(String tableName, TableItemType itemType, String columnName)
      Creates a new TableItemNode from a single column of a table.

      This constructor creates a table item for the specified table name, table part, and column name. It passes columnName as the start column and null as the end column to TableItemNode(String,TableItemType,String,String).

      
       TableItemNode tableItem = new TableItemNode("DeptSales", TableItemType.Headers, "Amount");
       FormulaSyntaxTree syntaxTree = new FormulaSyntaxTree();
       syntaxTree.setRoot(tableItem);
       String formulaText = syntaxTree.toString();
       
      Parameters:
      tableName - The name of the table.
      itemType - The table part represented by the structured reference.
      columnName - The column name to reference. This value is passed as the start column.
    • TableItemNode

      public TableItemNode(String tableName, TableItemType itemType, String columnFrom, String columnTo)
      Creates a new TableItemNode that represents a table structured reference spanning a range of columns.

      Use this constructor to specify the table name, the referenced table item type, and the start and end columns for the structured reference.

      
       TableItemNode tableItem = new TableItemNode(
           "DeptSales",
           TableItemType.Data,
           "Amount",
           "Discount"
       );
       FormulaSyntaxTree syntaxTree = new FormulaSyntaxTree();
       syntaxTree.setRoot(tableItem);
       String formulaText = syntaxTree.toString();
       
      Parameters:
      tableName - The name of the table.
      itemType - The table item type represented by the structured reference.
      columnFrom - The name of the first column in the referenced column range.
      columnTo - The name of the last column in the referenced column range.
  • Method Details

    • getTableName

      public final String getTableName()
      Gets the name of the table.

      Use this method to retrieve the table name stored in the current TableItemNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Headers],[#Data],[ComPct]]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       String tableName = tableItem.getTableName();
       
      Returns:
      The name of the table. Returns null if no table name has been set.
    • setTableName

      public final void setTableName(String value)
      Sets the name of the table.

      Use this method to update the table name stored in the current TableItemNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("[@ComPct]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       tableItem.setTableName("DeptSales");
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The table name to set. Use null to clear the table name.
    • getItemType

      public final TableItemType getItemType()
      Gets the referenced part of the table.

      The returned item type indicates which section of the table this TableItemNode represents in a structured reference, such as headers, data, or totals.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Headers],[#Data],[ComPct]]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       TableItemType itemType = tableItem.getItemType();
       
      Returns:
      The table item type. Returns null if no item type has been assigned.
    • setItemType

      public final void setItemType(TableItemType value)
      Sets the table item type.

      The item type identifies which part of the table this TableItemNode represents. The value is defined by TableItemType.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[Amount]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       tableItem.setItemType(TableItemType.Headers);
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The table item type to set.
    • getColumnFrom

      public final String getColumnFrom()
      Gets the start column of the table item.

      This method returns the first column name in the structured reference represented by this TableItemNode. For a single-column table item, it returns that column name. For a column range, it returns the start column of the range.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Headers],[#Data],[ComPct]]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       String columnFrom = tableItem.getColumnFrom();
       
      Returns:
      The start column name, or null if no start column has been set.
    • setColumnFrom

      public final void setColumnFrom(String value)
      Sets the start column of the table item.

      This method sets the first column name in the structured reference represented by this TableItemNode. For a single-column table item, it sets that column name. For a column range, it sets the start column of the range.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Data],[Q1]:[Q3]]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       tableItem.setColumnFrom("Q2");
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The start column name to set. Use null to clear the start column.
    • getColumnTo

      public final String getColumnTo()
      Gets the end column of the table column range.

      For a TableItemNode that represents a range of columns, this method returns the last column name in that range. If the node represents a single column reference, this method returns null.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Headers],[#Data],[ComPct]:[Column3]]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       String columnTo = tableItem.getColumnTo();
       
      Returns:
      The end column name of the table column range, or null if this node does not specify an end column.
    • setColumnTo

      public final void setColumnTo(String value)
      Sets the end column of the table column range.

      For a TableItemNode that represents a range of columns, this method sets the last column name in that range. If the node represents a single column reference, this method sets null.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("DeptSales[[#Data],[Amount]:[Total]]");
       TableItemNode tableItem = (TableItemNode) syntaxTree.getRoot();
       tableItem.setColumnTo("Discount");
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The end column name to set. Use null when this node should not specify an end column.