/*
* @(#)file SnmpIndex.java
* @(#)author Sun Microsystems, Inc.
* @(#)version 4.8
* @(#)date 06/05/03
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*/
package com.sun.jmx.snmp.agent;
// java imports
//
import java.io.Serializable;
import java.util.Vector;
import java.util.Enumeration;
// jmx imports
//
import com.sun.jmx.snmp.SnmpOid;
/**
* Represents a SNMP index.
* An SnmpIndex
is represented as a Vector
of SnmpOid
.
*
* This class is used internally and by the classes generated by mibgen
.
* You should not need to use this class directly.
*
*
This API is a Sun Microsystems internal API and is subject * to change without notice.
* @version 4.8 12/19/03 * @author Sun Microsystems, Inc */ public class SnmpIndex implements Serializable { /** * Initializes anSnmpIndex
using a vector of object identifiers.
* Following the RFC recommendations, every syntax that is used as a
* table index should have an object identifier representation. There are
* some guidelines on how to map the different syntaxes into an object identifier.
* In the different SnmpValue
classes provided, there is a toOid
method to get
* the object identifier of the value.
*
* @param oidList The list of Object Identifiers.
*/
public SnmpIndex(SnmpOid[] oidList) {
size= oidList.length;
for(int i= 0; i this
with.
*
* @return true
if the two indexes are equal, false
otherwise.
*/
public boolean equals(SnmpIndex index) {
if (size != index.getNbComponents())
return false;
// The two vectors have the same length.
// Compare each single element ...
//
SnmpOid oid1;
SnmpOid oid2;
Vector components= index.getComponents();
for(int i=0; i String
representation of the index.
* The different elements are separated by "//".
*
* @return A string representation of the index.
*/
public String toString() {
StringBuffer msg= new StringBuffer();
for(Enumeration e= oids.elements(); e.hasMoreElements(); ) {
SnmpOid val= (SnmpOid) e.nextElement();
msg.append( "//" + val.toString());
}
return msg.toString();
}
// PRIVATE VARIABLES
//------------------
/**
* The list of OIDs.
* @serial
*/
private Vector oids = new Vector();
/**
* The number of elements in the index.
* @serial
*/
private int size = 0;
}