HOME

com.ireasoning.protocol.snmp
Class SnmpTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--com.ireasoning.protocol.snmp.SnmpTableModel
All Implemented Interfaces:
Serializable, TableModel

public class SnmpTableModel
extends AbstractTableModel

This class is the data representation of a MIB table. It also implements Swing's TableModel interface, so it can used directly by Swing's JTable class.

See Also:
SnmpSession.snmpGetTable(java.lang.String, com.ireasoning.protocol.snmp.SnmpTableModel), Serialized Form

Field Summary
protected  Vector _columnDataTypes
          Column data types.
protected  Vector _columnNames
          Column names.
protected  Vector _columnOIDs
          Column oids.
protected  Vector _columns
          Table columns.
protected  boolean _isToTranslateValue
          true to translate VarBind's value
protected  String _tableName
          Table name
protected  SnmpOID _tableOID
          Table OID
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SnmpTableModel()
          Constructor
SnmpTableModel(String tableName)
          Constructor
 
Method Summary
 void addRow(SnmpVarBind[] vbs)
          Adds a new row
 SnmpVarBind get(int row, int column)
          Returns the the cell at columnIndex and rowIndex.
 SnmpVarBind[] getColumn(int index)
          Returns the column at specified index
 int getColumnCount()
          Returns the number of columns in the model.
 String getColumnDataType(int index)
          Returns column data type string
 String getColumnName(int column)
          Returns column name
 String getColumnOID(int column)
          Returns column oid at specified column
 long getPollingInterval()
          Returns the polling interval, in seconds.
 SnmpVarBind[] getRow(int index)
          Return row at specified index
 int getRowCount()
          Returns the number of rows in the model.
 String getTableName()
          Returns the table name
 SnmpOID getTableOID()
          Returns the table OID
 Object getValueAt(int row, int column)
          Returns the value for the cell at columnIndex and rowIndex.
 void refreshNow()
          Refresh whole table now (if table's polling is enabled)
 void removeAll()
          Removes all rows and columns
 void setColumnDataType(int index, String dataType)
          Sets column data type
 void setTableName(String tableName)
          Sets table name
 void setTableOID(SnmpOID oid)
          Sets a new table OID
 void setTranslateValue(boolean b)
          If passed b is true, subsequent calls to getValueAt(int row, int column) will use corresponding value defined in MIB.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to aValue.
 void setValueMap(int column, String key, String value)
          Passed a key/value map to further translate value into more readable text message.
 void startPolling(long interval)
          Starts a new thread for polling table periodically.
 void stopPolling()
          Stops polling
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_columns

protected Vector _columns
Table columns. Each element in this Vector object is SnmpVarBind object

_columnNames

protected Vector _columnNames
Column names. Each element in this Vector object is String object.

_columnOIDs

protected Vector _columnOIDs
Column oids. Each element in this Vector object is String object.

_columnDataTypes

protected Vector _columnDataTypes
Column data types. Each element in this Vector object is String object.

_tableName

protected String _tableName
Table name

_tableOID

protected SnmpOID _tableOID
Table OID

_isToTranslateValue

protected boolean _isToTranslateValue
true to translate VarBind's value
See Also:
setTranslateValue(boolean)
Constructor Detail

SnmpTableModel

public SnmpTableModel()
Constructor

SnmpTableModel

public SnmpTableModel(String tableName)
Constructor
Parameters:
tableName - table name
Method Detail

setTableName

public void setTableName(String tableName)
Sets table name
Parameters:
tableName - table name

getTableName

public String getTableName()
Returns the table name

getTableOID

public SnmpOID getTableOID()
Returns the table OID

setTableOID

public void setTableOID(SnmpOID oid)
Sets a new table OID

getRow

public SnmpVarBind[] getRow(int index)
Return row at specified index
Throws:
IndexOutOfBoundsException - if index is out of range

getColumn

public SnmpVarBind[] getColumn(int index)
Returns the column at specified index
Throws:
IndexOutOfBoundsException - if index is out of range

addRow

public void addRow(SnmpVarBind[] vbs)
Adds a new row
Parameters:
vbs - a SnmpVarBind array of each column in this new row

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the value for the cell at columnIndex and rowIndex.
Overrides:
getValueAt in class AbstractTableModel
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
a String object, the value at the specified cell
Throws:
IndexOutOfBoundsException - if row or column is out of range

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to aValue.
Overrides:
setValueAt in class AbstractTableModel
Parameters:
aValue - the new value, must be an instance of a class implementing SnmpDataType interface
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed

setTranslateValue

public void setTranslateValue(boolean b)
If passed b is true, subsequent calls to getValueAt(int row, int column) will use corresponding value defined in MIB. For example, "1" of ifAdminStatus will be translated to "up"
See Also:
MibUtil.translateValue(java.lang.String, java.lang.String), snmpgettable.java example

setValueMap

public void setValueMap(int column,
                        String key,
                        String value)
Passed a key/value map to further translate value into more readable text message. getValueAt method will return a value based on passed map
Parameters:
key - Map's key
value - Map's value
column - table column index, starting from 0

get

public SnmpVarBind get(int row,
                       int column)
Returns the the cell at columnIndex and rowIndex.
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the cell at specified location
Throws:
IndexOutOfBoundsException - if row or column is out of range

getRowCount

public int getRowCount()
Returns the number of rows in the model.
Overrides:
getRowCount in class AbstractTableModel
Returns:
the number of rows in the model
See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Returns the number of columns in the model.
Overrides:
getColumnCount in class AbstractTableModel
Returns:
the number of columns in the model
See Also:
getRowCount()

getColumnName

public String getColumnName(int column)
Returns column name
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - the column being queried
Returns:
a string containing the name of column
Throws:
IndexOutOfBoundsException - if column is out of range

getColumnOID

public String getColumnOID(int column)
Returns column oid at specified column
Parameters:
column - the column being queried
Returns:
a string containing the oid of column
Throws:
IndexOutOfBoundsException - if column is out of range

getColumnDataType

public String getColumnDataType(int index)
Returns column data type string
Parameters:
index - column index

setColumnDataType

public void setColumnDataType(int index,
                              String dataType)
Sets column data type
Parameters:
index - column index
dataType - data type string

getPollingInterval

public long getPollingInterval()
Returns the polling interval, in seconds.

startPolling

public void startPolling(long interval)
Starts a new thread for polling table periodically.
Note: The corresponding SnmpSession should not be closed if polling is enabled.
Parameters:
interval - polling interval, the number of seconds between two polls

stopPolling

public void stopPolling()
Stops polling

refreshNow

public void refreshNow()
Refresh whole table now (if table's polling is enabled)
See Also:
startPolling(long)

removeAll

public void removeAll()
Removes all rows and columns

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.