HOME

com.ireasoning.protocol.snmp
Class SnmpTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended bycom.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.
 SnmpOID getAuthFailureOID()
           
 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 getColumnDataType(int rowIndex, int columnIndex)
          Returns column data type string
 String getColumnName(int column)
          Returns column name
 String getColumnName(int row, 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)
          Returns row at specified index
 int getRowCount()
          Returns the number of rows in the model.
 String getRowIndexSuffix(int row)
          Returns index suffix of a row.
 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.
 SnmpVarBind getVarBindAt(int row, int column)
           
 void refreshNow()
          Refresh whole table now (if table's polling is enabled)
 void removeAll()
          Removes all rows and columns
 void removeRow(int index)
          Removes a row
 void setColumnDataType(int index, String dataType)
          Sets column data type
 void setColumnName(int index, String name)
          Sets column name
 void setColumnOID(int index, String oid)
          Sets column's OID
 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, getTableModelListeners, 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)
Returns row at specified index

Throws:
IndexOutOfBoundsException - if index is out of range

getRowIndexSuffix

public String getRowIndexSuffix(int row)
Returns index suffix of a row. For example, for ifTable, getRowIndexSuffix(0) may return a string "1", which is the value of ifIndex of the row. It returns null if there's not enough data to determine index.

Parameters:
row - row index

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 - an SnmpVarBind array of each column in this new row

getVarBindAt

public SnmpVarBind getVarBindAt(int row,
                                int column)

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the value for the cell at columnIndex and rowIndex.

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.

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.

Throws:
IndexOutOfBoundsException - if row or column is out of range

getRowCount

public int getRowCount()
Returns the number of rows in the model.

Returns:
the number of rows in the model
See Also:
getColumnCount()

getColumnCount

public int getColumnCount()
Returns the number of columns in the model.

Returns:
the number of columns in the model
See Also:
getRowCount()

getColumnName

public String getColumnName(int column)
Returns column name

Parameters:
column - the column being queried
Returns:
a string containing the name of column
Throws:
IndexOutOfBoundsException - if column is out of range

getColumnName

public String getColumnName(int row,
                            int column)
Returns column name

Parameters:
column - column index
row - the row index
Returns:
a string containing the name of column
Throws:
IndexOutOfBoundsException - if column is out of range

setColumnName

public void setColumnName(int index,
                          String name)
Sets column name

Parameters:
index - column index
name - column name

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

setColumnOID

public void setColumnOID(int index,
                         String oid)
Sets column's OID

Parameters:
index - column index
oid - column's OID

getColumnDataType

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

Parameters:
index - column index

getColumnDataType

public String getColumnDataType(int rowIndex,
                                int columnIndex)
Returns column data type string

Parameters:
columnIndex - column index
rowIndex - row 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)

removeRow

public void removeRow(int index)
Removes a row

Parameters:
index - row index

removeAll

public void removeAll()
Removes all rows and columns


getAuthFailureOID

public SnmpOID getAuthFailureOID()
Returns:
null if SNMPv3 authentication succeeded; otherwise the OID of authFailed message.

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.