com.adventnet.snmp.snmp2
Class SnmpBitstring

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

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

Field Summary
(package private)  byte[] byteValue
          byteValue is the master value of the OCTETSTRING and is always valid The value of the octet string, never null
(package private) static byte[] s_emptyString
          immutable, hence shareable
(package private)  java.lang.String value
          The String representation of the bit string.
 
Fields inherited from class com.adventnet.snmp.snmp2.SnmpVar
Type, varbindErrorVal
 
Constructor Summary
(package private) SnmpBitstring()
           
  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
(package private)  int encode(byte[] buff, int space)
          ASN encoder
 java.lang.String getNumericValueAsString()
          This method will throw UnsupportedOperationException since this is not a numeric data type.
 java.lang.Object getVarObject()
          Returns the value of this SnmpBitstring SNMP variable as a String Object.
(package private) static SnmpVar newInstance(byte[] b)
          Factory method for decode
 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
 

Field Detail

s_emptyString

static final byte[] s_emptyString
immutable, hence shareable

byteValue

byte[] byteValue
byteValue is the master value of the OCTETSTRING and is always valid The value of the octet string, never null

value

java.lang.String value
The String representation of the bit string. value is the String representation that is generated only on demand then cached.
Constructor Detail

SnmpBitstring

SnmpBitstring()

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

newInstance

static SnmpVar newInstance(byte[] b)
Factory method for decode

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.

getNumericValueAsString

public java.lang.String getNumericValueAsString()
This method will throw UnsupportedOperationException since this is not a numeric data type.
Overrides:
getNumericValueAsString in class SnmpVar
Returns:
Nothing is returned since this method throws an exception.
Throws:
java.lang.UnsupportedOperationException - Since this is not a numeric data type.

encode

int encode(byte[] buff,
           int space)
     throws java.lang.ArrayIndexOutOfBoundsException
ASN encoder
Overrides:
encode in class SnmpVar
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer