com.adventnet.snmp.snmp2
Class SnmpOpaque

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

public class SnmpOpaque
extends SnmpString

Class of SNMP Opaque Variable - Sub-class of SnmpString. An SnmpOpaque is used sometimes to wrap objects of other types. The SnmpVar constructor for this object allows such a usage. Decoded value of SnmpVar on such a usage of SnmpOpaque can be obtained using the decodeVariable method.

See Also:
Serialized Form

Fields inherited from class com.adventnet.snmp.snmp2.SnmpString
byteValue, enc, s_emptyString, value
 
Fields inherited from class com.adventnet.snmp.snmp2.SnmpVar
Type, varbindErrorVal
 
Constructor Summary
(package private) SnmpOpaque()
          Empty Constructor
  SnmpOpaque(byte[] b)
          Constructs a new SnmpOpaque object by taking a byte[].
  SnmpOpaque(SnmpVar var)
          Snmpvar constructor.
  SnmpOpaque(java.lang.String s)
          Constructs a SnmpOpaque object by taking a string.
 
Method Summary
 SnmpVar decodeVariable()
          Returns the SnmpVar object if any wrapped inside the SnmpOpaque object.
(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.
(package private) static SnmpVar newInstance(byte[] b)
          Factory method for decode
 java.lang.String toTagString()
          Converts the value of this SnmpOpaque object to a printable string where the type is tagged before the value with a tag OPAQUE:
 
Methods inherited from class com.adventnet.snmp.snmp2.SnmpString
equals, getVarObject, toBytes, toByteString, 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

SnmpOpaque

SnmpOpaque()
Empty Constructor

SnmpOpaque

public SnmpOpaque(SnmpVar var)
Snmpvar constructor. Allows to specify var object to be wrapped in as an SnmpOpaque object.
Parameters:
var - The SnmpVar object.

SnmpOpaque

public SnmpOpaque(java.lang.String s)
Constructs a SnmpOpaque object by taking a string.
Parameters:
s - String object

SnmpOpaque

public SnmpOpaque(byte[] b)
Constructs a new SnmpOpaque object by taking a byte[].
Parameters:
b - octet string
Method Detail

newInstance

static SnmpVar newInstance(byte[] b)
Factory method for decode
Parameters:
b - The bytevalue

toTagString

public java.lang.String toTagString()
Converts the value of this SnmpOpaque object to a printable string where the type is tagged before the value with a tag OPAQUE:
Overrides:
toTagString in class SnmpString
Returns:
the value of this SnmpOpaque object to a printable string where the type is tagged before the value with a tag OPAQUE:

getNumericValueAsString

public java.lang.String getNumericValueAsString()
This method will throw UnsupportedOperationException since this is not a numeric data type.
Overrides:
getNumericValueAsString in class SnmpString
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 SnmpString
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:
throws - an ArrayIndexOutOfBoundsException

decodeVariable

public SnmpVar decodeVariable()
                       throws SnmpException
Returns the SnmpVar object if any wrapped inside the SnmpOpaque object. This routine should be used only if it is certain that the contents represent an SnmpVar object. It does not guarantee the accurate results in case the object does not represent an SnmpVar.
Returns:
SnmpVar object corresponding to the contents.
Throws:
SnmpException - is thrown if contents do not represent a valid SnmpVar object.