Methods Summary |
---|
public synchronized void | addInstance(java.lang.String inst)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.
int max= size();
for (int i = 0; i < max; i++) {
((SnmpVarBind)elementData[i]).addInstance(inst) ;
}
|
public final synchronized void | addVarBind(java.lang.String[] list, java.lang.String inst)Prepares a vector of SnmpVarBindList from an array of SNMP MIB variables and instances.
for (int i = 0; i < list.length; i++) {
SnmpVarBind avar = new SnmpVarBind(list[i]) ;
avar.addInstance(inst) ;
addElement(avar) ;
}
|
public synchronized void | addVarBind(java.lang.String[] list)Adds an array of MIB variable names to the list. For example:
String mylist[] = {"sysUpTime.0", "ifInOctets.0"}
vb.addVarBind(mylist) ;
addVarBind(list, null) ;
|
public synchronized void | addVarBind(java.lang.String name)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.
SnmpVarBind avar ;
avar = new SnmpVarBind(name) ;
addVarBind(avar) ;
|
public synchronized void | addVarBind(SnmpVarBind var)Appends the given SnmpVarBind object to the existing SnmpVarBindList .
It creates a new SnmpVarBindList if one did not exist.
addElement(var) ;
|
public synchronized void | addVarBindList(com.sun.jmx.snmp.SnmpVarBindList list)Appends an SnmpVarBindList at the end of the current SnmpVarBindList object.
ensureCapacity(list.size() + size()) ;
for (int i = 0; i < list.size(); i++) {
addElement(list.getVarBindAt(i)) ;
}
|
public synchronized boolean | checkForUnspecifiedValue()Returns true if there is a value that is not specified.
int max= this.size();
for (int i = 0; i < max ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
if (avar.isUnspecifiedValue())
return true ;
}
return false ;
|
public synchronized boolean | checkForValidValues()Returns false if any of the variables does not contain a valid value.
Typically used for SnmpSet operations.
int max= this.size();
for (int i = 0; i < max ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
if (avar.isValidValue() == false)
return false ;
}
return true ;
|
public synchronized java.lang.Object | clone()Clones the SnmpVarBindList . A new copy of the SnmpVarBindList is created.
It is a real deep copy.
return cloneWithValue() ;
|
public synchronized com.sun.jmx.snmp.SnmpVarBindList | cloneWithValue()Clones the SnmpVarBindList . A new copy of the SnmpVarBindList is created.
It is a real deep copy.
SnmpVarBindList newvb = new SnmpVarBindList() ;
newvb.setTimestamp(this.getTimestamp()) ;
newvb.ensureCapacity(this.size()) ;
for (int i = 0; i < this.size() ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
newvb.addElement(avar.clone()) ;
}
return newvb ;
|
public synchronized com.sun.jmx.snmp.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).
SnmpVarBindList newvb = new SnmpVarBindList() ;
int max = this.size();
newvb.ensureCapacity(max) ;
for (int i = 0; i < max ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
newvb.addElement(avar.cloneWithoutValue()) ;
}
return newvb ;
|
public final synchronized void | concat(java.util.Vector list)Adds elements in the specified SnmpVarBindList to this list.
The elements are not cloned.
ensureCapacity(size() + list.size()) ;
for (Enumeration e = list.elements() ; e.hasMoreElements() ; ) {
addElement(e.nextElement()) ;
}
|
public void | finalize()Finalizer of the SnmpVarBindList objects.
This method is called by the garbage collector on an object
when garbage collection determines that there are no more references to the object.
Removes all the elements from this SnmpVarBindList object.
removeAllElements() ;
|
public Timestamp | getTimestamp()Gets the timestamp associated with this SnmpVarBindList .
return timestamp ;
|
public final synchronized SnmpVarBind | getVarBindAt(int pos)Gets an SnmpVarBind object.
return (SnmpVarBind)(elementAt(pos)) ;
|
public synchronized int | getVarBindCount()Gets the number of elements in this list.
return size() ;
|
public synchronized java.util.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.
return elements() ;
|
public synchronized 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.
SnmpOid oidarg = var.getOid() ;
for (int i = min; i < max ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
if (oidarg.equals(avar.getOid()))
return i ;
}
return -1 ;
|
public synchronized int | indexOfOid(SnmpVarBind var)Gives the index of an OID in the SnmpVarBindList .
return indexOfOid(var, 0, size()) ;
|
public synchronized int | indexOfOid(SnmpOid oid)Gives the index of an OID in the SnmpVarBindList .
int max = size();
for (int i = 0; i < max ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
if (oid.equals(avar.getOid()))
return i ;
}
return -1 ;
|
public java.lang.String | oidListToString()Returns a String containing the ASCII representation of all OIDs in the list.
StringBuffer s = new StringBuffer(300) ;
for (int i = 0 ; i < elementCount ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
s.append(avar.getOid().toString() + "\n") ;
}
return s.toString() ;
|
public synchronized boolean | removeVarBind(java.lang.String[] list, java.lang.String inst)Removes the array of SNMP MIB variables and instances from the existing SnmpVarBindList .
boolean result = true;
for (int i = 0; i < list.length; i++) {
SnmpVarBind avar = new SnmpVarBind(list[i]) ;
avar.addInstance(inst) ;
int indexOid = indexOfOid(avar) ;
try {
removeElementAt(indexOid) ;
} catch (ArrayIndexOutOfBoundsException e) {
result = false ;
}
}
return result ;
|
public synchronized boolean | removeVarBind(java.lang.String[] list)Removes the array of SNMP MIB variables from the existing SnmpVarBindList .
return removeVarBind(list, null) ;
|
public synchronized boolean | removeVarBind(java.lang.String name)Removes the SnmpVarBind object corresponding to the given MIB variable from the existing
SnmpVarBindList .
SnmpVarBind avar ;
int indexOid ;
avar = new SnmpVarBind(name) ;
indexOid = indexOfOid(avar) ;
try {
removeElementAt(indexOid) ;
return true ;
} catch (ArrayIndexOutOfBoundsException e) {
return false ;
}
|
public synchronized boolean | removeVarBind(SnmpVarBind var)Removes the given SnmpVarBind object from the existing SnmpVarBindList .
return removeElement(var) ;
|
public synchronized boolean | removeVarBindList(com.sun.jmx.snmp.SnmpVarBindList list)Removes all the SnmpVarBind objects of the given SnmpVarBindList from the existing
SnmpVarBindList .
boolean result = true;
for (int i = 0; i < list.size(); i++) {
result = removeElement(list.getVarBindAt(i)) ;
}
return result;
|
public final synchronized void | replaceVarBind(SnmpVarBind var, int pos)Replaces an element at a specified location with the new element.
setElementAt(var, pos) ;
|
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.
timestamp = tstamp ;
|
public final synchronized void | setVarBindList(java.util.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.
setVarBindList(list, false) ;
|
public final synchronized void | setVarBindList(java.util.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.
synchronized (list) {
final int max = list.size();
setSize(max) ;
list.copyInto(this.elementData) ;
if (copy) { // do deepcopy of all vars.
for (int i = 0; i < max ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
elementData[i] = avar.clone() ;
}
}
}
|
public synchronized com.sun.jmx.snmp.SnmpVarBindList | splitAt(int pos)Splits the SnmpVarBindList .
SnmpVarBindList splitVb = null ;
if (pos > elementCount)
return splitVb ;
splitVb = new SnmpVarBindList() ; // size() - atPosition) ;
int max= size();
for (int i = pos; i < max ; i++)
splitVb.addElement(elementData[i]) ;
elementCount = pos ;
trimToSize() ;
return splitVb ;
|
public synchronized java.util.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.
final int count = elementCount;
if (copy == false) return (Vector) super.clone();
Vector result = new Vector(count,5);
for (int i = 0; i < count ; i++) {
SnmpVarBind avar = (SnmpVarBind)elementData[i] ;
result.addElement(avar.clone()) ;
}
return result;
|
public synchronized java.lang.String | varBindListToString()Constructs a String containing details of each SnmpVarBindList (oid+value).
This is typically used in debugging.
StringBuffer s = new StringBuffer(300) ;
for (int i = 0; i < elementCount ; i++) {
s.append(elementData[i].toString() + "\n") ;
}
return s.toString() ;
|