com.tivoli.twg.snmputils
Class VariableBinding

java.lang.Object
  extended bycom.tivoli.twg.snmputils.VariableBinding
Direct Known Subclasses:
Counter64Vbl, CounterVbl, EmptyVbl, GaugeVbl, IntegerVbl, IpAddressVbl, NsapVbl, OidVbl, OpaqueVbl, StringVbl, TimeticksVbl, UnsignedVbl

public abstract class VariableBinding
extends java.lang.Object

I am an abstract class for handling variable bindings within an SNMP PDU.


Field Summary
protected  java.lang.String oid
          This holds an OID describing this particular variable binding.
 
Constructor Summary
VariableBinding()
           
 
Method Summary
abstract  void addToPdu(SNMPPDU pdu)
          This inserts the variable binding into the SNMPPDU.
static int getMIBType()
          This gets the MIB type for a particular kind of variable binding.
 java.lang.String getOid()
          This returns the OID associated with the variable binding.
static int getType()
          This gets the SNMPPDU type for a particular kind of variable binding.
abstract  java.lang.Object getValueAsObject()
          Returns the value for this variable binding as an Object
 void setOid(java.lang.String oid)
          This sets the OID associated with the variable binding.
 int size()
          This method returns the size of the variable binding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oid

protected java.lang.String oid
This holds an OID describing this particular variable binding.

Constructor Detail

VariableBinding

public VariableBinding()
Method Detail

getOid

public java.lang.String getOid()
This returns the OID associated with the variable binding. OIDs (Object IDentifiers) describe the specific variable binding so an agent may know how to translate it, and for what the PDU exists.

Returns:
a string representing the OID

setOid

public void setOid(java.lang.String oid)
This sets the OID associated with the variable binding. OIDs (Object IDentifiers) describe the specific variable binding so an agent may know how to translate it, and for what the PDU exists.

Parameters:
oid - a string representing the OID

getType

public static int getType()
This gets the SNMPPDU type for a particular kind of variable binding. This should be a class method rather than an instance method (hence, 'static').

Returns:

getMIBType

public static int getMIBType()
This gets the MIB type for a particular kind of variable binding. This should be a class method rather than an instance method (hence, 'static').

Returns:

getValueAsObject

public abstract java.lang.Object getValueAsObject()
Returns the value for this variable binding as an Object

Returns:
variable binding value as an Object

addToPdu

public abstract void addToPdu(SNMPPDU pdu)
This inserts the variable binding into the SNMPPDU. It's an abstract method, so it needs to be overridden by child classes. Basically, all one needs to add is a simple "pdu.AddVblItem(0,getOid(),getType(),[data item]);" statement.

Parameters:
pdu -

size

public int size()
This method returns the size of the variable binding. This method is useful for determining how large your PDU is about to become before it gets out of hand. It should be overridden thusly:

return super.size() + [your calculations here]
This particular method approximates the size of the OID within the PDU (it counts periods and multiplies by two). This would usually result in a value that's slightly higher than reality. This tact was chosen for it's speed, not accuracy. It is, however, conservative... better to presume a value slightly higher instead of something lower.
This method may be significantly enhanced if a real OID object were created and used throughout the system.

Returns:
An int representing the size of the variable binding in terms of the PDU.