MySnmpCrawler API

snmp.message.pdu
Class SnmpVariable

java.lang.Object
  |
  +--org.opennms.protocols.snmp.SnmpVarBind
        |
        +--snmp.message.pdu.SnmpVariable
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, org.opennms.protocols.snmp.SnmpSyntax

public class SnmpVariable
extends org.opennms.protocols.snmp.SnmpVarBind

The SnmpVariable class represents the binded variable in the PDU. It contains the paring of the OID and the value of the variable.

Version:
$Revision: 0.1 $ $Date: 2004/03/09 06:03:52 $
Author:
Scott Cheng
See Also:
Serialized Form

Field Summary
private  SnmpOid oid
           
private  SnmpPdu pdu
           
private  SnmpValue value
           
 
Fields inherited from class org.opennms.protocols.snmp.SnmpVarBind
ASNTYPE
 
Constructor Summary
SnmpVariable()
          The default Constructor.
SnmpVariable(SnmpPdu pdu)
          Constructs the SnmpVariable object with the PDU that contains it.
SnmpVariable(java.lang.String strOid)
          Constructs the SnmpVariable object with the OID string.
 
Method Summary
 int decode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Decodes the binded variables from the passed ASN.1 buffer.
 int encode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Encodes the SnmpVariable object into the passed buffer.
 SnmpOid getSnmpOid()
          Gets the SnmpOid object of the variable.
 SnmpPdu getSnmpPdu()
          Gets the SnmpPdu object that contains the variable.
 SnmpValue getSnmpValue()
          Gets the SnmpValue object of the variable.
 java.lang.String toString()
          Gets the string representation of the SnmpVariable object.
 
Methods inherited from class org.opennms.protocols.snmp.SnmpVarBind
clone, decodeASN, duplicate, encodeASN, getName, getValue, setName, setName, setValue, typeId
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

oid

private SnmpOid oid

value

private SnmpValue value

pdu

private SnmpPdu pdu
Constructor Detail

SnmpVariable

public SnmpVariable()
The default Constructor.


SnmpVariable

public SnmpVariable(SnmpPdu pdu)
Constructs the SnmpVariable object with the PDU that contains it.

Parameters:
pdu - The PDU that contains the variable.

SnmpVariable

public SnmpVariable(java.lang.String strOid)
Constructs the SnmpVariable object with the OID string.

Method Detail

getSnmpOid

public SnmpOid getSnmpOid()
Gets the SnmpOid object of the variable.

Returns:
The SnmpOid object of the variable.

getSnmpValue

public SnmpValue getSnmpValue()
Gets the SnmpValue object of the variable.

Returns:
The SnmpValue object of the variable.

getSnmpPdu

public SnmpPdu getSnmpPdu()
Gets the SnmpPdu object that contains the variable.

Returns:
The SnmpPdu object that contains the variable.

decode

public int decode(byte[] buf,
                  int offset,
                  org.opennms.protocols.snmp.asn1.BerEncoder encoder)
           throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                  org.opennms.protocols.snmp.asn1.AsnDecodingException
Decodes the binded variables from the passed ASN.1 buffer. The encoder object provides a way for the data to be decoded. The offset marks the start location for the decoding operation.

Parameters:
buf - Encoded ASN.1 data
offset - Offset to first byte of encoded data
encoder - The encoder used to convert the data
Returns:
The byte offset immediantly after the last decoded byte of information.
Throws:
AnsDecodingException - Thrown if an error occurs while attempting to decode the data. This exception will be thrown byte encoder object.
org.opennms.protocols.snmp.SnmpPduEncodingException
org.opennms.protocols.snmp.asn1.AsnDecodingException

encode

public int encode(byte[] buf,
                  int offset,
                  org.opennms.protocols.snmp.asn1.BerEncoder encoder)
           throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                  org.opennms.protocols.snmp.asn1.AsnEncodingException
Encodes the SnmpVariable object into the passed buffer. The variable's data is encoded using the passed AsnEncoder object. The offset for the next object to be encoded is returned by the method.

Parameters:
buf - Storeage for the encoded data
offset - Offset to start encoding data
encoder - The encoder used to convert the data
Returns:
The offset of the next byte immediantly after the last encoded byte by this routine.
Throws:
AnsEncodingException - Thrown if the encoder encounters an error while building the buffer.
org.opennms.protocols.snmp.SnmpPduEncodingException
org.opennms.protocols.snmp.asn1.AsnEncodingException

toString

public java.lang.String toString()
Gets the string representation of the SnmpVariable object.

Overrides:
toString in class org.opennms.protocols.snmp.SnmpVarBind
Returns:
The string representation of the SnmpVariable object.

MySnmpCrawler API