KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > snmp > RowStatusEvent


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - RowStatusEvent.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.snmp;
23
24 import java.util.*;
25
26 import org.snmp4j.agent.mo.*;
27 import org.snmp4j.PDU;
28
29 public class RowStatusEvent extends DeniableEventObject {
30
31 // private static final long serialVersionUID = 8808826350825049569L;
32

33   private MOTable table;
34   private MOTableRow row;
35   private MOTableRow changeSet;
36   private int oldStatus;
37   private int newStatus;
38
39   public RowStatusEvent(Object JavaDoc source,
40                         MOTable table, MOTableRow row, MOTableRow changeSet,
41                         int oldStatus, int newStatus) {
42     this(source, table, row, changeSet, oldStatus, newStatus, false);
43   }
44
45   public RowStatusEvent(Object JavaDoc source,
46                         MOTable table, MOTableRow row, MOTableRow changeSet,
47                         int oldStatus, int newStatus, boolean deniable) {
48     super(source, deniable);
49     this.table = table;
50     this.row = row;
51     this.changeSet = changeSet;
52     this.oldStatus = oldStatus;
53     this.newStatus = newStatus;
54   }
55
56   public int getNewStatus() {
57     return newStatus;
58   }
59
60   public int getOldStatus() {
61     return oldStatus;
62   }
63
64   public MOTableRow getRow() {
65     return row;
66   }
67
68   public MOTable getTable() {
69     return table;
70   }
71
72   public MOTableRow getChangeSet() {
73     return changeSet;
74   }
75
76   /**
77    * Checks whether the row event represents an activation of a row.
78    * To distinguish between a committing and a preparing row status event,
79    * use {@link #isDeniable()}. If that method returns <code>true</code>,
80    * then the event is fired on behalf of the preparation phase.
81    * @return
82    * <code>true</code> if the new row status is createAndGo(4) or active(1)
83    * and the old status is not active(1).
84    */

85   public boolean isRowActivated() {
86     return (((getNewStatus() == RowStatus.createAndGo) ||
87              (getNewStatus() == RowStatus.active)) &&
88             (getOldStatus() != RowStatus.active));
89   }
90
91   /**
92    * Checks whether the row event represents a deactivation of a row.
93    * To distinguish between a committing and a preparing row status event,
94    * use {@link #isDeniable()}. If that method returns <code>true</code>,
95    * then the event is fired on behalf the preparation phase.
96    * @return
97    * <code>true</code> if the new row status is destroy(6) or notInService(2)
98    * and the old status is active(1).
99    */

100   public boolean isRowDeactivated() {
101     return (((getNewStatus() == RowStatus.destroy) ||
102              (getNewStatus() == RowStatus.notInService)) &&
103             (getOldStatus() == RowStatus.active));
104   }
105
106 }
107
Popular Tags