com.adventnet.snmp.snmp2
Class SnmpCounter64

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.SnmpVar
        |
        +--com.adventnet.snmp.snmp2.SnmpCounter64
All Implemented Interfaces:
java.io.Serializable

public class SnmpCounter64
extends SnmpVar

Class of SNMP 64 bit COUNTER Variable. Since Java does not have a 64 bit unsigned type, the data is stored as long array of size 2.

See Also:
Serialized Form

Constructor Summary
SnmpCounter64(java.math.BigInteger val)
          The constructor takes a BigInteger as its argument.
SnmpCounter64(byte[] byteArray)
          This constructor takes a byte array as argument.
SnmpCounter64(long[] val)
          The constructor takes a long array of dimension 2 as its argument.
 
Method Summary
 long[] counter64Diff(SnmpCounter64 val)
          Returns the difference between two SnmpCounter64 numbers as a long array of length 2.
 long diff(SnmpCounter64 val)
          Returns the difference between this SnmpCounter64 and SnmpCounter64 argument as a long.
 boolean equals(java.lang.Object obj)
          Returns true if both the SnmpCounter64 objects are equal and false otherwise.
 java.lang.Object getVarObject()
          returns the value of SNMP variable as an object(long array of length 2).
 java.math.BigInteger toBigInteger()
          returns the value of SNMP variable as a BigInteger.
 byte[] toBytes()
          returns the value as raw bytes.
 java.lang.String toString()
          To convert the object to a printable string used in printing variables.
 java.lang.String toString(int radix)
          To convert the object to a printable string based on the radix provided.
 java.lang.String toTagString()
          converts the object to a printable string tagged with COUNTER64:
 java.lang.Object toValue()
          returns the value of SNMP variable as an object(long array of length 2).
 
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

SnmpCounter64

public SnmpCounter64(long[] val)
The constructor takes a long array of dimension 2 as its argument.

SnmpCounter64

public SnmpCounter64(byte[] byteArray)
This constructor takes a byte array as argument. This byteArray should contain the SnmpCounter64 value and it's length should be always 8.

For Example:
If the value of counter64 is 0xba12345f then the byteArray should contain
byteArray[0] = 0x00;
byteArray[1] = 0x00;
byteArray[2] = 0x00;
byteArray[3] = 0x00;
byteArray[4] = 0xba;
byteArray[5] = 0x12;
byteArray[6] = 0x34;
byteArray[7] = 0x5f;

From this byteArray the long array would be constructed. The constructed long array will have the following values in it
longArray[1] = 0x00000000;
longArray[1] = 0xab12345f;

Parameters:
byteArray - the counter 64 value as an array of bytes of length 8.
Throws:
java.lang.NullPointerException - if byteArray is null
java.lang.IllegalArgumentException - if byteArray is not of length 8.

SnmpCounter64

public SnmpCounter64(java.math.BigInteger val)
The constructor takes a BigInteger as its argument. The valid values ranges from 0 to 18446744073709551615(i.e., 2^64-1).
Method Detail

getVarObject

public java.lang.Object getVarObject()
returns the value of SNMP variable as an object(long array of length 2). Same as toValue().
Overrides:
getVarObject in class SnmpVar
Following copied from class: com.adventnet.snmp.snmp2.SnmpVar
Returns:
The value of the SnmpVar object as an appropriate object

toValue

public java.lang.Object toValue()
returns the value of SNMP variable as an object(long array of length 2).
Overrides:
toValue in class SnmpVar
Following copied from class: com.adventnet.snmp.snmp2.SnmpVar
Returns:
The value of the SnmpVar object as an appropriate object

toBigInteger

public java.math.BigInteger toBigInteger()
returns the value of SNMP variable as a BigInteger.

toString

public java.lang.String toString()
To convert the object to a printable string used in printing variables.
Overrides:
toString in class SnmpVar
Following copied from class: com.adventnet.snmp.snmp2.SnmpVar
Returns:
the SnmpVar object as a printable string.

toString

public java.lang.String toString(int radix)
To convert the object to a printable string based on the radix provided.
Parameters:
radix - the radix for which this counter64 object should be printed.

toTagString

public java.lang.String toTagString()
converts the object to a printable string tagged with COUNTER64:
Overrides:
toTagString in class SnmpVar
Following copied from class: com.adventnet.snmp.snmp2.SnmpVar
Returns:
the SnmpVar object as a printable String more descriptively with type of the SnmpVar object.

diff

public long diff(SnmpCounter64 val)
Returns the difference between this SnmpCounter64 and SnmpCounter64 argument as a long.
Throws:
java.lang.NullPointerException - if val is null.

counter64Diff

public long[] counter64Diff(SnmpCounter64 val)
Returns the difference between two SnmpCounter64 numbers as a long array of length 2.
Throws:
java.lang.NullPointerException - if val is null.

toBytes

public byte[] toBytes()
returns the value as raw bytes.
Overrides:
toBytes in class SnmpVar
Following copied from class: com.adventnet.snmp.snmp2.SnmpVar
Returns:
the value of this SnmpVar object as raw bytes.

equals

public boolean equals(java.lang.Object obj)
Returns true if both the SnmpCounter64 objects are equal and false otherwise.
Overrides:
equals in class java.lang.Object


Copyright (c)AdventNet Inc., 1996-2004