Package org.netxms.client
Class Table
java.lang.Object
org.netxms.client.Table
Generic class for holding data in tabular format. Table has named columns. All data stored as strings.
-
Constructor Summary
ConstructorsConstructorDescriptionTable()Create empty tableTable(NXCPMessage msg) Create table from data in NXCP message -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend all records from given table to this table.voidAdd data from additional messagesvoidaddRow()Add new rowvoidDelete all rows from table while retaining column structure.voidfillMessage(NXCPMessage msg) Fill NXCP message with table's dataTableRow[]Get all rows.getCell(int row, int column) Get table cellgetCellValue(int row, int column) Get cell value at given row and columnintGet number of columns in tableDataType[]Get data types of all columnsgetColumnDefinition(int column) Get column definitiongetColumnDisplayName(int column) Get column display nameString[]Get display names of all columnsintgetColumnIndex(String name) Get column index by namegetColumnName(int column) Get column nameGet names of all columnsgetFirstRows(int count) Get first N rows from table.getRow(int row) Get row.intGet number of rows in tableGet data origin (source).getTitle()booleanvoidSet cell valuevoidsetExtendedFormat(boolean extendedFormat) voidsetSource(DataOrigin source) Set data origin (source)voidvoidsort(Comparator<TableRow> comparator) Sort table rows using provided comparatortoString()
-
Constructor Details
-
Table
public Table()Create empty table -
Table
Create table from data in NXCP message- Parameters:
msg- NXCP message
-
-
Method Details
-
addDataFromMessage
Add data from additional messages- Parameters:
msg- The NXCPMessage
-
fillMessage
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
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
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
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
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
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
Get names of all columns- Returns:
- array of column names
-
getCellValue
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
Get table cell- Parameters:
row- rowcolumn- column- Returns:
- table cell using giver row and column
- Throws:
IndexOutOfBoundsException- throws error when there is no provided column or rows
-
getRow
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
Get all rows.- Returns:
- Array of all rows in a table
-
getTitle
- Returns:
- the title
-
setTitle
- Parameters:
title- the title to set
-
toString
-
addAll
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
Set cell value- Parameters:
row- rowcol- columnvalue- value to be set
-
getSource
Get data origin (source).- Returns:
- data origin
-
setSource
Set data origin (source)- Parameters:
source- new data origin (source)
-
getColumnDisplayNames
Get display names of all columns- Returns:
- String array with all column names
-
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
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
-