1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class InterfaceDeclImpl 39 extends ForwardScopeImpl 40 implements InterfaceRef, InterfaceDecl 41 { 42 48 51 private org.omg.CORBA.ExtInterfaceDef ext_interface_def_; 52 53 56 protected org.objectweb.ccm.util.Vector inherited_interfaces_; 57 58 64 69 protected 70 InterfaceDeclImpl(Repository rep, ScopeImpl parent) 71 { 72 super(rep, parent); 74 75 ext_interface_def_ = null; 77 inherited_interfaces_ = new org.objectweb.ccm.util.Vector(); 78 the_declaration_kind_ = DeclarationKind._dk_interface; 79 } 80 81 87 92 protected org.omg.CORBA.InterfaceDef [] 93 getInterfaceDefs() 94 { 95 org.omg.CORBA.InterfaceDef [] result = 96 new org.omg.CORBA.InterfaceDef [inherited_interfaces_.size()]; 97 98 for(int i=0; i<result.length; i++) 99 { 100 result[i] = ((InterfaceRef)(inherited_interfaces_.get(i))).getExtInterfaceDef(); 101 } 102 103 return result; 104 } 105 106 113 protected Declaration 114 findInInheritedInterfaces(String name) 115 { 116 for(int i=0; i<inherited_interfaces_.size(); i++) 117 { 118 Declaration decl = ((InterfaceDecl)(inherited_interfaces_.get(i))).find(name); 119 if (decl != null) return decl; 121 } 122 123 return null; 125 } 126 127 132 protected void 133 load(org.omg.CORBA.Contained contained) 134 { 135 ext_interface_def_ = org.omg.CORBA.ExtInterfaceDefHelper.narrow(contained); 136 org.omg.CORBA.InterfaceDef [] base_interfaces = ext_interface_def_.base_interfaces(); 137 138 for (int i=0;i<base_interfaces.length;i++) 139 addInterface((InterfaceRef)getRepository().lookupId(base_interfaces[i].id())); 141 142 super.load(contained); 143 } 144 145 150 protected void 151 loadAsMapping(org.omg.CORBA.Contained contained) 152 { 153 ext_interface_def_ = org.omg.CORBA.ExtInterfaceDefHelper.narrow(contained); 154 org.omg.CORBA.InterfaceDef [] base_interfaces = ext_interface_def_.base_interfaces(); 155 156 for (int i=0;i<base_interfaces.length;i++) 157 addInterface((InterfaceRef)getRepository().lookupMappedId(base_interfaces[i].id())); 159 160 super.loadAsMapping(contained); 161 } 162 163 169 180 public Declaration 181 find(String name) 182 { 183 Declaration decl = super.find(name); 185 186 if(decl != null) return decl; 188 189 return findInInheritedInterfaces(name); 191 } 192 193 200 public Declaration[] 201 getDependencies() 202 { 203 if (dependencies_!=null) 204 return dependencies_; 205 206 dependencies_ = new Declaration[0]; 207 org.objectweb.ccm.util.Vector itf_depend = new org.objectweb.ccm.util.Vector(); 208 Declaration[] depend = null; 209 210 InterfaceDecl[] bases = getBaseInterfaces(); 212 for (int i=0;i<bases.length;i++) 213 { 214 itf_depend.add(bases[i]); 215 depend = bases[i].getDependencies(); 216 for (int j=0;j<depend.length;j++) 217 { 218 if ((depend[j]!=this) && 219 (itf_depend.indexOf(depend[j])==-1)) 220 itf_depend.add(depend[j]); 221 } 222 } 223 224 Declaration[] decls = getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_all); 226 for (int i=0;i<decls.length;i++) 227 { 228 depend = decls[i].getDependencies(); 229 for (int j=0;j<depend.length;j++) 230 { 231 if ((!containsDecl(depend[j])) && 232 (depend[j]!=this) && 233 (itf_depend.indexOf(depend[j])==-1)) 234 itf_depend.add(depend[j]); 235 } 236 } 237 238 dependencies_ = (Declaration[])itf_depend.toArray(new Declaration[0]); 239 return dependencies_; 240 } 241 242 248 253 public org.omg.CORBA.IDLType 254 getIDLType() 255 { 256 return ext_interface_def_; 257 } 258 259 262 public int 263 getTypeKind() 264 { 265 return TypeKind._tk_interface; 266 } 267 268 274 280 public org.omg.CORBA.ExtInterfaceDef 281 getExtInterfaceDef() 282 { 283 return ext_interface_def_; 284 } 285 286 292 public org.omg.CORBA.InterfaceDef 293 getInterfaceDef() 294 { 295 return ext_interface_def_; 296 } 297 298 304 309 public void 310 addInterface(InterfaceRef itf) 311 { 312 if(itf != null) 313 { 314 itf.addRef(); 315 inherited_interfaces_.add(itf); 316 } 317 } 318 319 325 328 public InterfaceDecl[] 329 getBaseInterfaces() 330 { 331 InterfaceDecl[] result = new InterfaceDecl[inherited_interfaces_.size()]; 332 333 for(int i=0; i<result.length; i++) 334 { 335 result[i] = (InterfaceDecl)inherited_interfaces_.get(i); 336 } 337 return result; 338 } 339 340 346 349 public void 350 destroy() 351 { 352 for (int i=0;i<inherited_interfaces_.size();i++) 353 { 354 ((InterfaceRef)inherited_interfaces_.get(i)).removeRef(); 355 } 356 super.destroy(); 357 } 358 359 365 protected org.omg.CORBA.Contained 366 getContained() 367 { 368 return ext_interface_def_; 369 } 370 371 377 383 protected org.omg.CORBA.Container 384 getContainer() 385 { 386 return ext_interface_def_; 387 } 388 389 401 protected org.omg.CORBA.ExtAttributeDef 402 createExtAttribute(AttributeDecl attribute, 403 org.omg.CORBA.IDLType type, 404 org.omg.CORBA.AttributeMode mode, 405 org.omg.CORBA.ExceptionDef [] get_exceptions, 406 org.omg.CORBA.ExceptionDef [] set_exceptions) 407 { 408 org.omg.CORBA.ExtAttributeDef ext_attribute_def = 410 getExtInterfaceDef().create_ext_attribute(attribute.getId(), 411 attribute.getName(), 412 attribute.getVersion(), 413 type, mode, 414 get_exceptions, 415 set_exceptions); 416 return ext_attribute_def; 417 } 418 419 432 protected org.omg.CORBA.OperationDef 433 createOperation(OperationDecl operation, 434 org.omg.CORBA.IDLType type, 435 org.omg.CORBA.OperationMode mode, 436 org.omg.CORBA.ParameterDescription [] params, 437 org.omg.CORBA.ExceptionDef [] exceptions, 438 String [] contexts) 439 { 440 org.omg.CORBA.OperationDef operation_def = 442 getExtInterfaceDef().create_operation(operation.getId(), 443 operation.getName(), 444 operation.getVersion(), 445 type, mode, 446 params, 447 exceptions, 448 contexts); 449 return operation_def; 450 } 451 452 460 public Declaration[] 461 getContents(boolean exclude_inherited, int limited_types) 462 { 463 if (exclude_inherited) 464 return super.getContents(exclude_inherited, limited_types); 465 466 if (is_mapping_) 469 getRepository().useIDL2Repository(); 470 471 Declaration[] res = super.getContents(exclude_inherited, limited_types); 472 InterfaceDecl[] itfs = getBaseInterfaces(); 473 for (int i=0;i<itfs.length;i++) 474 { 475 Declaration[] tmp1 = itfs[i].getContents(exclude_inherited, limited_types); 476 Declaration[] tmp2 = res; 477 res = new Declaration[tmp1.length+tmp2.length]; 478 System.arraycopy(tmp2, 0, res, 0, tmp2.length); 479 System.arraycopy(tmp1, 0, res, tmp2.length, tmp1.length); 480 } 481 482 if (is_mapping_) 484 getRepository().useIDL3Repository(); 485 486 return res; 487 } 488 489 495 498 protected void 499 createContainer() 500 { 501 ext_interface_def_ = the_parent_.getContainer().create_ext_interface(getId(),getName(), getVersion(), 502 getInterfaceDefs()); 503 } 504 505 508 protected void 509 completeContainer() 510 { 511 org.omg.CORBA.InterfaceDef [] inherited_interfaces = getInterfaceDefs(); 512 if (inherited_interfaces.length != 0) 513 getExtInterfaceDef().base_interfaces(inherited_interfaces); 514 } 515 } 516 | Popular Tags |