- java.lang.Object
-
- java.util.EventObject
-
- org.snmp4j.event.CounterEvent
-
- All Implemented Interfaces:
java.io.Serializable
public class CounterEvent extends java.util.EventObject
CounterEvent
is an event object that indicates that a specific counter needs to be incremented.At the same time a
CounterEvent
can be used by the event originator to retrieve the actual value of the specified counter. Listeners that maintain the specified counter value, must set the new value when receiving theCounterEvent
by using thesetCurrentValue(Variable currentValue)
method.- Version:
- 2.4.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Variable
currentValue
private long
increment
private java.lang.Object
index
private OID
oid
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description CounterEvent(java.lang.Object source, OID oid)
Creates aCounterEvent
for the specified counter.CounterEvent(java.lang.Object source, OID oid, long increment)
Creates aCounterEvent
for the specified counter.CounterEvent(java.lang.Object source, OID oid, java.lang.Object index, long increment)
Creates aCounterEvent
for the specified counter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Variable
getCurrentValue()
Gets the current value of the counter, as set by the maintainer of the counter (one of the event listeners).long
getIncrement()
The increment to be added to the counter value on behalf of this event.java.lang.Object
getIndex()
The index identifier of the counter value (if the counter belongs to a table of counters).OID
getOid()
Gets the instance object identifier of the counter.void
setCurrentValue(Variable currentValue)
Sets the current value of the counter.void
setIncrement(long increment)
Sets the increment of the event.java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
oid
private OID oid
-
currentValue
private Variable currentValue
-
increment
private long increment
-
index
private java.lang.Object index
-
-
Constructor Detail
-
CounterEvent
public CounterEvent(java.lang.Object source, OID oid)
Creates aCounterEvent
for the specified counter.- Parameters:
source
- the source of the event.oid
- the OID of the counter instance (typically, the counter is a scalar and thus the OID has to end on zero).
-
CounterEvent
public CounterEvent(java.lang.Object source, OID oid, long increment)
Creates aCounterEvent
for the specified counter.- Parameters:
source
- the source of the event.oid
- the OID of the counter instance (typically, the counter is a scalar and thus the OID has to end on zero).increment
- a positive natural number (default is 1) that defines the increment that needs to be added to the counter on behalf of this event.
-
CounterEvent
public CounterEvent(java.lang.Object source, OID oid, java.lang.Object index, long increment)
Creates aCounterEvent
for the specified counter.- Parameters:
source
- the source of the event.oid
- the OID of the counter instance (typically, the counter is a scalar and thus the OID has to end on zero).index
- an counter defined object that identifies the counter row within a table of counters.increment
- a positive natural number (default is 1) that defines the increment that needs to be added to the counter on behalf of this event.- Since:
- 2.4.2
-
-
Method Detail
-
getOid
public OID getOid()
Gets the instance object identifier of the counter.- Returns:
- an
OID
.
-
getCurrentValue
public Variable getCurrentValue()
Gets the current value of the counter, as set by the maintainer of the counter (one of the event listeners).
-
setCurrentValue
public void setCurrentValue(Variable currentValue)
Sets the current value of the counter. This method has to be called by the maintainer of the counter's value.
-
getIncrement
public long getIncrement()
The increment to be added to the counter value on behalf of this event. The default is 1.- Returns:
- the counter increment of this event.
- Since:
- 2.4.2
-
setIncrement
public void setIncrement(long increment)
Sets the increment of the event. This has to be done before the event is fired to have an effect!- Parameters:
increment
- the counter increment (must be a positive value for Counter32 counters!). For Counter64 counters, the value might be negative but is then interpreted as an unsinged long value.
-
getIndex
public java.lang.Object getIndex()
The index identifier of the counter value (if the counter belongs to a table of counters).- Returns:
- the row index identifier for this counter event or
null
if the counter is a scalar value. - Since:
- 2.4.2
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.EventObject
-
-