OpenNMS API 1.2.9

## org.opennms.protocols.snmp
Class SnmpVarBind

    java.lang.Object
      org.opennms.protocols.snmp.SnmpVarBind

All Implemented Interfaces:
  java.lang.Cloneable, java.io.Serializable, SnmpSyntax

public class SnmpVarBind
extends java.lang.Object
implements SnmpSyntax, java.lang.Cloneable, java.io.Serializable

This class defined the SNMP variables that are transmitted to and from an agent. A variable is defined by its name (a SnmpObjectId) and its value (SnmpSyntax). The SnmpVarBind is used by the SnmpPduPacket class and uses SnmpObjectId along with any class that implements the SnmpSyntax interface.

Version:
  1.1.1.1
Author:
  Brian Weaver
See Also:
  `SnmpSyntax`, `SnmpPduPacket`, Serialized Form

Field Summary
`static byte` `ASNTYPE` The ASN.1 identifier used to mark SNMP variables
`private SnmpObjectId` `m_name` The object identifier that uniquely identifies the "value".
`private SnmpSyntax` `m_value` The actual value object associated with the object identifier.
`(package private) static long` `serialVersionUID` Allows for evolution of serialization format.

Constructor Summary
`SnmpVarBind()` The default class constructor.
`SnmpVarBind(SnmpObjectId name)` Constructs a specific variable with the "name" equal to the passed object identifier.
`SnmpVarBind(SnmpObjectId name, SnmpSyntax value)` Constructs a variable with the passed name and value.
`SnmpVarBind(SnmpVarBind second)` Class copy constructor.
`SnmpVarBind(java.lang.String name)` Constructs a new variable with the give name.
`SnmpVarBind(java.lang.String name, SnmpSyntax value)` Constructs a new variable with the passed name and value.

Method Summary
`java.lang.Object` `clone()` Returns a newly created duplicate object to the caller
`int` `decodeASN(byte[] buf, int offset, AsnEncoder encoder)` Used to recover the encoded variable data from the passed ASN.1 buffer.
`SnmpSyntax` `duplicate()` Returns a newly created duplicate object to the caller
`int` `encodeASN(byte[] buf, int offset, AsnEncoder encoder)` Encodes the SnmpVarBind object into the passed buffer.
`SnmpObjectId` `getName()` Returns the object identifier that names the variable.
`SnmpSyntax` `getValue()` Retreives the variable's value.
`void` `setName(SnmpObjectId name)` Sets the variable's object identifier name.
`void` `setName(java.lang.String name)` Sets the variable's name to passed value.
`void` `setValue(SnmpSyntax value)` Sets the value for the variable
`java.lang.String` `toString()` Converts the object to a string representation
`byte` `typeId()` Returns the ASN.1 type id for the object.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### serialVersionUID

    static final long serialVersionUID

  Allows for evolution of serialization format.

  See Also:
    Constant Field Values

### m_name

    private SnmpObjectId m_name

  The object identifier that uniquely identifies the "value".

### m_value

    private SnmpSyntax m_value

  The actual value object associated with the object identifier.

### ASNTYPE

    public static final byte ASNTYPE

  The ASN.1 identifier used to mark SNMP variables

  See Also:
    Constant Field Values

Constructor Detail

### SnmpVarBind

    public SnmpVarBind()

  The default class constructor. Constructs an SnmpVarBind with a default object identifier and a null value

See Also:
  `SnmpObjectId.SnmpObjectId(java.lang.String)`, `SnmpNull.SnmpNull(org.opennms.protocols.snmp.SnmpNull)`

### SnmpVarBind

    public SnmpVarBind(SnmpObjectId name)

  Constructs a specific variable with the "name" equal to the passed object identifier. The variable portion is set to an instance of SnmpNull.

Parameters:
  `name` - The object identifer name for this variable.

### SnmpVarBind

    public SnmpVarBind(SnmpObjectId name,
                       SnmpSyntax value)

  Constructs a variable with the passed name and value. The name and value are duplicated so that any further changes to the passed data will not affect the snmp variable.

Parameters:
  `name` - The object identifier name
  `value` - The syntax object.

### SnmpVarBind

    public SnmpVarBind(java.lang.String name)

  Constructs a new variable with the give name. The name must be a dotted decimal object identifier string.

Parameters:
  `name` - Dotted decimal object identifier.
See Also:
  `SnmpObjectId`

### SnmpVarBind

    public SnmpVarBind(java.lang.String name,
                       SnmpSyntax value)

  Constructs a new variable with the passed name and value. The name must be in a dotted decimal format. The value must not be null, but must be a valid SnmpSyntax object.

Parameters:
  `name` - The dotted decimal object identifer name
  `value` - The SnmpSyntax value for the variable

### SnmpVarBind

    public SnmpVarBind(SnmpVarBind second)

  Class copy constructor. Makes a duplicate copy of the passed variable and stores the new references in self. If the passed variable is modified after the construction, it will not affect the object.

Parameters:
  `second` - The variable to copy

Method Detail

### getName

    public SnmpObjectId getName()

  Returns the object identifier that names the variable.

  Returns:
    The variable's object identifier

### setName

    public void setName(SnmpObjectId name)

  Sets the variable's object identifier name.

  Parameters:
    `name` - The new object id for the variable.

### setName

    public void setName(java.lang.String name)

  Sets the variable's name to passed value.

  Parameters:
    `name` - The dotted decimal object identifier.

### getValue

    public SnmpSyntax getValue()

  Retreives the variable's value.

  Returns:
    The SnmpSyntax object for the variable.

### setValue

    public void setValue(SnmpSyntax value)

  Sets the value for the variable

  Parameters:
    `value` - The new value for the object

### typeId

    public byte typeId()

  Returns the ASN.1 type id for the object.

  Specified by:
    `typeId` in interface `SnmpSyntax`
  Returns:
    The ASN.1 type identifier.

### encodeASN

    public int encodeASN(byte[] buf,
                         int offset,
                         AsnEncoder encoder)
                  throws AsnEncodingException

  Encodes the SnmpVarBind 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. This method is defined to fulfill the contract with the SnmpSytnax interface.

  Specified by:
    `encodeASN` in interface `SnmpSyntax`
  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.
    `AsnEncodingException` - Thrown if an encoding error occurs

### decodeASN

    public int decodeASN(byte[] buf,
                         int offset,
                         AsnEncoder encoder)
                  throws AsnDecodingException

  Used to recover the encoded variable data 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. Once the data is decoded it is set in the current object.

  Specified by:
    `decodeASN` in interface `SnmpSyntax`
  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.
    `AsnDecodingException` - Thrown if an encoding error occurs

### duplicate

    public SnmpSyntax duplicate()

  Returns a newly created duplicate object to the caller

  Specified by:
    `duplicate` in interface `SnmpSyntax`
  Returns:
    A newly created variable

### clone

    public java.lang.Object clone()

  Returns a newly created duplicate object to the caller

  Returns:
    A newly created variable

### toString

    public java.lang.String toString()

  Converts the object to a string representation

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.