|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.beans.SnmpServer | +--com.adventnet.snmp.beans.SnmpTarget | +--com.adventnet.snmp.beans.SnmpTable
The SnmpTable class handles polling for SNMP tables. It has been designed to support the Model-View-Controller design of JFC/swing applications, although this class can be used without JFC. An extension of this class in the com.adventnet.snmp.ui package is explicitly for JFC.
To use the table class, instantiate, and identify the SNMP table to be used. Then perform operations on the table, or register for table change events. For example,
SnmpTable table = new SnmpTable(); table.setTargetHost( "localhost" ); // set the agent hostname table.loadMibs("rfc1213-mib"); // load MIBs
table.addSnmpTableListener(listener); // specify the listener
table.setTableOID("ifTable"); // this starts polling of table data
The resources used by this class are automatically garbage collected. No need to close sessions, or other cleanup by the user.
See the getSnmpTable.java application in the applications directory.
Field Summary | |
static int |
SNMP_VARIABLE_BINDING_DATA
Constant to specify the format in which the data has to be returned. |
static int |
SNMP_VARIABLE_DATA
Constant to specify the format in which the data has to be returned. |
static int |
STRING_DATA
Constant to specify the format in which the data has to be returned.String is the default. |
Fields inherited from class com.adventnet.snmp.beans.SnmpTarget |
serialize, SNMPGET, SNMPGETBULK, SNMPGETNEXT, SNMPINFORM, SNMPREPORT, SNMPRESPONSE, SNMPSET, SNMPTRAP, SNMPV2TRAP, VERSION1, VERSION2C, VERSION3 |
Fields inherited from class com.adventnet.snmp.beans.SnmpServer |
AUTH_NO_PRIV, AUTH_PRIV, CBC_3DES, CBC_DES, CFB_AES_128, CFB_AES_192, CFB_AES_256, MD5_AUTH, NO_AUTH, NO_AUTH_NO_PRIV, NO_PRIV, oidList, SHA_AUTH |
Constructor Summary | |
SnmpTable()
Use this constructor for applications. |
|
SnmpTable(java.applet.Applet applet)
Use this constructor for applets. |
|
SnmpTable(int protocol,
ProtocolOptions options)
Use this constructor for applications which uses protocols other than UDP/IP. |
|
SnmpTable(int port,
java.lang.String session)
Use this constructor for creating a new session for this application. |
|
SnmpTable(SnmpSession ses,
MibOperations mib)
This constructor is used to create an SnmpTable instance with a specified SnmpSession and MibOperations. |
Method Summary | |
void |
addRow(boolean Status,
java.lang.String[] oidlist,
java.lang.String[] s)
To add a new row of data into the table. |
void |
addSnmpTableListener(SnmpTableListener l)
Adds a SnmpTableListener instance to the listener's list.Whenever a change in SnmpTable occurs all the registered listeners will be notified. |
protected void |
checkDifferences(java.util.Vector oldData)
This method compares current table data with old data and notifies registered listeners of changes |
protected void |
compareRow(int row,
java.util.Vector oldData)
This method compares current data with old data for a given row and notifies registered listeners of changes |
void |
deleteRow(java.lang.String oid)
To delete a row of data from the table. |
void |
deleteTableRow(java.lang.String oid)
To delete a row of data from the table. |
protected void |
finalize()
Cleans up an object when there are no more references to the object. |
protected void |
genTableEvent(SnmpTableEvent evt)
Generate the table events to the listeners. |
java.lang.Object |
getCellValue(java.lang.String tableOID,
int rowIndex,
int columnIndex)
To get the value for the cell specified by the row and column index. |
java.lang.String[] |
getColumn(int columnIndex)
Returns a string array of data for a column in the Table,represented by the index. |
java.lang.String[] |
getColumn(java.lang.String columnName)
Returns a string array of data for a column in the Table, represented by the column name.Set the tableOID using setTableOID(). |
java.lang.Class |
getColumnClass(int columnIndex)
Returns the class to be used as renderer and editor for the column. |
int |
getColumnCount()
Returns the number of columns in the table corresponding to the table OID already set. |
MibNode |
getColumnMibNode(int columnIndex)
To Get the MibNode corresponding to the table column specified by the column index |
java.lang.String |
getColumnName(int columnIndex)
Returns the name of the column specified by the column index. |
int |
getDataType()
Returns the datatype in which the table data will be returned. |
int[] |
getHoles()
Returns the index of the not-implemented columns.Holes are the columns that are not defined in the agent. |
java.lang.String[][] |
getIndices()
Returns the indices of the SnmpTable. |
java.lang.String[][] |
getNotAccessibleIndex()
Returns the values for the not-accessible indices in the table. |
java.lang.String[] |
getNotAccessibleIndexColumns()
Returns the names of the not-accessible index columns in the table. |
boolean |
getPerformSets()
To check if the values will get set if some change is made in any table field which has write access(any editable cell). |
void |
getPerformSets(boolean allowSets)
To Activate/Deactivate an editable table field (cell). |
int |
getPollInterval()
Returns the current polling interval in seconds. |
boolean |
getRetrievalMode()
Returns the mode of retrieval of table data. |
SnmpVarBind[] |
getRow(int index)
To get data for a table row,specified by its position in the table. |
java.lang.String[] |
getRow(java.lang.String tableOID,
java.lang.String index)
Returns the data for a row of the Table specified by the index . |
int |
getRowCount()
Returns the number of rows of data available in the SnmpTable. |
java.lang.String |
getTableOID()
To get table oid used with this SnmpTable instance. |
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
To get the value for the cell specified by the row and column index. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
To check if the cell at the specified index is editable or not. |
void |
refreshTable()
Refreshes the table data. |
void |
removeSnmpTableListener(SnmpTableListener l)
Remove a listener from the list that's notified each time a change in the SNMP Table occurs. |
void |
run()
The run method does polling and updates of the table at specified polling itervals. |
void |
setCellValue(java.lang.String tableOID,
java.lang.Object aValue,
int rowIndex,
int columnIndex)
Sets the value for the cell specified by the row and column index. |
void |
setColumnsPolled(java.util.Vector index)
Sets the columns that needs to be polled. |
void |
setDataType(int type)
Set the type in which the data has to be returned when the table data is got using the getValueAt or getCellValue methods.By default these methods will return table data as String objects.To get the table data as SnmpVar or SnmpVarBind object, the respective constant can be set using setDataType() method. |
void |
setObjectIDList(java.lang.String[] s)
Sets the column names of the table that need to be polled. |
void |
setParams(java.lang.String host,
java.lang.String mib,
java.lang.String tableOID)
To set multiple parameters like TargetHost,MibModule and TableOID |
void |
setPollInterval(int i)
To set the polling interval in seconds. |
void |
setRetrievalMode(boolean mode)
To set the mode of retrieval. |
void |
setTableOID(java.lang.String tableOID)
Sets the table OID to be used with this SnmpTable instance. |
void |
setTableOIDWoStart(java.lang.String tableOID)
To set the table OID without starting polling. |
void |
setValueAt(java.lang.Object aValue,
int rowIndex,
int columnIndex)
Sets the value for the cell specified by the row and column index. |
protected void |
showErrorMessage(java.lang.String str)
|
void |
startPollingTable()
Method to start the polling of Table.This can be used after setting the table column oids using setObjectIDList.If the method setTableOID is used to set the oid of the table,this method need not be called explicitly as the setTableOID() method calls this method internally. |
void |
stopPollingTable()
Method to stop the polling of Table. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.adventnet.snmp.beans.CustomizerTemplate |
create_v3_tables, getSnmpEngineTable, getUSMTable, initSecurityProvider, isSupportedSecurityModel, manage_v3_tables |
Field Detail |
public static final int STRING_DATA
public static final int SNMP_VARIABLE_DATA
public static final int SNMP_VARIABLE_BINDING_DATA
Constructor Detail |
public SnmpTable(SnmpSession ses, MibOperations mib)
ses
- Instance of SnmpSession
but not null and also the created
SnmpSession should be opened before using in this constructor.mib
- Instance of MibOperations
public SnmpTable()
public SnmpTable(int protocol, ProtocolOptions options)
public SnmpTable(int port, java.lang.String session)
public SnmpTable(java.applet.Applet applet)
Method Detail |
public void setParams(java.lang.String host, java.lang.String mib, java.lang.String tableOID)
host
- target hostmib
- mib filetableOID
- OID of the tablepublic int getRowCount()
public int getColumnCount()
public java.lang.String getColumnName(int columnIndex)
columnIndex
- index of the column in the table.
public java.lang.Class getColumnClass(int columnIndex)
columnIndex
- index of the column in the table
public boolean isCellEditable(int rowIndex, int columnIndex)
rowIndex
- index of the row to which the cell belongscolumnIndex
- index of the column to which the cell belongs
public java.lang.Object getCellValue(java.lang.String tableOID, int rowIndex, int columnIndex)
tableOID
- OID of the table to which the cell belongs.rowIndex
- position of the row whose value is to be looked up.columnIndex
- position of the column whose value is to be looked up.
ErrorMessages
,
SnmpTarget.getErrorString()
,
SnmpTarget.getErrorCode()
,
setDataType(int type)
,
setCellValue(String tableOID,Object aValue, int rowIndex,int columnIndex)
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
rowIndex
- position of the row whose value is to be looked up.columnIndex
- position of the column whose value is to be looked up.
setDataType(int type)
,
setValueAt(Object aValue, int rowIndex,int columnIndex)
public void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
The following errorCodes can be set SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED,
REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN,
SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP errors defined in ErrorMessages.
INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
aValue
- the new value that needs to be set.rowIndex
- position of the row whose value is to be changed.columnIndex
- position of the column whose value is to be changed.getValueAt(int rowIndex, int columnIndex)
,
ErrorMessages
,
SnmpTarget.getErrorCode()
,
SnmpTarget.getErrorString()
protected void showErrorMessage(java.lang.String str)
public void setCellValue(java.lang.String tableOID, java.lang.Object aValue, int rowIndex, int columnIndex)
The following errorCodes can be set SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED,
REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN,
SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP errors defined in ErrorMessages.
INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
tableOID
- OID of the table to which the cell belongs.aValue
- the new value that needs to be set.rowIndex
- position of the row whose value is to be changed.columnIndex
- position of the column whose value is to be changed.getCellValue(String tableOID, int rowIndex, int columnIndex)
,
ErrorMessages
,
SnmpTarget.getErrorCode()
,
SnmpTarget.getErrorString()
public void addSnmpTableListener(SnmpTableListener l)
l
- an instance of SnmpTableListener to be added.A instance of a
class implementing SnmpTableListener interface.SnmpTableListener
public void removeSnmpTableListener(SnmpTableListener l)
l
- an instance of SnmpTableListener which needs to be removed
from the list.SnmpTableListener
public java.lang.String getTableOID()
public void setTableOIDWoStart(java.lang.String tableOID) throws DataException
tableOID
- OID of the table as a String
DataException
- is thrown if data is invalid
The following errorcodes can be set MIB_NODE_UNAVAIL,INVALID_TABLE_OIDErrorMessages
,
SnmpTarget.getErrorString()
,
SnmpTarget.getErrorCode()
public void setObjectIDList(java.lang.String[] s)
setObjectIDList
in class SnmpTarget
s
- a one dimensional array of column namespublic void setTableOID(java.lang.String tableOID) throws DataException
tableOID
- the Object ID of the table, e.g. ifTable
DataException
- is thrown if data is invalid
The following errorcodes can be set MIB_NODE_UNAVAIL,INVALID_TABLE_OIDErrorMessages
,
SnmpTarget.getErrorString()
,
SnmpTarget.getErrorCode()
public java.lang.String[][] getNotAccessibleIndex()
public java.lang.String[] getNotAccessibleIndexColumns()
public void addRow(boolean Status, java.lang.String[] oidlist, java.lang.String[] s) throws DataException
Status
- true if the table has EntryStatus column and false if it has RowStatus column.oidlist
- string array of Object ids of the table columns for which the data has to be set.s
- string array of values to be set in the row.
DataException
- is thrown on errors.public void deleteRow(java.lang.String oid)
oid
- rowStatus.index .Index represent the instance value of the row which
needs to be deleted from the table.public void deleteTableRow(java.lang.String oid) throws DataException
oid
- rowStatus.index .Index represent the instance value of the row which
needs to be deleted from the table.
DataException
- is thrown on errors.public java.lang.String[][] getIndices()
public void startPollingTable()
public void stopPollingTable()
public void refreshTable()
public int getDataType()
setDataType(int type)
public void setDataType(int type)
type
- STRING_DATA to get String values,
SNMP_VARIABLE_DATA to get SnmpVar values,SNMP_VARIABLE_BINDING_DATA to get
data as SnmpVarBinds.public void setColumnsPolled(java.util.Vector index)
index
- vector of column indices that needs to be polled.public boolean getRetrievalMode()
public void setRetrievalMode(boolean mode)
mode
- either true or false.public void run()
run
in interface java.lang.Runnable
ErrorMessages
,
SnmpTarget.getErrorCode()
,
SnmpTarget.getErrorString()
protected void checkDifferences(java.util.Vector oldData)
oldData
- is the data in the table before current pollprotected void compareRow(int row, java.util.Vector oldData)
row
- the row which has to be comparedoldData
- is the data in the table before current pollprotected void genTableEvent(SnmpTableEvent evt)
evt
- an instance of SnmpTableEvent.protected void finalize() throws java.lang.Throwable
finalize
in class SnmpServer
java.lang.Throwable
- - in case of finalization errors.public java.lang.String[] getColumn(int columnIndex)
columnIndex
- position of the column whose value is required.
public java.lang.String[] getColumn(java.lang.String columnName)
columnName
- name of the column
public SnmpVarBind[] getRow(int index)
index
- position of the row in the table.
getRow(String tableOID,String index)
public java.lang.String[] getRow(java.lang.String tableOID, java.lang.String index)
tableOID
- the OID of the table to which the row belongs.index
- instance value of the row in the table.
getRow(int index)
public int getPollInterval()
public void setPollInterval(int i)
i
- poll interval in seconds.public MibNode getColumnMibNode(int columnIndex)
columnIndex
- index of the column
public boolean getPerformSets()
public void getPerformSets(boolean allowSets)
public int[] getHoles()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |