com.sun.management.snmp
Class SnmpVarBindList

java.lang.Object
  extended by java.util.AbstractCollection
      extended by java.util.AbstractList
          extended by java.util.Vector
              extended by com.sun.management.snmp.SnmpVarBindList
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class SnmpVarBindList
extends Vector

Contains a list of SnmpVarBind objects. This class helps to create an SnmpVarBindList from a list of MIB variable names. In addition, it contains different forms of methods which can copy or clone the list. This list is required by any SNMP entity which specifies a list of variables to query.

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
 String identity
          A name given to the 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(int initialCapacity)
          Prepares an empty list.
SnmpVarBindList(SnmpVarBindList list)
          Similar to the copy constructor.
SnmpVarBindList(String name)
          Prepares an empty list with a String to print while debugging.
SnmpVarBindList(String name, Vector list)
          Creates a new SnmpVarBindList object from a plain vector of SnmpVarBind objects.
SnmpVarBindList(Vector list)
          Creates a new SnmpVarBindList object from a plain vector of SnmpVarBind objects.
 
Method Summary
 void addInstance(String inst)
          Adds the string as an instance part to all OIDs in this list.
 void addVarBind(SnmpVarBind var)
          Appends the given SnmpVarBind object to the existing SnmpVarBindList.
 void addVarBind(String name)
          Creates an SnmpVarBind object from the given MIB variable and appends it to the existing SnmpVarBindList.
 void addVarBind(String[] list)
          Adds an array of MIB variable names to the list.
 void addVarBind(String[] list, String inst)
          Prepares a vector of SnmpVarBindList from an array of SNMP MIB variables and instances.
 void addVarBindList(SnmpVarBindList list)
          Appends an SnmpVarBindList at the end of the current SnmpVarBindList object.
 boolean checkForUnspecifiedValue()
          Returns true if there is a value that is not specified.
 boolean checkForValidValues()
          Returns false if any of the variables does not contain a valid value.
 Object clone()
          Clones the SnmpVarBindList.
 SnmpVarBindList cloneWithoutValue()
          Clones the SnmpVarBindList.
 SnmpVarBindList cloneWithValue()
          Clones the SnmpVarBindList.
 void concat(Vector list)
          Adds elements in the specified SnmpVarBindList to this list.
 Timestamp getTimestamp()
          Gets the timestamp associated with this SnmpVarBindList.
 SnmpVarBind getVarBindAt(int pos)
          Gets an SnmpVarBind object.
 int getVarBindCount()
          Gets the number of elements in this list.
 Enumeration getVarBindList()
          This is a convenience function that returns an enumeration.
 int indexOfOid(SnmpOid oid)
          Gives the index of an OID in the SnmpVarBindList.
 int indexOfOid(SnmpVarBind var)
          Gives the index of an OID in the SnmpVarBindList.
 int indexOfOid(SnmpVarBind var, int min, int max)
          Gives the index of an OID in the SnmpVarBindList.
 String oidListToString()
          Returns a String containing the ASCII representation of all OIDs in the list.
 boolean removeVarBind(SnmpVarBind var)
          Removes the given SnmpVarBind object from the existing SnmpVarBindList.
 boolean removeVarBind(String name)
          Removes the SnmpVarBind object corresponding to the given MIB variable from the existing SnmpVarBindList.
 boolean removeVarBind(String[] list)
          Removes the array of SNMP MIB variables from the existing SnmpVarBindList.
 boolean removeVarBind(String[] list, String inst)
          Removes the array of SNMP MIB variables and instances from the existing SnmpVarBindList.
 boolean removeVarBindList(SnmpVarBindList list)
          Removes all the SnmpVarBind objects of the given SnmpVarBindList from the existing SnmpVarBindList.
 void replaceVarBind(SnmpVarBind var, int pos)
          Replaces an element at a 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(Vector list)
          Replaces the current variable binding list of SnmpVarBind with the new specified variable binding list of SnmpVarBind objects.
 void setVarBindList(Vector list, boolean copy)
          Replaces the current variable binding list of SnmpVarBind objects with the new variable binding list of SnmpVarBind objects.
 SnmpVarBindList splitAt(int pos)
          Splits the SnmpVarBindList.
 Vector toVector(boolean copy)
          Copies the SnmpVarBindList into a plain vector of SnmpVarBind objects.
 String varBindListToString()
          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
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

identity

public String identity
A name given to the SnmpVarBindList. Useful for debugging. The default name is "VarBindList".

Constructor Detail

SnmpVarBindList

public SnmpVarBindList()
Prepares an empty list. The initial capacity and the capacity increment are initialized to 5.


SnmpVarBindList

public SnmpVarBindList(int initialCapacity)
Prepares an empty list.

Parameters:
initialCapacity - The initial capacity of the SnmpVarBindList.

SnmpVarBindList

public SnmpVarBindList(String name)
Prepares an empty list with a String to print while debugging.

Parameters:
name - The name of the newly created SnmpVarBindList.

SnmpVarBindList

public SnmpVarBindList(SnmpVarBindList list)
Similar to the copy constructor. Does a shallow copy of the elements. Individual elements are not cloned.

Parameters:
list - The SnmpVarBindList to copy.

SnmpVarBindList

public SnmpVarBindList(Vector list)
Creates a new SnmpVarBindList object from a plain vector of SnmpVarBind objects. Objects in the specified vector can be SnmpVarBind objects or derivatives.

Parameters:
list - The vector of SnmpVarBind objects to copy.

SnmpVarBindList

public SnmpVarBindList(String name,
                       Vector list)
Creates a new SnmpVarBindList object from a plain vector of SnmpVarBind objects. Objects in the specified vector can be SnmpVarBind objects or derivatives.

Parameters:
name - The name of the newly created SnmpVarBindList.
list - The vector of SnmpVarBind objects to copy.
Method Detail

getTimestamp

public Timestamp getTimestamp()
Gets the timestamp associated with this SnmpVarBindList.

Returns:
The timestamp.

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.

getVarBindAt

public final SnmpVarBind getVarBindAt(int pos)
Gets an SnmpVarBind object.

Parameters:
pos - The position in the list.
Returns:
The SnmpVarBind object at the specified position.
Throws:
ArrayIndexOutOfBoundsException - If the specified pos is beyond range.

getVarBindCount

public int getVarBindCount()
Gets the number of elements in this list.

Returns:
The number of elements in the list.

getVarBindList

public Enumeration getVarBindList()
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 SnmpVarBind objects.

setVarBindList

public final void setVarBindList(Vector list)
Replaces the current variable binding list of SnmpVarBind with the new specified variable binding list of SnmpVarBind objects. This method only clones the vector. It does not clone the SnmpVarBind objects contained in the list.

Parameters:
list - A vector of SnmpVarBind objects.

setVarBindList

public final void setVarBindList(Vector list,
                                 boolean copy)
Replaces the current variable binding list of SnmpVarBind objects with the new variable binding list of SnmpVarBind objects. If copy is true, it will clone each SnmpVarBind object contained in the list.

Parameters:
list - A vector of SnmpVarBind objects.
copy - The flag indicating whether each object in the list should be cloned.

addVarBindList

public void addVarBindList(SnmpVarBindList list)
Appends an SnmpVarBindList at the end of the current SnmpVarBindList object.

Parameters:
list - The SnmpVarBindList to append.

removeVarBindList

public boolean removeVarBindList(SnmpVarBindList list)
Removes all the SnmpVarBind objects of the given SnmpVarBindList from the existing SnmpVarBindList.

Parameters:
list - The SnmpVarBindList to be removed.
Returns:
true if all the SnmpVarBind objects were components of this SnmpVarBindList, false otherwise.

replaceVarBind

public final void replaceVarBind(SnmpVarBind var,
                                 int pos)
Replaces an element at a specified location with the new element.

Parameters:
var - The replacement variable.
pos - The location in the SnmpVarBindList.
Throws:
ArrayIndexOutOfBoundsException - If the specified pos is beyond range.

addVarBind

public final void addVarBind(String[] list,
                             String inst)
                      throws SnmpStatusException
Prepares a vector of SnmpVarBindList from an array of SNMP MIB variables and instances.

Parameters:
list - An array of String containing MIB variable names.
inst - A common instance for each of the MIB variables in vlist.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.

removeVarBind

public boolean removeVarBind(String[] list,
                             String inst)
                      throws SnmpStatusException
Removes the array of SNMP MIB variables and instances from the existing SnmpVarBindList.

Parameters:
list - An array of String containing MIB variable names.
inst - A common instance for each of the MIB variables 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.

addVarBind

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

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

Parameters:
list - The array of MIB variable names.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.

removeVarBind

public boolean removeVarBind(String[] list)
                      throws SnmpStatusException
Removes the array of SNMP MIB variables from the existing SnmpVarBindList.

Parameters:
list - Array of strings 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.

addVarBind

public void addVarBind(String name)
                throws SnmpStatusException
Creates an SnmpVarBind object from the given MIB variable and appends it to the existing SnmpVarBindList. It creates a new SnmpVarBindList if one did not exist.

Parameters:
name - A MIB variable name.
Throws:
SnmpStatusException - An error occurred while accessing a MIB node.

removeVarBind

public boolean removeVarBind(String name)
                      throws SnmpStatusException
Removes the SnmpVarBind object corresponding to the given MIB variable from the existing SnmpVarBindList.

Parameters:
name - 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.

addVarBind

public void addVarBind(SnmpVarBind var)
Appends the given SnmpVarBind object to the existing SnmpVarBindList. It creates a new SnmpVarBindList if one did not exist.

Parameters:
var - The SnmpVarBind object to be appended.

removeVarBind

public boolean removeVarBind(SnmpVarBind var)
Removes the given SnmpVarBind object from the existing SnmpVarBindList.

Parameters:
var - The SnmpVarBind object to be removed.
Returns:
true if the SnmpVarBind object was a component of this SnmpVarBindList, false otherwise.

addInstance

public void addInstance(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.

concat

public final void concat(Vector list)
Adds elements in the specified SnmpVarBindList to this list. The elements are not cloned.

Parameters:
list - A vector of SnmpVarBind.

checkForValidValues

public boolean checkForValidValues()
Returns false if any of the variables does not contain a valid value. Typically used for SnmpSet operations.

Returns:
false if any of the variables 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.

splitAt

public SnmpVarBindList splitAt(int pos)
Splits the SnmpVarBindList.

Parameters:
pos - The position at which to split the SnmpVarBindList
Returns:
The SnmpVarBindList list from the beginning up to the split position.

indexOfOid

public int indexOfOid(SnmpVarBind var,
                      int min,
                      int max)
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 the end parameter. Otherwise the method returns -1.

Parameters:
var - The SnmpVarBind object with the requested OID.
min - The min index in SnmpVarBindList.
max - The max index in SnmpVarBindList.
Returns:
The index of the OID in SnmpVarBindList.

indexOfOid

public int indexOfOid(SnmpVarBind var)
Gives the index of an OID in the SnmpVarBindList.

Parameters:
var - The SnmpVarBind object with the requested OID.
Returns:
The index of the OID in SnmpVarBindList.

indexOfOid

public int indexOfOid(SnmpOid oid)
Gives the index of an OID in the SnmpVarBindList.

Parameters:
oid - The SnmpOid object with the requested OID.
Returns:
The index of the OID in SnmpVarBindList.

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.

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 Object clone()
Clones the SnmpVarBindList. A new copy of the SnmpVarBindList is created. It is a real deep copy.

Overrides:
clone in class Vector
Returns:
The object clone.

toVector

public Vector toVector(boolean copy)
Copies the SnmpVarBindList into a plain vector of SnmpVarBind objects. If the copy flag is false, does a shallow copy of the list. Otherwise, individual elements will be cloned.

Parameters:
copy - The flag indicating whether each object in the list should be cloned.
Returns:
A new vector of SnmpVarBind objects.

oidListToString

public 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.

varBindListToString

public String varBindListToString()
Constructs a String containing details of each SnmpVarBindList (oid+value). This is typically used in debugging.

Returns:
A detailed String of all in the SnmpVarBindList.

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.