KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > event > CounterEvent


1 /*_############################################################################
2   _##
3   _## SNMP4J - CounterEvent.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.event;
22
23 import java.util.EventObject JavaDoc;
24 import org.snmp4j.smi.OID;
25 import org.snmp4j.smi.Variable;
26 import org.snmp4j.smi.Counter32;
27 // for JavaDoc
28
import org.snmp4j.smi.Counter64;
29
30 /**
31  * <code>CounterEvent</code> is an event object that indicates that a specific
32  * counter needs to be incremented.
33  * <p>
34  * At the same time a <code>CounterEvent</code>
35  * can be used by the event originator to retrieve the actual value of the
36  * specified counter. Listeners that maintain the specified counter value,
37  * must set the new value when receiving the <code>CounterEvent</code> by using
38  * the {@link #setCurrentValue(Variable currentValue)} method.
39  *
40  * @author Frank Fock
41  * @version 1.0
42  */

43 public class CounterEvent extends EventObject JavaDoc {
44
45   private static final long serialVersionUID = 7916507798848195425L;
46
47   private OID oid;
48   private Variable currentValue = new Counter32();
49
50   /**
51    * Creates a <code>CounterEvent</code> for the specified counter.
52    * @param source
53    * the source of the event.
54    * @param oid
55    * the OID of the counter instance (typically, the counter is a scalar and
56    * thus the OID has to end on zero).
57    */

58   public CounterEvent(Object JavaDoc source, OID oid) {
59     super(source);
60     this.oid = oid;
61   }
62
63   /**
64    * Gets the instance object identifier of the counter.
65    * @return
66    * an <code>OID</code>.
67    */

68   public OID getOid() {
69     return oid;
70   }
71
72   /**
73    * Gets the current value of the counter, as set by the maintainer of the
74    * counter (one of the event listeners).
75    * @return
76    * a {@link Counter32} or {@link Counter64} instance.
77    */

78   public Variable getCurrentValue() {
79     return currentValue;
80   }
81
82   /**
83    * Sets the current value of the counter. This method has to be called by
84    * the maintainer of the counter's value.
85    *
86    * @param currentValue
87    * a {@link Counter32} or {@link Counter64} instance.
88    */

89   public void setCurrentValue(Variable currentValue) {
90     this.currentValue = currentValue;
91   }
92 }
93
Popular Tags