Class Table


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

      • Table

        public Table()
        Create empty table
      • Table

        public Table​(org.netxms.base.NXCPMessage msg)
        Create table from data in NXCP message
        Parameters:
        msg - NXCP message
    • Method Detail

      • addDataFromMessage

        public void addDataFromMessage​(org.netxms.base.NXCPMessage msg)
        Add data from additional messages
        Parameters:
        msg - The NXCPMessage
      • fillMessage

        public void fillMessage​(org.netxms.base.NXCPMessage msg)
        Fill NXCP message with table's data
        Parameters:
        msg - NXCP message
      • 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
      • 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())
      • 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
      • 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 int getSource()
        Returns:
        the source
      • setSource

        public void setSource​(int source)
        Parameters:
        source - the source to set
      • 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