Class Table

java.lang.Object
org.netxms.client.Table

public class Table extends Object
Generic class for holding data in tabular format. Table has named columns. All data stored as strings.
  • Constructor Details

    • Table

      public Table()
      Create empty table
    • Table

      public Table(NXCPMessage msg)
      Create table from data in NXCP message
      Parameters:
      msg - NXCP message
  • Method Details

    • addDataFromMessage

      public void addDataFromMessage(NXCPMessage msg)
      Add data from additional messages
      Parameters:
      msg - The NXCPMessage
    • fillMessage

      public void fillMessage(NXCPMessage msg)
      Fill NXCP message with table's data
      Parameters:
      msg - NXCP message
    • deleteAllRows

      public void deleteAllRows()
      Delete all rows from table while retaining column structure.
    • sort

      public void sort(Comparator<TableRow> comparator)
      Sort table rows using provided comparator
      Parameters:
      comparator - comparator for table rows
    • getColumnCount

      public int getColumnCount()
      Get number of columns in table
      Returns:
      Number of columns
    • getRowCount

      public int getRowCount()
      Get number of rows in table
      Returns:
      Number of rows
    • getColumnDefinition

      public TableColumnDefinition getColumnDefinition(int column) throws IndexOutOfBoundsException
      Get column definition
      Parameters:
      column - Column index (zero-based)
      Returns:
      Column name
      Throws:
      IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())
    • getColumnName

      public String getColumnName(int column) throws IndexOutOfBoundsException
      Get column name
      Parameters:
      column - Column index (zero-based)
      Returns:
      Column name
      Throws:
      IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())
    • getColumnDisplayName

      public String getColumnDisplayName(int column) throws IndexOutOfBoundsException
      Get column display name
      Parameters:
      column - Column index (zero-based)
      Returns:
      Column name
      Throws:
      IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())
    • getColumnIndex

      public int getColumnIndex(String name)
      Get column index by name
      Parameters:
      name - Column name
      Returns:
      0-based column index or -1 if column with given name does not exist
    • getColumns

      public TableColumnDefinition[] getColumns()
      Get names of all columns
      Returns:
      array of column names
    • getCellValue

      public String getCellValue(int row, int column) throws IndexOutOfBoundsException
      Get cell value at given row and column
      Parameters:
      row - Row index (zero-based)
      column - Column index (zero-based)
      Returns:
      Data from given cell
      Throws:
      IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount()) or row index is out of range (row < 0 || row >= getRowCount())
    • getCell

      public TableCell getCell(int row, int column) throws IndexOutOfBoundsException
      Get table cell
      Parameters:
      row - row
      column - column
      Returns:
      table cell using giver row and column
      Throws:
      IndexOutOfBoundsException - throws error when there is no provided column or rows
    • getRow

      public TableRow getRow(int row) throws IndexOutOfBoundsException
      Get row.
      Parameters:
      row - Row index (zero-based)
      Returns:
      table row
      Throws:
      IndexOutOfBoundsException - if row index is out of range (row < 0 || row >= getRowCount())
    • getAllRows

      public TableRow[] getAllRows()
      Get all rows.
      Returns:
      Array of all rows in a table
    • getTitle

      public String getTitle()
      Returns:
      the title
    • setTitle

      public void setTitle(String title)
      Parameters:
      title - the title to set
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • addAll

      public void addAll(Table src)
      Append all records from given table to this table. Source table must have same column set.
      Parameters:
      src - source table
    • addRow

      public void addRow()
      Add new row
    • setCell

      public void setCell(int row, int col, String value)
      Set cell value
      Parameters:
      row - row
      col - column
      value - value to be set
    • getSource

      public DataOrigin getSource()
      Get data origin (source).
      Returns:
      data origin
    • setSource

      public void setSource(DataOrigin source)
      Set data origin (source)
      Parameters:
      source - new data origin (source)
    • getColumnDisplayNames

      public String[] getColumnDisplayNames()
      Get display names of all columns
      Returns:
      String array with all column names
    • getColumnDataTypes

      public DataType[] getColumnDataTypes()
      Get data types of all columns
      Returns:
      int array with all column data types
    • isExtendedFormat

      public boolean isExtendedFormat()
      Returns:
      the extendedFormat
    • setExtendedFormat

      public void setExtendedFormat(boolean extendedFormat)
      Parameters:
      extendedFormat - the extendedFormat to set
    • getFirstRows

      public Table getFirstRows(int count)
      Get first N rows from table. New table is backed by data from original table, so any changes to rows or column definitions will affect original table as well.
      Parameters:
      count - number of rows to retrieve
      Returns:
      new table containing only requested rows