com.sun.jaw.snmp.manager
Class SnmpVarbindList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--com.sun.jaw.snmp.manager.SnmpVarbindList

public class SnmpVarbindList
extends java.util.Vector

SnmpVarbindList contains a list of SnmpVar objects. This class helps create a SnmpVarbindList from a list of MIB variable names. In addition it contains methods of different form which can copy or clone the list. This list is required by the SnmpSession which specifies a list of variables to query.

See Also:
SnmpVar, SnmpSession, Serialized Form

Field Summary
 java.lang.String identity
          A name given to SnmpVarbindList.
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SnmpVarbindList()
          Prepares an empty list.
SnmpVarbindList(SnmpVarbindList lst)
          Similar to the copy constructor.
SnmpVarbindList(java.lang.String s)
          Prepares an empty list with a string to print while debugging.
 
Method Summary
 void addInstance(java.lang.String inst)
          Adds the string as an instance part to all OIDs in this list.
 void addVarbindList(SnmpVarbindList vblst)
          Appends a SnmpVarbindList at the end of the current SnmpVarbindList object.
 void addVariable(SnmpVar vars)
          Appends the given SnmpVar object to the existing SnmpVarbindList.
 void addVariable(java.lang.String s)
          Creates an SnmpVar object from the given MIB variable and appends it to the existing SnmpVarbindList.
 void addVariable(java.lang.String[] vlist)
          Adds an array of MIB variable names to the list.
 void addVariable(java.lang.String[] vlist, java.lang.String inst)
          Prepares a Vector of SnmpVarbindList from an array of SNMP MIB variables and instances.
 boolean checkForUnspecifiedValue()
          Returns true if there is a value that is not specified.
 boolean checkForValidValues()
          Returns false if any of the variable does not contain a valid value.
 java.lang.Object clone()
          Clones the SnmpVarbindList.
 SnmpVarbindList cloneWithoutValue()
          Clones the SnmpVarbindList.
 SnmpVarbindList cloneWithValue()
          Clones the SnmpVarbindList.
 void concat(java.util.Vector list)
          Adds elements in the specified SnmpVarbindList to this list.
 void finalize()
          Removes all the elements from the SnmpVarbindList object.
 SnmpVar getSnmpVarAt(int pos)
          Gets an SnmpVar object.
 Timestamp getTimestamp()
          Gets the timestamp associated with this SnmpVarbindList.
 java.util.Enumeration getVarbindEnumeration()
          This is a convenience function that returns an enumeration.
 int getVariableCount()
          Gets the number of elements in this list.
 int indexOfOid(SnmpOid oidarg)
          Gives the index of an OID in the SnmpVarbindList.
 int indexOfOid(SnmpVar svar)
          Gives the index of an OID in the SnmpVarbindList.
 int indexOfOid(SnmpVar svar, int start, int end)
          Gives the index of an OID in the SnmpVarbindList.
 java.lang.String oidListToString()
          Returns a string containing the ASCII representation of all OIDs in the list.
 boolean removeVarbindList(SnmpVarbindList vblst)
          Removes all the SnmpVar objects of the given SnmpVarbindList from the existing SnmpVarbindList.
 boolean removeVariable(SnmpVar vars)
          Removes the given SnmpVar object from the existing SnmpVarbindList.
 boolean removeVariable(java.lang.String s)
          Removes the SnmpVar object corresponding to the given MIB variable from the existing SnmpVarbindList.
 boolean removeVariable(java.lang.String[] vlist)
          Removes the array of SNMP MIB variables from the existing SnmpVarbindList.
 boolean removeVariable(java.lang.String[] vlist, java.lang.String inst)
          Removes the array of SNMP MIB variables and instances from the existing SnmpVarbindList.
 void replaceVariable(SnmpVar newvar, int pos)
          Replaces an element at specified location with the new element.
 void setTimestamp(Timestamp tstamp)
          Records the sysUpTime and the actual time when this SnmpVarbindList was changed or created.
 void setVarbindList(java.util.Vector list)
          Replaces the current list of varbinds with the new varbind.
 void setVarbindList(java.util.Vector list, boolean copy)
          Replaces the current list of varbinds with the new varbind specified.
 SnmpVarbindList splitAt(int atPosition)
          Splits the SnmpVarbindList.
 java.lang.String vbListToString()
          Constructs a string containing details of each SnmpVarbindList (oid+value).
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

identity

public java.lang.String identity
A name given to SnmpVarbindList. Useful for debugging. The default name is "VarbindList".
Constructor Detail

SnmpVarbindList

public SnmpVarbindList()
Prepares an empty list.

SnmpVarbindList

public SnmpVarbindList(java.lang.String s)
Prepares an empty list with a string to print while debugging.
Parameters:
s - The name of the new created SnmpVarbindList.

SnmpVarbindList

public SnmpVarbindList(SnmpVarbindList lst)
Similar to the copy constructor. Does a shallow copy of the elements. Individual elements are not cloned.
Parameters:
lst - The SnmpVarbindList to copy.
Method Detail

setTimestamp

public void setTimestamp(Timestamp tstamp)
Records the sysUpTime and the actual time when this SnmpVarbindList was changed or created. This needs to be set explicitly.
Parameters:
tstamp - The SnmpTimestamp of the device for which the values hold true.

getTimestamp

public Timestamp getTimestamp()
Gets the timestamp associated with this SnmpVarbindList.
Returns:
The timestamp.

getSnmpVarAt

public final SnmpVar getSnmpVarAt(int pos)
Gets an SnmpVar object.
Parameters:
pos - The position in list.
Returns:
The SnmpVar object at the specified position.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the pos is beyond range.

getVariableCount

public int getVariableCount()
Gets the number of elements in this list.
Returns:
The number of elements in the list.

getVarbindEnumeration

public java.util.Enumeration getVarbindEnumeration()
This is a convenience function that returns an enumeration. This can be used to traverse the list. This is advantageous as it hides the implementation of the class of the list which keeps the variables.
Returns:
An enumeration object of the SnmpVarbindList.
See Also:
Enumeration

oidListToString

public java.lang.String oidListToString()
Returns a string containing the ASCII representation of all OIDs in the list.
Returns:
An ASCII list of all OIDs in this list.

vbListToString

public java.lang.String vbListToString()
Constructs a string containing details of each SnmpVarbindList (oid+value). This is used typically in debugging.
Returns:
A detailed string of all in the SnmpVarbindList.

setVarbindList

public final void setVarbindList(java.util.Vector list)
Replaces the current list of varbinds with the new varbind. This method only clones the vector. It does not clone the SnmpVar object contained in the list.
Parameters:
list - A vector of SnmpVar.
See Also:
SnmpVar, SnmpSession

concat

public final void concat(java.util.Vector list)
Adds elements in the specified SnmpVarbindList to this list. The elements are not cloned.
Parameters:
list - A vector of SnmpVar.

setVarbindList

public final void setVarbindList(java.util.Vector list,
                                 boolean copy)
Replaces the current list of varbinds with the new varbind specified. If copy is true, it will clone each SnmpVar object contained in the list.
Parameters:
list - A vector of SnmpVar.
copy - The flag indicating whether each object in the list should be cloned.
See Also:
SnmpVar, SnmpSession

replaceVariable

public final void replaceVariable(SnmpVar newvar,
                                  int pos)
Replaces an element at specified location with the new element.
Parameters:
newvar - The replacement variable.
pos - The location in the SnmpVarbindList.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the pos is beyond range.

addVariable

public final void addVariable(java.lang.String[] vlist,
                              java.lang.String inst)
                       throws SnmpStatusException
Prepares a Vector of SnmpVarbindList from an array of SNMP MIB variables and instances. It does not affect the session at all (to be moved to a different class).
Parameters:
vlist - An array of String containing MIB variable names.
inst - A common instance for each of the MIB variable in vlist.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.
See Also:
SnmpVar

removeVariable

public boolean removeVariable(java.lang.String[] vlist,
                              java.lang.String inst)
                       throws SnmpStatusException
Removes the array of SNMP MIB variables and instances from the existing SnmpVarbindList.
Parameters:
vlist - An array of String containing MIB variable names.
inst - A common instance for each of the MIB variable in vlist.
Returns:
True if all the SNMP MIB variables were components of this SnmpVarbindList; false otherwise.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.
Since:
JDMK 3.2
See Also:
SnmpVar

addVariable

public void addVariable(java.lang.String[] vlist)
                 throws SnmpStatusException
Adds an array of MIB variable names to the list. For example:

String mylist[] = {"sysUpTime.0", "ifInOctets.0"}
vb.addVariable(mylist) ;

Parameters:
vlist - The array of MIB variables names.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.
See Also:
SnmpVar

removeVariable

public boolean removeVariable(java.lang.String[] vlist)
                       throws SnmpStatusException
Removes the array of SNMP MIB variables from the existing SnmpVarbindList.
Parameters:
vlist - Array of String containing MIB variable names.
Returns:
True if all the SNMP MIB variables were components of this SnmpVarbindList; false otherwise.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.
Since:
JDMK 3.2
See Also:
SnmpVar

addVariable

public void addVariable(SnmpVar vars)
Appends the given SnmpVar object to the existing SnmpVarbindList. It creates a new SnmpVarbindList if it did not exist.
Parameters:
vars - The SnmpVar object to be appended.
See Also:
SnmpVar

removeVariable

public boolean removeVariable(SnmpVar vars)
Removes the given SnmpVar object from the existing SnmpVarbindList.
Parameters:
vars - The SnmpVar object to be removed.
Returns:
True if the SnmpVar object was a component of this SnmpVarbindList; false otherwise.
Since:
JDMK 3.2
See Also:
SnmpVar

addVariable

public void addVariable(java.lang.String s)
                 throws SnmpStatusException
Creates an SnmpVar object from the given MIB variable and appends it to the existing SnmpVarbindList. It creates a new SnmpVarbindList if it did not exist.
Parameters:
s - A MIB variable name.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.
See Also:
SnmpVar

removeVariable

public boolean removeVariable(java.lang.String s)
                       throws SnmpStatusException
Removes the SnmpVar object corresponding to the given MIB variable from the existing SnmpVarbindList.
Parameters:
s - A MIB variable name.
Returns:
True if the SNMP MIB variable was a component of this SnmpVarbindList; false otherwise.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.
Since:
JDMK 3.2
See Also:
SnmpVar

addInstance

public void addInstance(java.lang.String inst)
                 throws SnmpStatusException
Adds the string as an instance part to all OIDs in this list. This method should be used with caution because it affects all OIDs in the list.
Parameters:
inst - The string to add as an instance part.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.

splitAt

public SnmpVarbindList splitAt(int atPosition)
Splits the SnmpVarbindList.
Parameters:
atposition - The position to split the SnmpVarbindList
Returns:
The SnmpVarbindList list from the beginning up to the split position.

indexOfOid

public int indexOfOid(SnmpVar svar,
                      int start,
                      int end)
Gives the index of an OID in the SnmpVarbindList. The index returned must be greater than or equal to the start parameter and smaller than end parameter. Otherwise the method returns -1.
Parameters:
svar - The SnmpVar object with the requested OID.
start - The min index in SnmpVarbindList.
end - The max index in SnmpVarbindList.
Returns:
The index of the OID in SnmpVarbindList.

indexOfOid

public int indexOfOid(SnmpVar svar)
Gives the index of an OID in the SnmpVarbindList.
Parameters:
svar - The SnmpVar object with the requested OID.
Returns:
The index of the OID in SnmpVarbindList.

indexOfOid

public int indexOfOid(SnmpOid oidarg)
Gives the index of an OID in the SnmpVarbindList.
Parameters:
oidarg - The SnmpOid object with the requested OID.
Returns:
The index of the OID in SnmpVarbindList.

checkForValidValues

public boolean checkForValidValues()
Returns false if any of the variable does not contain a valid value. Typically, used for SnmpSet operations.
Returns:
False if any of the variable does not contain a valid value; true otherwise.

checkForUnspecifiedValue

public boolean checkForUnspecifiedValue()
Returns true if there is a value that is not specified.
Returns:
True if there is a value that is not specified; false otherwise.

addVarbindList

public void addVarbindList(SnmpVarbindList vblst)
Appends a SnmpVarbindList at the end of the current SnmpVarbindList object.
Parameters:
vblst - The SnmpVarbindList to append.

removeVarbindList

public boolean removeVarbindList(SnmpVarbindList vblst)
Removes all the SnmpVar objects of the given SnmpVarbindList from the existing SnmpVarbindList.
Parameters:
vblst - The SnmpVarbindList to be removed.
Returns:
True if all the SnmpVar objects were components of this SnmpVarbindList; false otherwise.
Since:
JDMK 3.2
See Also:
SnmpVar

finalize

public void finalize()
Removes all the elements from the SnmpVarbindList object.
Overrides:
finalize in class java.lang.Object

cloneWithoutValue

public SnmpVarbindList cloneWithoutValue()
Clones the SnmpVarbindList. It does not clone the value part of the variable. It is a deep copy (except for the value portion).
Returns:
The SnmpVarbindList clone.

clone

public java.lang.Object clone()
Clones the SnmpVarbindList. A new copy of the SnmpVarbindList is created. It is a real deep copy.
Returns:
The Object clone.
Overrides:
clone in class java.util.Vector

cloneWithValue

public SnmpVarbindList cloneWithValue()
Clones the SnmpVarbindList. A new copy of the SnmpVarbindList is created. It is a real deep copy.
Returns:
The SnmpVarbindList clone.