1 27 package org.objectweb.openccm.Containers.MetaInformation; 28 29 import org.objectweb.ccm.util.Table; 30 import org.omg.CORBA.LocalObject ; 31 import org.omg.Components.InvalidName; 32 33 39 public class InterfaceInstanceListImpl 40 extends LocalObject 41 implements InterfaceInstanceList 42 { 43 private Table _interfaces; 44 45 public InterfaceInstanceListImpl() 46 { 47 _interfaces = new Table(); 48 } 49 50 53 public InterfaceInstance 54 get_interface_instance(String name) 55 throws InvalidName 56 { 57 InterfaceInstance result = (InterfaceInstance) _interfaces.get(name); 58 if(result == null) 59 throw new InvalidName(); 60 return result; 61 } 62 63 66 public InterfaceInstance[] 67 get_named_interface_instances(String [] names) 68 throws InvalidName 69 { 70 InterfaceInstance[] result = new InterfaceInstance[names.length]; 71 72 74 int i = 0; 75 for(i=0;i<names.length;i++) 76 { 77 result[i] = (InterfaceInstance)_interfaces.get(names[i]); 78 79 if(result[i] == null) 80 { 81 throw new InvalidName(); 82 } 83 } 84 85 return result; 86 } 87 88 91 public InterfaceInstance[] 92 get_all_interface_instances() 93 { 94 InterfaceInstance[] result = new InterfaceInstance[_interfaces.size()]; 95 96 int idx = 0; 98 for(java.util.Enumeration elements = _interfaces.elements(); elements.hasMoreElements(); ) 99 { 100 InterfaceInstance info = (InterfaceInstance)elements.nextElement(); 101 result[idx++] = info; 102 } 103 return result; 104 } 105 106 109 public void add_interface_instance(InterfaceInstance cpi) 110 { 111 112 String key = cpi.type_reference().name() + cpi.toString().substring(cpi.toString().lastIndexOf("@")); 113 _interfaces.put(new String (cpi.type_reference().name()+cpi),cpi); 114 115 } 116 117 120 public void remove_interface_instance(String name) 121 throws InvalidName 122 { 123 Object result = _interfaces.remove(name); 124 125 if (result == null) throw new InvalidName(); 126 } 127 } 128 | Popular Tags |