1 11 12 13 package com.sun.jmx.snmp; 14 15 16 import java.util.Vector ; 19 20 import com.sun.jmx.snmp.SnmpOidTable; 23 import com.sun.jmx.snmp.SnmpOidRecord; 24 import com.sun.jmx.snmp.SnmpStatusException; 25 26 33 34 public class SnmpOidDatabaseSupport implements SnmpOidDatabase { 35 36 39 public SnmpOidDatabaseSupport(){ 40 tables=new Vector (); 41 } 42 43 47 public SnmpOidDatabaseSupport(SnmpOidTable table){ 48 tables=new Vector (); 49 tables.addElement(table); 50 } 51 52 56 public void add(SnmpOidTable table) { 57 if (!tables.contains(table)) { 58 tables.addElement(table); 59 } 60 } 61 62 67 public void remove(SnmpOidTable table) throws SnmpStatusException { 68 if (!tables.contains(table)) { 69 throw new SnmpStatusException("The specified SnmpOidTable does not exist in this SnmpOidDatabase"); 70 } 71 tables.removeElement(table); 72 } 73 74 82 public SnmpOidRecord resolveVarName(String name) throws SnmpStatusException { 83 for (int i=0;i<tables.size();i++) { 84 try { 85 return (((SnmpOidTable)tables.elementAt(i)).resolveVarName(name)); 86 } 87 catch (SnmpStatusException e) { 88 if (i==tables.size()-1) { 89 throw new SnmpStatusException(e.getMessage()); 90 } 91 } 92 } 93 return null; 94 } 95 96 103 public SnmpOidRecord resolveVarOid(String oid) throws SnmpStatusException { 104 for (int i=0;i<tables.size();i++) { 105 try { 106 return (((SnmpOidTable)tables.elementAt(i)).resolveVarOid(oid)); 107 } 108 catch (SnmpStatusException e) { 109 if (i==tables.size()-1) { 110 throw new SnmpStatusException(e.getMessage()); 111 } 112 } 113 } 114 return null; 115 } 116 117 122 public Vector getAllEntries() { 123 Vector res = new Vector (); 124 for (int i=0;i<tables.size();i++) { 125 Vector tmp = ((SnmpOidTable)tables.elementAt(i)).getAllEntries(); 126 if (tmp != null) { 127 for(int ii=0; ii<tmp.size(); ii++) { 128 res.addElement(tmp.elementAt(ii)); 129 } 130 } 131 } 132 return res; 134 } 135 136 139 public void removeAll(){ 140 tables.removeAllElements() ; 141 } 142 143 private Vector tables; 144 } 145 | Popular Tags |