com.adventnet.snmp.snmp2
Class SnmpCounter

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.SnmpVar
        |
        +--com.adventnet.snmp.snmp2.SnmpUnsignedInt
              |
              +--com.adventnet.snmp.snmp2.SnmpCounter

public class SnmpCounter
extends SnmpUnsignedInt

Class of SNMP Counter Variable - Sub-class of SnmpUnsignedInt.

See Also:
Serialized Form

Fields inherited from class com.adventnet.snmp.snmp2.SnmpUnsignedInt
byteValue, value
 
Fields inherited from class com.adventnet.snmp.snmp2.SnmpVar
Type, varbindErrorVal
 
Constructor Summary
SnmpCounter(long s)
          Constructor requires a long as its argument.
 
Method Summary
(package private)  int encode(byte[] buff, int space)
          ASN encoder
 long getIncrement(long lastValue)
          Gets the (positive) increment of this Counter variable over a long.
 long getIncrement(SnmpCounter c)
          Gets the (positive) increment of this Counter variable over another.
 java.lang.String toTagString()
          To convert the object to a printable string tagged with Counter:
 
Methods inherited from class com.adventnet.snmp.snmp2.SnmpUnsignedInt
equals, getNumericValueAsString, getVarObject, longValue, toBytes, toString, toValue
 
Methods inherited from class com.adventnet.snmp.snmp2.SnmpVar
createVariable, getError, getType, getTypeString
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SnmpCounter

public SnmpCounter(long s)
Constructor requires a long as its argument.
Parameters:
s - long value The valid values ranges from 0 to 4294967295(both inclusive).
Method Detail

toTagString

public java.lang.String toTagString()
To convert the object to a printable string tagged with Counter:
Overrides:
toTagString in class SnmpUnsignedInt
Returns:
string tagged with Counter:

getIncrement

public long getIncrement(SnmpCounter c)
Gets the (positive) increment of this Counter variable over another. Takes care of wraparound by adding the MAX counter value if negative.

getIncrement

public long getIncrement(long lastValue)
Gets the (positive) increment of this Counter variable over a long. Takes care of wraparound by adding the MAX counter value if negative.

encode

int encode(byte[] buff,
           int space)
     throws java.lang.ArrayIndexOutOfBoundsException
ASN encoder
Overrides:
encode in class SnmpUnsignedInt
Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer