MySnmpCrawler API

snmp.message.pdu
Class SnmpValue

java.lang.Object
  |
  +--snmp.message.pdu.SnmpValue
All Implemented Interfaces:
org.opennms.protocols.snmp.SnmpSyntax

public class SnmpValue
extends java.lang.Object
implements org.opennms.protocols.snmp.SnmpSyntax

The SnmpValue class represents an ASN.1 syntax of the SNMP value. It encapsulates the MBean attribute value taht maps to the associated object identifier and translates that value to the corresponding ASN.1 syntaxt.

Version:
$Revision: 0.1 $ $Date: 2004/03/09 06:03:52 $
Author:
Scott Cheng

Field Summary
private  MBeanAttribute attr
           
private  SnmpOid oid
           
private  SnmpDatatype snmpSyntax
           
private  SnmpVariable snmpVar
           
private  java.lang.Object value
           
 
Constructor Summary
SnmpValue()
          The default Constructor.
SnmpValue(SnmpOid oid)
          Constructs the SnmpValue object with the associated SnmpOId object.
SnmpValue(SnmpVariable snmpVar)
          Constructs the SnmpValue object with the SnmpVariable object that contains the SnmpOid and SnmpValue objects.
 
Method Summary
 int decode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Invokes the decodeASN method to decode the SNMP value from the passed buffer.
 int decodeASN(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
          Gets the SnmpSyntax object and decodes the actual SNMP value from the buffer accordingly.
 org.opennms.protocols.snmp.SnmpSyntax duplicate()
          Invokded to duplicate the SnmpValue object, but currectly it's not supported.
 int encode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Invokes the encodeASN method to encode the SNMP value into the passed buffer.
 int encodeASN(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
          Encodes the SNMP value using the passed encoder and stores the results in the passed buffer.
 MBeanAttribute getMBeanAttribute()
          Gets the MBeanAttribute object.
 org.opennms.protocols.snmp.SnmpSyntax getSnmpSyntax()
          Gets the SnmpSyntax object that contains the actual SNMP value.
 void setMBeanAttribute(MBeanAttribute attr)
          Sets the MBeanAttribute object obtained from the MBean and translates the attribute value to the ASN.1 syntax.
 java.lang.String toString()
          Gets the string representation of the SnmpValue object.
 byte typeId()
          Gets the ASN.1 type ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

snmpSyntax

private SnmpDatatype snmpSyntax

value

private java.lang.Object value

oid

private SnmpOid oid

snmpVar

private SnmpVariable snmpVar

attr

private MBeanAttribute attr
Constructor Detail

SnmpValue

public SnmpValue()
The default Constructor.


SnmpValue

public SnmpValue(SnmpVariable snmpVar)
Constructs the SnmpValue object with the SnmpVariable object that contains the SnmpOid and SnmpValue objects.

Parameters:
snmpVar - The SnmpVariable object.

SnmpValue

public SnmpValue(SnmpOid oid)
Constructs the SnmpValue object with the associated SnmpOId object.

Method Detail

setMBeanAttribute

public void setMBeanAttribute(MBeanAttribute attr)
                       throws SnmpException
Sets the MBeanAttribute object obtained from the MBean and translates the attribute value to the ASN.1 syntax.

Parameters:
attr - The MBeanAttribute object.
Throws:
SnmpException

getMBeanAttribute

public MBeanAttribute getMBeanAttribute()
Gets the MBeanAttribute object.

Returns:
The MBeanAttribute object.

getSnmpSyntax

public org.opennms.protocols.snmp.SnmpSyntax getSnmpSyntax()
Gets the SnmpSyntax object that contains the actual SNMP value.

Returns:
The SnmpSyntax object.

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
Invokes the decodeASN method to decode the SNMP value from the passed buffer.

Parameters:
buf - The encode buffer
offset - The offset byte to begin decoding
encoder - The decoder object.
Returns:
The index of the byte immediantly after the last decoded byte of information.
Throws:
org.opennms.protocols.snmp.asn1.AsnDecodingException - Thrown by the encoder if an error occurs trying to decode the data buffer.
org.opennms.protocols.snmp.SnmpPduEncodingException

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
Invokes the encodeASN method to encode the SNMP value into the passed buffer.

Parameters:
buf - The buffer to write the encoded information.
offset - The offset to start writing information
encoder - The encoder object.
Returns:
The offset of the byte immediantly after the last encoded byte.
Throws:
org.opennms.protocols.snmp.asn1.AsnEncodingException - Thrown if the encoder finds an error in the buffer.
org.opennms.protocols.snmp.SnmpPduEncodingException

typeId

public byte typeId()
Gets the ASN.1 type ID.

Specified by:
typeId in interface org.opennms.protocols.snmp.SnmpSyntax

encodeASN

public int encodeASN(byte[] buf,
                     int offset,
                     org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
              throws org.opennms.protocols.snmp.asn1.AsnEncodingException
Encodes the SNMP value using the passed encoder and stores the results in the passed buffer. An exception is thrown if an error occurs with the encoding of the information.

Specified by:
encodeASN in interface org.opennms.protocols.snmp.SnmpSyntax
Parameters:
buf - The buffer to write the encoded information.
offset - The offset to start writing information
encoder - The encoder object.
Returns:
The offset of the byte immediantly after the last encoded byte.
Throws:
org.opennms.protocols.snmp.asn1.AsnEncodingException - Thrown if the encoder finds an error in the buffer.

decodeASN

public int decodeASN(byte[] buf,
                     int offset,
                     org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
              throws org.opennms.protocols.snmp.asn1.AsnDecodingException
Gets the SnmpSyntax object and decodes the actual SNMP value from the buffer accordingly. If an error occurs during the decoding sequence then an AsnDecodingException is thrown by the method. The value is decoded using the AsnEncoder passed to the object.

Specified by:
decodeASN in interface org.opennms.protocols.snmp.SnmpSyntax
Parameters:
buf - The encode buffer
offset - The offset byte to begin decoding
encoder - The decoder object.
Returns:
The index of the byte immediantly after the last decoded byte of information.
Throws:
org.opennms.protocols.snmp.asn1.AsnDecodingException - Thrown by the encoder if an error occurs trying to decode the data buffer.

duplicate

public org.opennms.protocols.snmp.SnmpSyntax duplicate()
Invokded to duplicate the SnmpValue object, but currectly it's not supported.

Specified by:
duplicate in interface org.opennms.protocols.snmp.SnmpSyntax
Returns:
The duplicated SnmpSyntax object.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the SnmpValue object.

MySnmpCrawler API