Package org.netxms.client
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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(Table src)Append all records from given table to this table.voidaddDataFromMessage(org.netxms.base.NXCPMessage msg)Add data from additional messagesvoidaddRow()Add new rowvoidfillMessage(org.netxms.base.NXCPMessage msg)Fill NXCP message with table's dataTableRow[]getAllRows()Get all rows.TableCellgetCell(int row, int column)Get table cellStringgetCellValue(int row, int column)Get cell value at given row and columnintgetColumnCount()Get number of columns in tableDataType[]getColumnDataTypes()Get data types of all columnsTableColumnDefinitiongetColumnDefinition(int column)Get column definitionStringgetColumnDisplayName(int column)Get column display nameString[]getColumnDisplayNames()Get display names of all columnsintgetColumnIndex(String name)Get column index by nameStringgetColumnName(int column)Get column nameTableColumnDefinition[]getColumns()Get names of all columnsTablegetFirstRows(int count)Get first N rows from table.TableRowgetRow(int row)Get row.intgetRowCount()Get number of rows in tableintgetSource()StringgetTitle()booleanisExtendedFormat()voidsetCell(int row, int col, String value)Set cell valuevoidsetExtendedFormat(boolean extendedFormat)voidsetSource(int source)voidsetTitle(String title)voidsort(Comparator<TableRow> comparator)Sort table rows using provided comparatorStringtoString()
-
-
-
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
-
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- rowcolumn- 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
-
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- rowcol- columnvalue- 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
-
-