1 11 package com.sun.jmx.snmp.internal; 12 13 import java.util.Hashtable ; 14 import com.sun.jmx.snmp.SnmpEngineId; 15 import com.sun.jmx.snmp.SnmpUnknownModelLcdException; 16 import com.sun.jmx.snmp.SnmpUnknownSubSystemException; 17 24 public abstract class SnmpLcd { 25 26 class SubSysLcdManager { 27 private Hashtable models = new Hashtable (); 28 public void addModelLcd(int id, 29 SnmpModelLcd usmlcd) { 30 models.put(new Integer (id), usmlcd); 31 } 32 33 public SnmpModelLcd getModelLcd(int id) { 34 return (SnmpModelLcd) models.get(new Integer (id)); 35 } 36 37 public SnmpModelLcd removeModelLcd(int id) { 38 return (SnmpModelLcd) models.remove(new Integer (id)); 39 } 40 } 41 42 43 private Hashtable subs = new Hashtable (); 44 45 49 public abstract int getEngineBoots(); 50 54 public abstract String getEngineId(); 55 56 60 public abstract void storeEngineBoots(int i); 61 62 66 public abstract void storeEngineId(SnmpEngineId id); 67 73 public void addModelLcd(SnmpSubSystem sys, 74 int id, 75 SnmpModelLcd lcd) { 76 77 SubSysLcdManager subsys = (SubSysLcdManager) subs.get(sys); 78 if( subsys == null ) { 79 subsys = new SubSysLcdManager(); 80 subs.put(sys, subsys); 81 } 82 83 subsys.addModelLcd(id, lcd); 84 } 85 90 public void removeModelLcd(SnmpSubSystem sys, 91 int id) 92 throws SnmpUnknownModelLcdException, SnmpUnknownSubSystemException { 93 94 SubSysLcdManager subsys = (SubSysLcdManager) subs.get(sys); 95 if( subsys != null ) { 96 SnmpModelLcd lcd = subsys.removeModelLcd(id); 97 if(lcd == null) { 98 throw new SnmpUnknownModelLcdException("Model : " + id); 99 } 100 } 101 else 102 throw new SnmpUnknownSubSystemException(sys.toString()); 103 } 104 105 111 public SnmpModelLcd getModelLcd(SnmpSubSystem sys, 112 int id) { 113 SubSysLcdManager subsys = (SubSysLcdManager) subs.get(sys); 114 115 if(subsys == null) return null; 116 117 return (SnmpModelLcd) subsys.getModelLcd(id); 118 } 119 } 120 | Popular Tags |