SnmpTableListenerImpl.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:2k
源码类别:
SNMP编程
开发平台:
C/C++
- /* $Id: SnmpTableListenerImpl.java,v 1.3 2002/09/09 05:45:01 tonyjpaul Exp $ */
- /*
- * @(#)SnmpTableListenerImpl.java
- * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
- * Please read the COPYRIGHTS file for more
- */
- import java.util.*;
- import com.adventnet.snmp.snmp2.*;
- import com.adventnet.snmp.mibs.*;
- import com.adventnet.snmp.beans.*;
- public class SnmpTableListenerImpl extends
- com.adventnet.snmp.corba._SnmpTableListenerImplBase
- {
- public SnmpTableListenerImpl( com.adventnet.snmp.corba.SnmpTable tbl )
- {
- this.table = tbl;
- }
- // This method is called when trap is received by SnmpTrapReceiver
- public void tableChanged(com.adventnet.snmp.corba.TableEvent tblEvent) {
- try {
- StringBuffer sb = new StringBuffer();
- if ( tblEvent.startRow == 0) { // we're being notified of first row
- for (int i=0;i<table.getColumnCount();i++) // print column names
- sb.append(table.getColumnName(i)+" t");
- System.out.println(sb.toString());
- }
- if (table.getRowCount() == 0) { // no rows and we're being notified
- System.err.println("Request failed or timed out. n"+
- table.getErrorString());
- } else { // print the rows we're getting
- sb = new StringBuffer();
- for (int j= tblEvent.startRow;j<=tblEvent.endRow;j++) {
- for (int i=0;i<table.getColumnCount();i++)
- sb.append(table.getValueAt(j,i)+" t");
- }
- System.out.println(sb.toString());
- }
- } catch (Exception ex) {
- System.err.println("Failed: "+ ex);
- ex.printStackTrace();
- }
- }
- com.adventnet.snmp.corba.SnmpTable table;
- }
- //System.out.println("Got a trap" );
- //com.adventnet.snmp.beans.SnmpTableEvent event = ((SnmpTableEventImpl)tblEvent).tableEvent;
- //System.out.println( "Table Event: " );
- //System.out.println( "First Row: " + tblEvent.startRow );
- //System.out.println( "Last Row: " + tblEvent.endRow );
- //System.out.println( "Column : " + tblEvent.column );
- //System.out.println( "Type: " + tblEvent.Type );