HOME

com.ireasoning.protocol.snmp
Class SnmpTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.ireasoning.protocol.snmp.SnmpTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class SnmpTableModel
extends javax.swing.table.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  java.util.Vector _columnDataTypes
          Column data types.
protected  java.util.Vector _columnNames
          Column names.
protected  java.util.Vector _columnOIDs
          Column oids.
protected  java.util.Vector _columns
          Table columns.
protected  boolean _isToTranslateValue
          true to translate VarBind's value
protected  java.lang.String _tableName
          Table name
protected  SnmpOID _tableOID
          Table OID
protected  java.util.Map _valueMap
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SnmpTableModel()
          Constructor
SnmpTableModel(java.lang.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.
 java.lang.String getColumnDataType(int index)
          Returns column data type string
 java.lang.String getColumnDataType(int rowIndex, int columnIndex)
          Returns column data type string
 java.lang.String getColumnName(int column)
          Returns column name
 java.lang.String getColumnName(int row, int column)
          Returns column name
 java.lang.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.
 java.lang.String getRowIndexSuffix(int row)
          Returns index suffix of a row.
 java.lang.String getTableName()
          Returns the table name
 SnmpOID getTableOID()
          Returns the table OID
 java.lang.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, java.lang.String dataType)
          Sets column data type
 void setColumnName(int index, java.lang.String name)
          Sets column name
 void setColumnOID(int index, java.lang.String oid)
          Sets column's OID
 void setTableName(java.lang.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(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to aValue.
 void setValueMap(int column, java.lang.String key, java.lang.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 java.util.Vector _columns
Table columns. Each element in this Vector object is SnmpVarBind object


_columnNames

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


_columnOIDs

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


_columnDataTypes

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


_tableName

protected java.lang.String _tableName
Table name


_tableOID

protected SnmpOID _tableOID
Table OID


_isToTranslateValue

protected boolean _isToTranslateValue
true to translate VarBind's value

See Also:
setTranslateValue(boolean)

_valueMap

protected java.util.Map _valueMap
Constructor Detail

SnmpTableModel

public SnmpTableModel()
Constructor


SnmpTableModel

public SnmpTableModel(java.lang.String tableName)
Constructor

Parameters:
tableName - table name
Method Detail

setTableName

public void setTableName(java.lang.String tableName)
Sets table name

Parameters:
tableName - table name

getTableName

public java.lang.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:
java.lang.IndexOutOfBoundsException - if index is out of range

getRowIndexSuffix

public java.lang.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:
java.lang.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 java.lang.Object getValueAt(int row,
                                   int column)
Returns the value for the cell at columnIndex and rowIndex.

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

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to aValue.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.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,
                        java.lang.String key,
                        java.lang.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:
java.lang.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 java.lang.String getColumnName(int column)
Returns column name

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
column - the column being queried
Returns:
a string containing the name of column
Throws:
java.lang.IndexOutOfBoundsException - if column is out of range

getColumnName

public java.lang.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:
java.lang.IndexOutOfBoundsException - if column is out of range

setColumnName

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

Parameters:
index - column index
name - column name

getColumnOID

public java.lang.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:
java.lang.IndexOutOfBoundsException - if column is out of range

setColumnOID

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

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

getColumnDataType

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

Parameters:
index - column index

getColumnDataType

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

Parameters:
columnIndex - column index
rowIndex - row index

setColumnDataType

public void setColumnDataType(int index,
                              java.lang.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.