KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > MOTableRowEvent


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - MOTableRowEvent.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (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
22 package org.snmp4j.agent.mo;
23
24 import java.util.*;
25
26 import org.snmp4j.mp.*;
27
28 /**
29  * The <code>MOTableRowEvent</code> class describes the changes
30  * @author Frank Fock
31  * @version 1.1
32  */

33 public class MOTableRowEvent extends DeniableEventObject {
34
35   private static final long serialVersionUID = 5846054060591503486L;
36
37   /**
38    * A single column of a row is changed.
39    */

40   public static final int CHANGE = 0;
41   /**
42    * A row is created.
43    */

44   public static final int CREATE = 1;
45   /**
46    * A row is added.
47    */

48   public static final int ADD = 2;
49   /**
50    * A row is deleted.
51    */

52   public static final int DELETE = 3;
53
54   /**
55    * This event type indicates that a complete row has been updated.
56    */

57   public static final int UPDATED = 4;
58
59
60   private MOTable table;
61   private MOTableRow row;
62   private MOTableRow preparedChanges;
63   private int type;
64   private int vetoColumn = -1;
65
66   /**
67    * Creates a table row event based on table, row and type that cannot be
68    * canceled by the event listener.
69    * @param source
70    * the event source.
71    * @param table
72    * the table.
73    * @param row
74    * the row associated with this event.
75    * @param type
76    * the event type.
77    */

78   public MOTableRowEvent(Object JavaDoc source,
79                          MOTable table, MOTableRow row,
80                          int type) {
81     super(source, false);
82     this.table = table;
83     this.row = row;
84     this.type = type;
85   }
86
87   /**
88    * Creates a table row event based on table, row and type that may be
89    * canceled by the event listener depending on the specified flag.
90    * @param source
91    * the event source.
92    * @param table
93    * the table.
94    * @param row
95    * the row associated with this event.
96    * @param type
97    * the event type.
98    * @param deniable
99    * indicates whether the event can be canceled through setting its
100    * denyReason member to a SNMP error status.
101    * @since 1.1
102    */

103   public MOTableRowEvent(Object JavaDoc source,
104                          MOTable table, MOTableRow row,
105                          int type, boolean deniable) {
106     super(source, deniable);
107     this.table = table;
108     this.row = row;
109     this.type = type;
110   }
111
112   /**
113    * Creates a table row event based on table, row, prepared changes, and type
114    * that cannot be canceled by the event listener.
115    *
116    * @param source
117    * the event source.
118    * @param table
119    * the table.
120    * @param row
121    * the row associated with this event.
122    * @param preparedChanges
123    * a row instance containing the prepared changes for <code>row</code>.
124    * @param type
125    * the event type.
126    */

127   public MOTableRowEvent(Object JavaDoc source,
128                          MOTable table,
129                          MOTableRow row,
130                          MOTableRow preparedChanges,
131                          int type) {
132     super(source, false);
133     this.table = table;
134     this.row = row;
135     this.preparedChanges = preparedChanges;
136     this.type = type;
137   }
138
139   /**
140    * Creates a table row event based on table, row, prepared changes, and type.
141    * @param source
142    * the event source.
143    * @param table
144    * the table.
145    * @param row
146    * the row associated with this event.
147    * @param preparedChanges
148    * a row instance containing the prepared changes for <code>row</code>.
149    * @param type
150    * the event type.
151    * @param deniable
152    * indicates whether the event can be canceled through setting its
153    * denyReason member to a SNMP error status.
154    * @since 1.1
155    */

156   public MOTableRowEvent(Object JavaDoc source,
157                          MOTable table,
158                          MOTableRow row,
159                          MOTableRow preparedChanges,
160                          int type,
161                          boolean deniable) {
162     super(source, deniable);
163     this.table = table;
164     this.row = row;
165     this.preparedChanges = preparedChanges;
166     this.type = type;
167   }
168
169   public MOTableRow getRow() {
170     return row;
171   }
172
173   public MOTable getTable() {
174     return table;
175   }
176
177   public int getType() {
178     return type;
179   }
180
181   /**
182    * Returns the veto status that revokes the row operation or zero if the
183    * row operation is accepted by all listeners.
184    * @return
185    * a SNMP or sub-agent protocol error status or zero if the row operation
186    * is accepted.
187    */

188   public int getVetoStatus() {
189     return getDenyReason();
190   }
191
192   public MOTableRow getPreparedChanges() {
193     return preparedChanges;
194   }
195
196   public int getVetoColumn() {
197     return vetoColumn;
198   }
199
200   /**
201    * Sets the veto status that revokes the row operation.
202    * @param denyReason
203    * a SNMP error status or a sub-agent protocol specific error status.
204    * In any case zero represents no error.
205    */

206   public void setVetoStatus(int denyReason) {
207     setDenyReason(denyReason);
208   }
209
210   /**
211    * Sets the column index on whose behalf the veto is issued.
212    * @param vetoColumn
213    * a column index.
214    */

215   public void setVetoColumn(int vetoColumn) {
216     this.vetoColumn = vetoColumn;
217   }
218
219   public String JavaDoc toString() {
220     return getClass().getName()+"[source="+source+",table="+table+",row="+row+
221         ",type="+type+",deniable="+isDeniable()+"]";
222   }
223 }
224
Popular Tags