org.netxms.client
Class Table

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

public class Table
extends java.lang.Object

Generic class for holding data in tabular format. Table has named columns. All data stored as strings.


Constructor Summary
Table()
          Create empty table
Table(NXCPMessage msg)
          Create table from data in NXCP message
 
Method Summary
 void addAll(Table src)
          Append all records from given table to this table.
 void addDataFromMessage(NXCPMessage msg)
          Add data from additional messages
 void addRow()
          Add new row
 void fillMessage(NXCPMessage msg)
          Fill NXCP message with table's data
 java.lang.Object[] getAllRows()
          Get all rows as an array of List.
 java.lang.String getCell(int row, int column)
          Get cell value at given row and column
 int getColumnCount()
          Get number of columns in table
 int[] getColumnDataTypes()
          Get display names of all columns
 TableColumnDefinition getColumnDefinition(int column)
          Get column definition
 java.lang.String getColumnDisplayName(int column)
          Get column display name
 java.lang.String[] getColumnDisplayNames()
          Get display names of all columns
 int getColumnFormat(int column)
          Deprecated. 
 int getColumnIndex(java.lang.String name)
          Get column index by name
 java.lang.String getColumnName(int column)
          Get column name
 TableColumnDefinition[] getColumns()
          Get names of all columns
 java.util.List<java.lang.String> getRow(int row)
          Get row.
 int getRowCount()
          Get number of rows in table
 int getSource()
           
 java.lang.String getTitle()
           
 void setCell(int row, int col, java.lang.String value)
          Set cell value
 void setSource(int source)
           
 void setTitle(java.lang.String title)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table()
Create empty table


Table

public Table(NXCPMessage msg)
Create table from data in NXCP message

Parameters:
msg - NXCP message
Method Detail

addDataFromMessage

public void addDataFromMessage(NXCPMessage msg)
Add data from additional messages

Parameters:
msg -

fillMessage

public void fillMessage(NXCPMessage msg)
Fill NXCP message with table's data

Parameters:
msg - NXCP message

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 java.lang.IndexOutOfBoundsException
Get column definition

Parameters:
column - Column index (zero-based)
Returns:
Column name
Throws:
java.lang.IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())

getColumnName

public java.lang.String getColumnName(int column)
                               throws java.lang.IndexOutOfBoundsException
Get column name

Parameters:
column - Column index (zero-based)
Returns:
Column name
Throws:
java.lang.IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())

getColumnDisplayName

public java.lang.String getColumnDisplayName(int column)
                                      throws java.lang.IndexOutOfBoundsException
Get column display name

Parameters:
column - Column index (zero-based)
Returns:
Column name
Throws:
java.lang.IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())

getColumnFormat

@Deprecated
public int getColumnFormat(int column)
                    throws java.lang.IndexOutOfBoundsException
Deprecated. 

Get column format

Parameters:
column - Column index (zero-based)
Returns:
Column format
Throws:
java.lang.IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount())

getColumnIndex

public int getColumnIndex(java.lang.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

getCell

public java.lang.String getCell(int row,
                                int column)
                         throws java.lang.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:
java.lang.IndexOutOfBoundsException - if column index is out of range (column < 0 || column >= getColumnCount()) or row index is out of range (row < 0 || row >= getRowCount())

getRow

public java.util.List<java.lang.String> getRow(int row)
                                        throws java.lang.IndexOutOfBoundsException
Get row.

Parameters:
row - Row index (zero-based)
Returns:
List of all values for given row
Throws:
java.lang.IndexOutOfBoundsException - if row index is out of range (row < 0 || row >= getRowCount())

getAllRows

public java.lang.Object[] getAllRows()
Get all rows as an array of List. Method returns Object[] because Java forbids creation of generic arrays.

Returns:
Array of all rows in a table

getTitle

public java.lang.String getTitle()
Returns:
the title

setTitle

public void setTitle(java.lang.String title)
Parameters:
title - the title to set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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,
                    java.lang.String value)
Set cell value

Parameters:
row -
col -
value -

getSource

public int getSource()
Returns:
the source

setSource

public void setSource(int source)
Parameters:
source - the source to set

getColumnDisplayNames

public java.lang.String[] getColumnDisplayNames()
Get display names of all columns

Returns:

getColumnDataTypes

public int[] getColumnDataTypes()
Get display names of all columns

Returns:


Copyright © 2013. All Rights Reserved.