KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > util > TableEvent


1 /*_############################################################################
2   _##
3   _## SNMP4J - TableEvent.java
4   _##
5   _## Copyright 2003-2007 Frank Fock and Jochen Katz (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21 package org.snmp4j.util;
22
23 import org.snmp4j.smi.OID;
24 import org.snmp4j.smi.VariableBinding;
25 import org.snmp4j.PDU;
26
27 /**
28  * The <code>TableEvent</code> class reports events in a table retrieval
29  * operation.
30  *
31  * @author Frank Fock
32  * @version 1.8
33  * @since 1.0.2
34  * @see TableUtils
35  */

36 public class TableEvent extends RetrievalEvent {
37
38   private static final long serialVersionUID = 3340523737695933621L;
39
40   private OID index;
41
42   protected TableEvent(Object JavaDoc source, Object JavaDoc userObject) {
43     super(source, userObject);
44     this.userObject = userObject;
45   }
46
47   /**
48    * Creates a table event with a status.
49    * @param source
50    * the source of the event.
51    * @param userObject
52    * the user object or <code>null</code>.
53    * @param status
54    * one of the status constants defined for this object.
55    */

56   public TableEvent(Object JavaDoc source, Object JavaDoc userObject, int status) {
57     this(source, userObject);
58     this.status = status;
59   }
60
61   /**
62    * Creates a table event with an exception.
63    * @param source
64    * the source of the event.
65    * @param userObject
66    * the user object or <code>null</code>.
67    * @param exception
68    * an exception instance.
69    */

70   public TableEvent(Object JavaDoc source, Object JavaDoc userObject, Exception JavaDoc exception) {
71     this(source, userObject);
72     this.exception = exception;
73     this.status = STATUS_EXCEPTION;
74   }
75
76   /**
77    * Creates a table event with a report PDU.
78    * @param source
79    * the source of the event.
80    * @param userObject
81    * the user object or <code>null</code>.
82    * @param report
83    * a PDU of type {@link PDU#REPORT}.
84    */

85   public TableEvent(Object JavaDoc source, Object JavaDoc userObject, PDU report) {
86     this(source, userObject);
87     this.reportPDU = report;
88     this.status = STATUS_REPORT;
89   }
90
91   /**
92    * Creates a table event with row data.
93    *
94    * @param source
95    * the source of the event.
96    * @param userObject
97    * the user object or <code>null</code>.
98    * @param index
99    * the index OID of the row.
100    * @param cols
101    * an array of <code>VariableBinding</code> instances containing the
102    * elements of the row. The array may contain <code>null</code> elements
103    * which indicates that the agent does not return an instance for that
104    * column and row index. If an element is not <code>null</code>, then
105    * the <code>OID</code> of the variable binding contains the full instance
106    * <code>OID</code> of the variable.
107    */

108   public TableEvent(Object JavaDoc source, Object JavaDoc userObject,
109                     OID index, VariableBinding[] cols) {
110     super(source, userObject, cols);
111     this.index = index;
112   }
113
114   /**
115    * Gets the row index OID.
116    * @return
117    * the row's index OID or <code>null</code> if {@link #isError()} returns
118    * <code>true</code>.
119    */

120   public OID getIndex() {
121     return index;
122   }
123
124   /**
125    * Gets the columnar objects of the row.
126    * @return
127    * an array of <code>VariableBinding</code> instances containing the
128    * elements of the row. The array may contain <code>null</code> elements
129    * which indicates that the agent does not return an instance for that
130    * column and row index. If an element is not <code>null</code>, then
131    * the <code>OID</code> of the variable binding contains the full instance
132    * <code>OID</code> of the variable.<p>
133    * If {@link #isError()} returns <code>true</code>, <code>null</code>
134    * will be returned.
135    */

136   public VariableBinding[] getColumns() {
137     return vbs;
138   }
139
140
141 }
142
Popular Tags