com.adventnet.snmp.snmp2
Class SnmpBitstring

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

public class SnmpBitstring
extends SnmpVar

Class of SNMP Bitstring Variable - Sub-class of SnmpVar. This class can be used to create an SnmpVar object of type SnmpString. It also has methods to retrive the value in different forms(eg. String, byte).

See Also:
Serialized Form

Constructor Summary
SnmpBitstring(byte[] b)
          Constructs a new SnmpBitstring by taking an octet string.
SnmpBitstring(byte[] b, int size)
          This takes a byte array and encodes.
SnmpBitstring(java.lang.String val)
          Constructs a new SnmpBitstring taking a string instance as its argument.
 
Method Summary
 java.lang.Object getVarObject()
          Returns the value of this SnmpBitstring SNMP variable as a String Object.
 byte[] toBytes()
          To return the value of this SnmpBitstring object as raw bytes.
 java.lang.String toString()
          To convert the value of this SnmpBitstring object to a printable string used in printing variables.
 java.lang.String toTagString()
          To convert the value of this SnmpBitstring object to a printable string where the type is tagged before the value with a tag BITSTRING:.
 java.lang.Object toValue()
          Returns the value of this SnmpBitstring SNMP variable as a string object.
 
Methods inherited from class com.adventnet.snmp.snmp2.SnmpVar
createVariable, getError, getType, getTypeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SnmpBitstring

public SnmpBitstring(java.lang.String val)
Constructs a new SnmpBitstring taking a string instance as its argument. The bytes of the String should be encoded as required by the byte[] constructor.
Parameters:
val - The string value for creating a new SnmpBitstring object.

SnmpBitstring

public SnmpBitstring(byte[] b)
Constructs a new SnmpBitstring by taking an octet string. The first byte should contain the count of bits in the last byte, which are not relevant.

SnmpBitstring

public SnmpBitstring(byte[] b,
                     int size)
              throws SnmpException
This takes a byte array and encodes. This is different from the other constructors in that, there is no need to specify the count of unused bits in the last byte. The size parameter should just specify the total length of the bit string(which is the number of bits).
Parameters:
b - the byte array to be used.
size - the length of the bit string
Throws:
SnmpException - is thrown on invalid parameters such as size less than the total number of bits in the array.
Method Detail

getVarObject

public java.lang.Object getVarObject()
Returns the value of this SnmpBitstring SNMP variable as a String Object. This method is the same as toValue().
Overrides:
getVarObject in class SnmpVar
Returns:
the value of this SnmpBitstring object as a printable string.

toValue

public java.lang.Object toValue()
Returns the value of this SnmpBitstring SNMP variable as a string object. This method is the same as toString().
Overrides:
toValue in class SnmpVar
Returns:
the value of this SnmpBitstring object as a printable string.

toString

public java.lang.String toString()
To convert the value of this SnmpBitstring object to a printable string used in printing variables.
Overrides:
toString in class SnmpVar
Returns:
the value of SnmpBitstring object as a printable string.

toTagString

public java.lang.String toTagString()
To convert the value of this SnmpBitstring object to a printable string where the type is tagged before the value with a tag BITSTRING:.
Overrides:
toTagString in class SnmpVar
Returns:
the value of SnmpBitstring object as a printable where the type is tagged before the value with a Tag - BITSTRING: .

toBytes

public byte[] toBytes()
To return the value of this SnmpBitstring object as raw bytes.
Overrides:
toBytes in class SnmpVar
Returns:
The value of this SnmpBitstring as byte value.


Copyright (c)AdventNet Inc., 1996-2004