com.adventnet.snmp.snmp2
Class SnmpNull

java.lang.Object
  extended by com.adventnet.snmp.snmp2.SnmpVar
      extended by com.adventnet.snmp.snmp2.SnmpNull
All Implemented Interfaces:
java.io.Serializable

public class SnmpNull
extends SnmpVar

Class of SNMP Null Variable - Sub-class of SnmpVar. This class can be used to created a SnmpVar object of type SnmpNull. It also has methods to retrieve the value in different forms(eg. String, byte). The SnmpNull type is used as a placeholder. Additionally it can take up the error indication for a particular OID. i.e SnmpAPI.NOSUCHOBJECTEXP, SnmpAPI.NOSUCHINSTANCEEXP, or SnmpAPI.ENDOFMIBVIEWEXP.

See Also:
Serialized Form

Field Summary
(package private)  byte[] byteValue
           
(package private)  int value
           
 
Fields inherited from class com.adventnet.snmp.snmp2.SnmpVar
Type, varbindErrorVal
 
Constructor Summary
SnmpNull()
          Creates an SnmpNull object with the value 0.
SnmpNull(byte val)
          Creates an SnmpNull object.
 
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 SnmpNull object as an appropriate Object type, in this case returns null.
 byte[] toBytes()
          Returns the value of this SnmpNull object as null with return type byte[].
 java.lang.String toString()
          Converts value of this SnmpNull object to a printable string.
 java.lang.String toTagString()
          Converts the value of this SnmpNull object to a printable string where the type is tagged before the value with the appropriate tag Type.
 java.lang.Object toValue()
          Returns the value of this SnmpNull object as an appropriate Object type, in this case returns null.
 
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

value

int value

byteValue

byte[] byteValue
Constructor Detail

SnmpNull

public SnmpNull()
Creates an SnmpNull object with the value 0.


SnmpNull

public SnmpNull(byte val)
Creates an SnmpNull object. Null Objects in Snmpv2c and Snmpv3 can take up additionally the error indication for the particular oid.

Parameters:
val - could be any of SnmpAPI.NOSUCHOBJECTEXP , SnmpAPI.NOSUCHINSTANCEEXP, or SnmpAPI.ENDOFMIBVIEWEXP.
Method Detail

getVarObject

public java.lang.Object getVarObject()
Returns the value of this SnmpNull object as an appropriate Object type, in this case returns null. This method is the same as toValue().

Specified by:
getVarObject in class SnmpVar
Returns:
the value of this SnmpNull object as a null value.

toValue

public java.lang.Object toValue()
Returns the value of this SnmpNull object as an appropriate Object type, in this case returns null.

Specified by:
toValue in class SnmpVar
Returns:
the value of this SnmpNull object as null value.

toString

public java.lang.String toString()
Converts value of this SnmpNull object to a printable string. Returns a string with value "NULL".

Specified by:
toString in class SnmpVar
Returns:
the value of this SnmpNull as a printable string as "NULL".

toTagString

public java.lang.String toTagString()
Converts the value of this SnmpNull object to a printable string where the type is tagged before the value with the appropriate tag Type. The tag type can be any of the SnmpVar types(i.e STRING, INTEGER, etc.).

Specified by:
toTagString in class SnmpVar
Returns:
the value of this SnmpNull object to a printable string where the type is tagged before the value with the appropriate tag type.

toBytes

public byte[] toBytes()
Returns the value of this SnmpNull object as null with return type byte[].

Specified by:
toBytes in class SnmpVar
Returns:
the value of this SnmpNull object as null with return type byte[].

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

Specified by:
encode in class SnmpVar
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