01: /*_############################################################################
02: _##
03: _## SNMP4J - CounterEvent.java
04: _##
05: _## Copyright (C) 2003-2008 Frank Fock and Jochen Katz (SNMP4J.org)
06: _##
07: _## Licensed under the Apache License, Version 2.0 (the "License");
08: _## you may not use this file except in compliance with the License.
09: _## 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;
24: import org.snmp4j.smi.OID;
25: import org.snmp4j.smi.Variable;
26: import org.snmp4j.smi.Counter32; // for JavaDoc
27: import org.snmp4j.smi.Counter64;
28:
29: /**
30: * <code>CounterEvent</code> is an event object that indicates that a specific
31: * counter needs to be incremented.
32: * <p>
33: * At the same time a <code>CounterEvent</code>
34: * can be used by the event originator to retrieve the actual value of the
35: * specified counter. Listeners that maintain the specified counter value,
36: * must set the new value when receiving the <code>CounterEvent</code> by using
37: * the {@link #setCurrentValue(Variable currentValue)} method.
38: *
39: * @author Frank Fock
40: * @version 1.0
41: */
42: public class CounterEvent extends EventObject {
43:
44: private static final long serialVersionUID = 7916507798848195425L;
45:
46: private OID oid;
47: private Variable currentValue = new Counter32();
48:
49: /**
50: * Creates a <code>CounterEvent</code> for the specified counter.
51: * @param source
52: * the source of the event.
53: * @param oid
54: * the OID of the counter instance (typically, the counter is a scalar and
55: * thus the OID has to end on zero).
56: */
57: public CounterEvent(Object source, OID oid) {
58: super (source);
59: this .oid = oid;
60: }
61:
62: /**
63: * Gets the instance object identifier of the counter.
64: * @return
65: * an <code>OID</code>.
66: */
67: public OID getOid() {
68: return oid;
69: }
70:
71: /**
72: * Gets the current value of the counter, as set by the maintainer of the
73: * counter (one of the event listeners).
74: * @return
75: * a {@link Counter32} or {@link Counter64} instance.
76: */
77: public Variable getCurrentValue() {
78: return currentValue;
79: }
80:
81: /**
82: * Sets the current value of the counter. This method has to be called by
83: * the maintainer of the counter's value.
84: *
85: * @param currentValue
86: * a {@link Counter32} or {@link Counter64} instance.
87: */
88: public void setCurrentValue(Variable currentValue) {
89: this.currentValue = currentValue;
90: }
91: }
|