1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.*; 31 import org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription; 32 33 41 42 public class InterfaceDef_impl 43 extends Container_impl 44 implements InterfaceDefOperations 45 { 46 52 53 protected InterfaceDef_ref[] base_interfaces_; 54 55 61 62 public 63 InterfaceDef_impl(IFR ifr, 64 Container_impl container) 65 { 66 this(ifr, container, false); 67 68 setServant(new InterfaceDefPOATie(this)); 70 } 71 72 73 public 74 InterfaceDef_impl(IFR ifr, 75 Container_impl container, 76 boolean dummy) 77 { 78 super(ifr, container); 80 81 base_interfaces_ = new InterfaceDef_ref[0]; 83 } 84 85 91 94 protected InterfaceDef_ref[] 95 getBaseInterfaces() 96 { 97 return base_interfaces_; 98 } 99 100 106 110 protected TypeCode 111 recursiveType(java.util.List idSeq) 112 { 113 return type(); 114 } 115 116 122 125 public InterfaceDef 126 asInterfaceDef() 127 { 128 return InterfaceDefHelper.narrow(asObject()); 129 } 130 131 137 140 public void 141 setDescriptionValue(Any any) 142 { 143 InterfaceDescription description = new InterfaceDescription(); 145 description.name = name(); 146 description.id = id(); 147 description.defined_in = getContainerID(); 148 description.version = version(); 149 description.base_interfaces = 150 InterfaceDef_ref.computeRepositoryIdSeq(getBaseInterfaces()); 151 152 InterfaceDescriptionHelper.insert(any, description); 154 } 155 156 162 165 public boolean 166 checkDefinitionKind(DefinitionKind dk) 167 { 168 return (dk == DefinitionKind.dk_Attribute) 169 || (dk == DefinitionKind.dk_Constant) 170 || (dk == DefinitionKind.dk_Exception) 171 || (dk == DefinitionKind.dk_Operation) 172 || (dk == DefinitionKind.dk_Alias) 173 || (dk == DefinitionKind.dk_Struct) 174 || (dk == DefinitionKind.dk_Union) 175 || (dk == DefinitionKind.dk_Enum) 176 || (dk == DefinitionKind.dk_Native); 177 } 178 179 182 public void 183 checkName(String name, 184 boolean exclude_inherited, 185 boolean in_inherited) 186 { 187 super.checkName(name, exclude_inherited, in_inherited); 189 190 if(!exclude_inherited) 191 { 192 InterfaceDef_ref[] bases = getBaseInterfaces(); 193 for(int i=0; i<bases.length; i++) 194 bases[i].getImpl().checkName(name, false, true); 195 } 196 } 197 198 201 public java.util.List 202 selectNamedContained(java.util.List selection, 203 String search_name, 204 int levels_to_search, 205 DefinitionKind limit_type, 206 boolean exclude_inherited) 207 { 208 super.selectNamedContained(selection, search_name, levels_to_search, 210 limit_type, exclude_inherited); 211 212 if(!exclude_inherited) 213 { 214 InterfaceDef_ref[] bases = getBaseInterfaces(); 215 for(int i=0; i<bases.length; i++) 216 { 217 bases[i].getImpl().selectNamedContained(selection, 218 search_name, levels_to_search, 219 limit_type, false); 220 } 221 } 222 223 return selection; 224 } 225 226 229 public java.util.List 230 selectContained(java.util.List selection, 231 DefinitionKind limit_type, 232 boolean exclude_inherited) 233 { 234 super.selectContained(selection, limit_type, exclude_inherited); 236 237 if(!exclude_inherited) 238 { 239 InterfaceDef_ref[] bases = getBaseInterfaces(); 240 for(int i=0; i<bases.length; i++) 241 { 242 bases[i].getImpl().selectContained( 243 selection, limit_type, false); 244 } 245 } 246 247 return selection; 248 } 249 250 256 259 protected void 260 cutDependencies() 261 { 262 InterfaceDef_ref.cutDependencies(base_interfaces_); 264 base_interfaces_ = null; 265 266 super.cutDependencies(); 268 } 269 270 276 279 public DefinitionKind 280 def_kind() 281 { 282 return DefinitionKind.dk_Interface; 283 } 284 285 291 294 public TypeCode 295 type() 296 { 297 return getIFR().getTCF().create_interface_tc(id(), name()); 299 } 300 301 307 310 public Contained 311 lookup(String search_name) 312 { 313 Contained contained1 = super.lookup(search_name); 315 316 if (contained1 == null) 317 { 318 InterfaceDef_ref[] bases = getBaseInterfaces(); 319 for(int i=0; i<bases.length; i++) 320 { 321 Contained contained2 = bases[i].getImpl().lookup(search_name); 322 if(contained2 != null) 323 { 324 if(contained1 != null) 325 { 326 String id1 = contained1.id(); 327 String id2 = contained2.id(); 328 if(!id1.equals(id2)) 329 throw exceptionAmbiguousLookup(id1, id2); 330 } 331 332 contained1 = contained2; 333 } 334 } 335 } 336 337 return contained1; 338 } 339 340 346 349 public InterfaceDef[] 350 base_interfaces() 351 { 352 return InterfaceDef_ref.computeInterfaceDefSeq(getBaseInterfaces()); 353 } 354 355 358 public void 359 base_interfaces(InterfaceDef[] val) 360 { 361 InterfaceDef_impl[] itfs = new InterfaceDef_impl[val.length]; 362 for (int i=0; i<val.length; i++) 363 itfs[i] = castToLocal(val[i]); 364 365 367 InterfaceDef_ref[] refs = new InterfaceDef_ref[val.length]; 368 for (int i=0; i<val.length; i++) 369 refs[i] = new InterfaceDef_ref( this, itfs[i] ); 370 371 InterfaceDef_ref.cutDependencies(getBaseInterfaces()); 373 374 base_interfaces_ = refs; 375 } 376 377 380 public boolean 381 is_a(String interface_id) 382 { 383 if(interface_id.equals(id())) 384 return true; 385 386 if(interface_id.equals("IDL:omg.org/CORBA/Object:1.0")) 387 return true; 388 389 InterfaceDef_ref[] bases = getBaseInterfaces(); 390 for(int i=0; i<bases.length; i++) 391 if (bases[i].getImpl().is_a(interface_id)) 392 return true; 393 394 return false; 395 } 396 397 400 public FullInterfaceDescription 401 describe_interface() 402 { 403 FullInterfaceDescription description = new FullInterfaceDescription(); 404 description.name = name(); 405 description.id = id(); 406 description.defined_in = getContainerID(); 407 description.version = version(); 408 description.operations = getOpDescriptionSeq(); 409 description.attributes = getAttrDescriptionSeq(); 410 description.base_interfaces = 411 InterfaceDef_ref.computeRepositoryIdSeq(getBaseInterfaces()); 412 description.type = type(); 413 return description; 414 } 415 416 419 public AttributeDef 420 create_attribute(String id, 421 String name, 422 String version, 423 IDLType type, 424 AttributeMode mode) 425 { 426 AttributeDef_impl attr = new AttributeDef_impl(getIFR(), this); 427 428 try 429 { 430 addContained(attr, id, name, version); 431 attr.type_def(type); 432 attr.mode(mode); 433 } 434 catch(SystemException exc) 435 { 436 attr.destroy(); 437 throw exc; 438 } 439 440 attr.whenCreated(); 441 return attr.asAttributeDef(); 442 } 443 444 447 public OperationDef 448 create_operation(String id, 449 String name, 450 String version, 451 IDLType result, 452 OperationMode mode, 453 ParameterDescription[] params, 454 ExceptionDef[] exceptions, 455 String [] contexts) 456 { 457 OperationDef_impl op = new OperationDef_impl(getIFR(), this); 458 459 try 460 { 461 addContained(op, id, name, version); 462 op.result_def(result); 463 op.mode(mode); 464 op.params(params); 465 op.exceptions(exceptions); 466 op.contexts(contexts); 467 } 468 catch(SystemException exc) 469 { 470 op.destroy(); 471 throw exc; 472 } 473 474 op.whenCreated(); 475 return op.asOperationDef(); 476 } 477 } 478 | Popular Tags |