/* * * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ // Copyright (c) 1995-96 by Cisco Systems, Inc. package com.sun.jmx.snmp; // java import // import java.util.Vector; // jmx import // import com.sun.jmx.snmp.SnmpOidTable; import com.sun.jmx.snmp.SnmpOidRecord; import com.sun.jmx.snmp.SnmpStatusException; import static com.sun.jmx.mbeanserver.Util.cast; /** * Defines a set of SnmpOidTable objects containing metadata definitions for MIB variables. * Each SnmpOidTable should contain information on variables of one MIB. * It provides resolution of all MIB variables contained in the SnmpOidTable objects. *

This API is a Sun Microsystems internal API and is subject * to change without notice.

*/ public class SnmpOidDatabaseSupport implements SnmpOidDatabase { /** * Creates an empty SnmpOidDatabaseSupport. */ public SnmpOidDatabaseSupport(){ tables=new Vector(); } /** * Creates an SnmpOidDatabaseSupport containing the specified SnmpOidTable object. * @param table The SnmpOidTable object used to initialize this SnmpOidDatabaseSupport. */ public SnmpOidDatabaseSupport(SnmpOidTable table){ tables=new Vector(); tables.addElement(table); } /** * Adds a SnmpOidTable object in this SnmpOidDatabase. * @param table The table to add. */ public void add(SnmpOidTable table) { if (!tables.contains(table)) { tables.addElement(table); } } /** * Removes a SnmpOidTable object from this SnmpOidDatabase. * @param table The table to be removed. * @exception SnmpStatusException The specified SnmpOidTable does not exist in this SnmpOidDatabase. */ public void remove(SnmpOidTable table) throws SnmpStatusException { if (!tables.contains(table)) { throw new SnmpStatusException("The specified SnmpOidTable does not exist in this SnmpOidDatabase"); } tables.removeElement(table); } /** * Searches for a MIB variable given its logical name and returns an SnmpOidRecord * object containing information on the variable. * @param name The name of the MIB variable. * @return The SnmpOidRecord object containing information on the variable. * * @exception SnmpStatusException The specified name does not exist in this SnmpOidDatabase */ public SnmpOidRecord resolveVarName(String name) throws SnmpStatusException { for (int i=0;iSnmpOidRecord object containing * information on the variable. * @param oid The OID of the MIB variable. * @return The SnmpOidRecord object containing information on the variable. * @exception SnmpStatusException The specified oid does not exist in this SnmpOidDatabase. */ public SnmpOidRecord resolveVarOid(String oid) throws SnmpStatusException { for (int i=0;iSnmpOidTable objects * of this SnmpOidDatabase. * @return A vector of SnmpOidTable objects containing all the elements of this SnmpOidDatabase. */ public Vector getAllEntries() { Vector res = new Vector(); for (int i=0;i tmp = cast(tables.elementAt(i).getAllEntries()); if (tmp != null) { for(int ii=0; iiSnmpOidTable objects from this SnmpOidDatabase. */ public void removeAll(){ tables.removeAllElements() ; } private Vector tables; }