com.sun.management.snmp
Class SnmpVarBind

java.lang.Object
  extended by com.sun.management.snmp.SnmpVarBind
All Implemented Interfaces:
SnmpDataTypeEnums, Serializable, Cloneable

public class SnmpVarBind
extends Object
implements SnmpDataTypeEnums, Cloneable, Serializable

This class holds information for a MIB variable contained in an SnmpVarBindList. An SnmpVarBind consists of three parts:

- The corresponding OID object for the MIB variable.
- The value part associated with that OID instance. If present, it determines the MIB syntax for the object.
- The status of the SnmpVarBind which specifies whether the agent responded with an exception condition for this variable such as noSuchInstance, endOfMibView, or noSuchObject. On the manager side, these errors can be fixed with the PduFixedOnError option and the request is retried by removing the variable from the request variable bindings list.

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
static SnmpNull endOfMibView
          Error code value as defined in RFC 1448 for: endOfMibView.
static SnmpNull noSuchInstance
          Error code value as defined in RFC 1448 for: noSuchInstance.
static SnmpNull noSuchObject
          Error code value as defined in RFC 1448 for: noSuchObject.
 int status
          Indicates the status of the value in this SnmpVarBind.
static String[] statusLegend
          Keeps the legend for the value part of the SnmpVarBind.
static int stValueEndOfMibView
          Useful constant indicating that the status of the SnmpVarBind object is endOfMibView.
static int stValueNoSuchInstance
          Useful constant indicating that the status of the SnmpVarBind object is noSuchInstance.
static int stValueNoSuchObject
          Useful constant indicating that the status of the SnmpVarBind object is noSuchObject.
static int stValueOk
          Useful constant indicating that the status of the SnmpVarBind object is valid.
static int stValueUnspecified
          Useful constant indicating that the status of the SnmpVarBind object is not initialized.
 
Fields inherited from interface com.sun.management.snmp.SnmpDataTypeEnums
ApplFlag, BitStringTag, BooleanTag, Counter64Tag, CounterTag, CtxtFlag, errEndOfMibViewTag, errNoSuchInstanceTag, errNoSuchObjectTag, GaugeTag, IntegerTag, IpAddressTag, NsapTag, NullTag, ObjectIdentiferTag, ObjectIdentifierTag, OctetStringTag, OpaqueTag, SequenceTag, TableTag, TimeticksTag, UintegerTag, UnknownSyntaxTag
 
Constructor Summary
SnmpVarBind()
          Default constructor.
SnmpVarBind(SnmpOid oid)
          Constructs a new SnmpVarBind object from the specified SnmpOid value.
SnmpVarBind(SnmpOid oid, SnmpValue val)
          Constructs a new SnmpVarBind object from the specified SnmpOid and SnmpValue.
SnmpVarBind(String name)
          Constructs a new SnmpVarBind object from the specified String value.
 
Method Summary
 void addInstance(long inst)
          Adds an instance part to the OID in the SnmpOid object.
 void addInstance(long[] inst)
          Adds an instance part to the OID in the SnmpOid object.
 void addInstance(String inst)
          Adds an instance part to the OID in the SnmpOid object.
 void appendInOid(SnmpOid oid)
          Appends the specified SnmpOid to the end of the OID of this SnmpVarBind.
 void clearValue()
          Clears the value associated with this SnmpVarBind and sets the status to stValueUnspecified.
 Object clone()
          Clones the SNMP variable (including value).
 Object cloneWithoutValue()
          Clones the SNMP variable.
 void copyValue(SnmpVarBind var)
          Clones and copies only the value part from another SnmpVarBind object.
 void copyValueAndOid(SnmpVarBind var)
          Clones and copies the OID and value part from another SnmpVarBind object.
 SnmpOid getOid()
          Returns the complete OID part associated with this SnmpVarBind.
 SnmpCounter64 getSnmpCounter64Value()
          Returns the value part associated with this SnmpVarBind.
 SnmpCounter getSnmpCounterValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpGauge getSnmpGaugeValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpInt getSnmpIntValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpIpAddress getSnmpIpAddressValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpOid getSnmpOidValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpOpaque getSnmpOpaqueValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpStringFixed getSnmpStringFixedValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpString getSnmpStringValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpTimeticks getSnmpTimeticksValue()
          Returns the value part associated with this SnmpVarBind.
 SnmpValue getSnmpValue()
          Returns the value part associated with this SnmpVarBind.
 String getStringValue()
          Returns the printable ASCII representation for the corresponding variable value.
 int getValueStatus()
          Returns the status of the value associated with this SnmpVarBind as an integer.
 String getValueStatusLegend()
          Returns the status of the value associated with this SnmpVarBind as a String.
 boolean hasVarBindException()
          Determines whether the SnmpVarBind has an SNMP exception (generated by agent in response to a request).
 void insertInOid(int oid)
          Inserts a sub-id at the beginning of the OID of this SnmpVarBind.
 boolean isOidEqual(SnmpVarBind var)
          Checks whether the OID for this variable completely matches the OID part of the specified SnmpVarBind object.
 boolean isUnspecifiedValue()
          Checks whether the value associated with this SnmpVarBind is unspecified.
 boolean isValidValue()
          Checks whether the object contains a valid accessible value.
 SnmpOidRecord resolveVarName(String name)
          Consults the MIB table storage to resolve the name to its OID type structure.
 void setEndOfMibView()
          Set the value to endOfMibView.
 void setNoSuchInstance()
          Set the value to noSuchInstance.
 void setNoSuchObject()
          Set the value to noSuchObject.
 void setOid(SnmpOid oid)
          Sets the SnmpOid part associated with this SnmpVarBind with the specified OID.
 void setOid(SnmpOid oid, boolean clearValue)
          Sets the SnmpOid part associated with this SnmpVarBind with the specified OID.
 void setSnmpCounter64Value(long val)
          Sets the SnmpCounter64 value part associated with this SnmpVarBind with the specified counter 64 value.
 void setSnmpCounter64Value(UnsignedLong val)
          Sets the SnmpCounter64 value part associated with this SnmpVarBind with the specified counter 64 value.
 void setSnmpCounterValue(long val)
          Sets the SnmpCounter value part associated with this SnmpVarBind with the specified counter value.
 void setSnmpGaugeValue(long val)
          Sets the SnmpGauge value part associated with this SnmpVarBind with the specified gauge value.
 void setSnmpIntValue(long val)
          Sets the SnmpInt value part associated with this SnmpVarBind with the specified integer value.
 void setSnmpIpAddressValue(String val)
          Sets the SnmpIpAddress value part associated with this SnmpVarBind with the specified ipAddress value.
 void setSnmpOidValue(String val)
          Sets the SnmpOid value part associated with this SnmpVarBind with the specified OID value.
 void setSnmpOpaqueValue(byte[] val)
          Sets the SnmpOpaque value part associated with this SnmpVarBind with the specified bytes array values.
 void setSnmpStringFixedValue(String val)
          Sets the SnmpStringFixed value part associated with this SnmpVarBind with the specified string value.
 void setSnmpStringValue(String val)
          Sets the SnmpString value part associated with this SnmpVarBind with the specified string value.
 void setSnmpTimeticksValue(long val)
          Sets the SnmpTimeticks value part associated with this SnmpVarBind with the specified timeticks value.
 void setSnmpValue(SnmpValue val)
          Sets the SnmpValue part associated with this SnmpVarBind with the specified value.
 String toString()
          Returns the printable ASCII representation of this SnmpVarBind.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

statusLegend

public static final String[] statusLegend
Keeps the legend for the value part of the SnmpVarBind.


stValueUnspecified

public static final int stValueUnspecified
Useful constant indicating that the status of the SnmpVarBind object is not initialized.

See Also:
Constant Field Values

stValueOk

public static final int stValueOk
Useful constant indicating that the status of the SnmpVarBind object is valid.

See Also:
Constant Field Values

stValueNoSuchObject

public static final int stValueNoSuchObject
Useful constant indicating that the status of the SnmpVarBind object is noSuchObject. Status of SnmpVarBind as returned by the SNMPv2 agent.

See Also:
Constant Field Values

stValueNoSuchInstance

public static final int stValueNoSuchInstance
Useful constant indicating that the status of the SnmpVarBind object is noSuchInstance. Status of SnmpVarBind as returned by the SNMPv2 agent. In the SNMPv1 context, this is appropriate when noSuchName is returned in response to the SnmpGet request.

See Also:
Constant Field Values

stValueEndOfMibView

public static final int stValueEndOfMibView
Useful constant indicating that the status of the SnmpVarBind object is endOfMibView. Status of SnmpVarBind as returned by the SNMPv2 agent. In the SNMPv1 context, this is appropriate when noSuchName is returned in response to the SnmpGetNext request.

See Also:
Constant Field Values

noSuchObject

public static final SnmpNull noSuchObject
Error code value as defined in RFC 1448 for: noSuchObject.


noSuchInstance

public static final SnmpNull noSuchInstance
Error code value as defined in RFC 1448 for: noSuchInstance.


endOfMibView

public static final SnmpNull endOfMibView
Error code value as defined in RFC 1448 for: endOfMibView.


status

public int status
Indicates the status of the value in this SnmpVarBind. The default value is stValueUnspecified. This attribute is updated internally and should not be changed otherwise.

Constructor Detail

SnmpVarBind

public SnmpVarBind()
Default constructor.


SnmpVarBind

public SnmpVarBind(SnmpOid oid)
Constructs a new SnmpVarBind object from the specified SnmpOid value.

Parameters:
oid - The OID part of the SnmpVarBind.

SnmpVarBind

public SnmpVarBind(SnmpOid oid,
                   SnmpValue val)
Constructs a new SnmpVarBind object from the specified SnmpOid and SnmpValue.

Parameters:
oid - The OID part of the SnmpVarBind.
val - The value part of the SnmpVarBind.

SnmpVarBind

public SnmpVarBind(String name)
            throws SnmpStatusException
Constructs a new SnmpVarBind object from the specified String value. If the name is a MIB variable, it resolves the name with the MIB database.

Parameters:
name - The MIB variable name or a dot-formatted OID String.
Throws:
SnmpStatusException - An error occurred while resolving the MIB variable name.
Method Detail

getOid

public final SnmpOid getOid()
Returns the complete OID part associated with this SnmpVarBind.

Returns:
The SnmpOid for this variable.

setOid

public final void setOid(SnmpOid oid)
Sets the SnmpOid part associated with this SnmpVarBind with the specified OID. The value part of this SnmpVarBind will automatically be nulled.

Parameters:
oid - The new OID.

setOid

public final void setOid(SnmpOid oid,
                         boolean clearValue)
Sets the SnmpOid part associated with this SnmpVarBind with the specified OID.

Parameters:
oid - The new OID.
clearValue - If true the value part of this SnmpVarBind will be nulled.

getSnmpValue

public final SnmpValue getSnmpValue()
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpValue for this variable.

setSnmpValue

public final void setSnmpValue(SnmpValue val)
Sets the SnmpValue part associated with this SnmpVarBind with the specified value. The status is updated to indicate that the value is valid.

Parameters:
val - The new value.

getSnmpCounter64Value

public final SnmpCounter64 getSnmpCounter64Value()
                                          throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpCounter64 value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpCounter64Value

public final void setSnmpCounter64Value(long val)
                                 throws IllegalArgumentException
Sets the SnmpCounter64 value part associated with this SnmpVarBind with the specified counter 64 value. The status is updated to indicate that the value is valid.

Parameters:
val - The new counter 64 value.
Throws:
IllegalArgumentException - The specified value is negative or larger than Long.MAX_VALUE.
See Also:
SnmpCounter64

setSnmpCounter64Value

public final void setSnmpCounter64Value(UnsignedLong val)
                                 throws IllegalArgumentException
Sets the SnmpCounter64 value part associated with this SnmpVarBind with the specified counter 64 value. The status is updated to indicate that the value is valid.

Parameters:
val - The new counter 64 value.
Throws:
IllegalArgumentException - The specified value is larger than Long.MAX_VALUE.
See Also:
SnmpCounter64

getSnmpIntValue

public final SnmpInt getSnmpIntValue()
                              throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpInt value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpIntValue

public final void setSnmpIntValue(long val)
                           throws IllegalArgumentException
Sets the SnmpInt value part associated with this SnmpVarBind with the specified integer value. The status is updated to indicate that the value is valid.

Parameters:
val - The new integer value.
Throws:
IllegalArgumentException - The specified value is smaller than Integer.MIN_VALUE or larger than Integer.MAX_VALUE.
See Also:
SnmpInt

getSnmpCounterValue

public final SnmpCounter getSnmpCounterValue()
                                      throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpCounter value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpCounterValue

public final void setSnmpCounterValue(long val)
                               throws IllegalArgumentException
Sets the SnmpCounter value part associated with this SnmpVarBind with the specified counter value. The status is updated to indicate that the value is valid.

Parameters:
val - The new counter value.
Throws:
IllegalArgumentException - The specified value is negative or larger than SnmpUnsignedInt.MAX_VALUE.
See Also:
SnmpCounter

getSnmpGaugeValue

public final SnmpGauge getSnmpGaugeValue()
                                  throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpGauge value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpGaugeValue

public final void setSnmpGaugeValue(long val)
                             throws IllegalArgumentException
Sets the SnmpGauge value part associated with this SnmpVarBind with the specified gauge value. The status is updated to indicate that the value is valid.

Parameters:
val - The new gauge value.
Throws:
IllegalArgumentException - The specified value is negative or larger than SnmpUnsignedInt.MAX_VALUE.
See Also:
SnmpGauge

getSnmpTimeticksValue

public final SnmpTimeticks getSnmpTimeticksValue()
                                          throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpTimeticks value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpTimeticksValue

public final void setSnmpTimeticksValue(long val)
                                 throws IllegalArgumentException
Sets the SnmpTimeticks value part associated with this SnmpVarBind with the specified timeticks value. The status is updated to indicate that the value is valid.

Parameters:
val - The new timeticks value.
Throws:
IllegalArgumentException - The specified value is negative or larger than SnmpUnsignedInt.MAX_VALUE.
See Also:
SnmpTimeticks

getSnmpOidValue

public final SnmpOid getSnmpOidValue()
                              throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpOid value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpOidValue

public final void setSnmpOidValue(String val)
                           throws IllegalArgumentException
Sets the SnmpOid value part associated with this SnmpVarBind with the specified OID value. The status is updated to indicate that the value is valid.

Parameters:
val - The new OID value.
Throws:
IllegalArgumentException - The specified value is neither a numeric String nor a String of the MIB database.
See Also:
SnmpOid

getSnmpIpAddressValue

public final SnmpIpAddress getSnmpIpAddressValue()
                                          throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpIpAddress value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpIpAddressValue

public final void setSnmpIpAddressValue(String val)
                                 throws IllegalArgumentException
Sets the SnmpIpAddress value part associated with this SnmpVarBind with the specified ipAddress value. The status is updated to indicate that the value is valid.

Parameters:
val - The new IP address value.
Throws:
IllegalArgumentException - The specified value does not correspond to an IP address.
See Also:
SnmpIpAddress

getSnmpStringValue

public final SnmpString getSnmpStringValue()
                                    throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpString value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpStringValue

public final void setSnmpStringValue(String val)
Sets the SnmpString value part associated with this SnmpVarBind with the specified string value. The status is updated to indicate that the value is valid.

Parameters:
val - The new string value.
See Also:
SnmpString

getSnmpOpaqueValue

public final SnmpOpaque getSnmpOpaqueValue()
                                    throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpOpaque value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpOpaqueValue

public final void setSnmpOpaqueValue(byte[] val)
Sets the SnmpOpaque value part associated with this SnmpVarBind with the specified bytes array values. The status is updated to indicate that the value is valid.

Parameters:
val - The new bytes array value.
See Also:
SnmpOpaque

getSnmpStringFixedValue

public final SnmpStringFixed getSnmpStringFixedValue()
                                              throws ClassCastException
Returns the value part associated with this SnmpVarBind.

Returns:
The SnmpStringFixed value for this variable.
Throws:
ClassCastException - An attempt has been made to cast an object to a subclass of which it is not an instance.

setSnmpStringFixedValue

public final void setSnmpStringFixedValue(String val)
Sets the SnmpStringFixed value part associated with this SnmpVarBind with the specified string value. The status is updated to indicate that the value is valid.

Parameters:
val - The new string value.
See Also:
SnmpStringFixed

resolveVarName

public SnmpOidRecord resolveVarName(String name)
                             throws SnmpStatusException
Consults the MIB table storage to resolve the name to its OID type structure.

Parameters:
name - The MIB variable name or a dot-formatted OID String.
Returns:
The SnmpOidRecord object containing information on the MIB variable.
Throws:
SnmpStatusException - An error occurred while resolving the MIB variable name.

getValueStatus

public final int getValueStatus()
Returns the status of the value associated with this SnmpVarBind as an integer. This value is one of stValueUnspecified, stValueOk, stValueNoSuchObject, stValueNoSuchInstance, stValueEndOfMibView.

Returns:
The status of the associated value.

getValueStatusLegend

public final String getValueStatusLegend()
Returns the status of the value associated with this SnmpVarBind as a String. This value is a displayable representation of the status integer value. It is one of Value not initialized, Valid Value, No such object, No such Instance, End of Mib View.

Returns:
The status of the associated value.

isValidValue

public final boolean isValidValue()
Checks whether the object contains a valid accessible value.

Returns:
true if the associated value is valid, false otherwise.

isUnspecifiedValue

public final boolean isUnspecifiedValue()
Checks whether the value associated with this SnmpVarBind is unspecified.

Returns:
true if the status is unspecified, false otherwise.

clearValue

public final void clearValue()
Clears the value associated with this SnmpVarBind and sets the status to stValueUnspecified.


isOidEqual

public final boolean isOidEqual(SnmpVarBind var)
Checks whether the OID for this variable completely matches the OID part of the specified SnmpVarBind object.

Parameters:
var - The object whose OID part is to be matched.
Returns:
true if the OID part matches exactly, false otherwise.

addInstance

public final void addInstance(long inst)
Adds an instance part to the OID in the SnmpOid object. Note that there is no getInstance method. This method will directly add the instance to the SnmpOid object.

Parameters:
inst - The sub-identifier to be appended to the OID.

addInstance

public final void addInstance(long[] inst)
                       throws SnmpStatusException
Adds an instance part to the OID in the SnmpOid object. Note that there is no getInstance method. This method will directly add the instance to the SnmpOid object.

Parameters:
inst - The sub-identifier array to be appended to the OID.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.

addInstance

public final void addInstance(String inst)
                       throws SnmpStatusException
Adds an instance part to the OID in the SnmpOid object. Note that there is no getInstance method. This method will directly add the instance to the SnmpOid object.

Parameters:
inst - Dot-formatted sub-identifier String to be appended to the OID.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.

insertInOid

public void insertInOid(int oid)
Inserts a sub-id at the beginning of the OID of this SnmpVarBind.

Parameters:
oid - The sub-id to insert.

appendInOid

public void appendInOid(SnmpOid oid)
Appends the specified SnmpOid to the end of the OID of this SnmpVarBind.

Parameters:
oid - The OID to append.

hasVarBindException

public final boolean hasVarBindException()
Determines whether the SnmpVarBind has an SNMP exception (generated by agent in response to a request).

Returns:
true if the SnmpVarBind has an SNMP response exception, false otherwise.

copyValueAndOid

public void copyValueAndOid(SnmpVarBind var)
Clones and copies the OID and value part from another SnmpVarBind object.

Parameters:
var - The SnmpVarBind clone.

copyValue

public void copyValue(SnmpVarBind var)
Clones and copies only the value part from another SnmpVarBind object.

Parameters:
var - The SnmpVarBind clone.

cloneWithoutValue

public Object cloneWithoutValue()
Clones the SNMP variable. It does not clone the value portion.

Returns:
A new object with the value part set to null.

clone

public Object clone()
Clones the SNMP variable (including value).

Overrides:
clone in class Object
Returns:
The SNMP variable clone.

getStringValue

public final String getStringValue()
Returns the printable ASCII representation for the corresponding variable value.

Returns:
The printable ASCII representation.

setNoSuchObject

public final void setNoSuchObject()
Set the value to noSuchObject. This is equivalent to setSnmpValue(SnmpVarBind.noSuchObject).


setNoSuchInstance

public final void setNoSuchInstance()
Set the value to noSuchInstance. This is equivalent to setSnmpValue(SnmpVarBind.noSuchInstance).


setEndOfMibView

public final void setEndOfMibView()
Set the value to endOfMibView. This is equivalent to setSnmpValue(SnmpVarBind.endOfMibView).


toString

public final String toString()
Returns the printable ASCII representation of this SnmpVarBind.

Overrides:
toString in class Object
Returns:
The printable ASCII representation.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.