1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.*; 31 32 40 41 public class Repository_impl 42 extends Container_impl 43 implements RepositoryOperations 44 { 45 51 54 public 55 Repository_impl(IFR ifr) 56 { 57 this(ifr, false); 59 } 60 61 67 public 68 Repository_impl(IFR ifr, 69 boolean enable_mappings) 70 { 71 super(ifr, null); 73 74 setServant(new RepositoryPOATie(this)); 76 77 primDef_null_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_null); 81 primDef_void_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_void); 82 primDef_short_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_short); 83 primDef_long_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_long); 84 primDef_ushort_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_ushort); 85 primDef_ulong_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_ulong); 86 primDef_float_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_float); 87 primDef_double_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_double); 88 primDef_boolean_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_boolean); 89 primDef_char_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_char); 90 primDef_octet_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_octet); 91 primDef_any_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_any); 92 primDef_TypeCode_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_TypeCode); 93 primDef_Principal_ = new PrimitiveDef_impl(ifr, 94 PrimitiveKind.pk_Principal); 95 primDef_string_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_string); 96 primDef_objref_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_objref); 97 primDef_longlong_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_longlong); 98 primDef_ulonglong_ = new PrimitiveDef_impl(ifr, 99 PrimitiveKind.pk_ulonglong); 100 primDef_longdouble_ = new PrimitiveDef_impl(ifr, 101 PrimitiveKind.pk_longdouble); 102 primDef_wchar_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_wchar); 103 primDef_wstring_ = new PrimitiveDef_impl(ifr, PrimitiveKind.pk_wstring); 104 primDef_value_base_ = new PrimitiveDef_impl(ifr, 105 PrimitiveKind.pk_value_base); 106 107 repID_elements_ = new java.util.Hashtable (); 109 mapped_elements_ = new java.util.Hashtable (); 110 111 isIDL2Repository_ = true; 113 enable_mappings_ = enable_mappings; 114 } 115 116 122 125 protected boolean isIDL2Repository_; 126 127 130 protected boolean enable_mappings_; 131 132 135 protected PrimitiveDef_impl primDef_null_; 136 protected PrimitiveDef_impl primDef_void_; 137 protected PrimitiveDef_impl primDef_short_; 138 protected PrimitiveDef_impl primDef_long_; 139 protected PrimitiveDef_impl primDef_ushort_; 140 protected PrimitiveDef_impl primDef_ulong_; 141 protected PrimitiveDef_impl primDef_float_; 142 protected PrimitiveDef_impl primDef_double_; 143 protected PrimitiveDef_impl primDef_boolean_; 144 protected PrimitiveDef_impl primDef_char_; 145 protected PrimitiveDef_impl primDef_octet_; 146 protected PrimitiveDef_impl primDef_any_; 147 protected PrimitiveDef_impl primDef_TypeCode_; 148 protected PrimitiveDef_impl primDef_Principal_; 149 protected PrimitiveDef_impl primDef_string_; 150 protected PrimitiveDef_impl primDef_objref_; 151 protected PrimitiveDef_impl primDef_longlong_; 152 protected PrimitiveDef_impl primDef_ulonglong_; 153 protected PrimitiveDef_impl primDef_longdouble_; 154 protected PrimitiveDef_impl primDef_wchar_; 155 protected PrimitiveDef_impl primDef_wstring_; 156 protected PrimitiveDef_impl primDef_value_base_; 157 158 161 protected java.util.Hashtable repID_elements_; 162 163 166 protected java.util.Hashtable mapped_elements_; 167 168 174 177 public boolean 178 isIDL2Repository() 179 { 180 return isIDL2Repository_; 181 } 182 183 186 public Repository 187 asRepository() 188 { 189 return RepositoryHelper.narrow(asObject()); 190 } 191 192 195 public void 196 addRID(String id, Contained_impl contained) 197 { 198 if (contained.container_.mapping_started_) 199 mapped_elements_.put(id, contained); 200 else 201 repID_elements_.put(id, contained); 202 } 203 204 207 public void 208 removeRID(String id) 209 { 210 mapped_elements_.remove(id); 211 repID_elements_.remove(id); 212 } 213 214 217 public Contained_impl 218 getRID(String id) 219 { 220 if (!isIDL2Repository()) 221 return (Contained_impl)repID_elements_.get(id); 222 223 java.lang.Object obj = mapped_elements_.get(id); 224 if (obj!=null) 225 return (Contained_impl)obj; 226 227 return (Contained_impl)repID_elements_.get(id); 228 } 229 230 233 public Contained_impl 234 getMappedRID(String id) 235 { 236 return (Contained_impl)mapped_elements_.get(id); 237 } 238 239 242 public PrimitiveDef_impl 243 getPrimDefVoid() 244 { 245 return primDef_void_; 246 } 247 248 254 260 public void 261 setDescriptionValue(Any any) 262 { 263 } 265 266 272 275 public DefinitionKind 276 def_kind() 277 { 278 return DefinitionKind.dk_Repository; 279 } 280 281 284 public void 285 destroy() 286 { 287 throw exceptionCanNotBeDestroyed(); 289 } 290 291 297 300 public Contained 301 lookup(String search_name) 302 { 303 while(search_name.startsWith("::")) 305 search_name = search_name.substring(2); 306 307 return super.lookup(search_name); 309 } 310 311 317 320 public Contained 321 lookup_id(String search_id) 322 { 323 Contained_impl contained = getRID(search_id); 324 325 if (contained == null) return null; 327 328 return contained.asContained(); 329 } 330 331 334 public TypeCode 335 get_canonical_typecode(TypeCode tc) 336 { 337 return tc; 340 } 341 342 345 public PrimitiveDef 346 get_primitive(PrimitiveKind kind) 347 { 348 switch(kind.value()) 349 { 350 case PrimitiveKind._pk_null: 351 return primDef_null_.asPrimitiveDef(); 352 353 case PrimitiveKind._pk_void: 354 return primDef_void_.asPrimitiveDef(); 355 356 case PrimitiveKind._pk_short: 357 return primDef_short_.asPrimitiveDef(); 358 359 case PrimitiveKind._pk_long: 360 return primDef_long_.asPrimitiveDef(); 361 362 case PrimitiveKind._pk_ushort: 363 return primDef_ushort_.asPrimitiveDef(); 364 365 case PrimitiveKind._pk_ulong: 366 return primDef_ulong_.asPrimitiveDef(); 367 368 case PrimitiveKind._pk_float: 369 return primDef_float_.asPrimitiveDef(); 370 371 case PrimitiveKind._pk_double: 372 return primDef_double_.asPrimitiveDef(); 373 374 case PrimitiveKind._pk_boolean: 375 return primDef_boolean_.asPrimitiveDef(); 376 377 case PrimitiveKind._pk_char: 378 return primDef_char_.asPrimitiveDef(); 379 380 case PrimitiveKind._pk_octet: 381 return primDef_octet_.asPrimitiveDef(); 382 383 case PrimitiveKind._pk_any: 384 return primDef_any_.asPrimitiveDef(); 385 386 case PrimitiveKind._pk_TypeCode: 387 return primDef_TypeCode_.asPrimitiveDef(); 388 389 case PrimitiveKind._pk_Principal: 390 return primDef_Principal_.asPrimitiveDef(); 391 392 case PrimitiveKind._pk_string: 393 return primDef_string_.asPrimitiveDef(); 394 395 case PrimitiveKind._pk_objref: 396 return primDef_objref_.asPrimitiveDef(); 397 398 case PrimitiveKind._pk_longlong: 399 return primDef_longlong_.asPrimitiveDef(); 400 401 case PrimitiveKind._pk_ulonglong: 402 return primDef_ulonglong_.asPrimitiveDef(); 403 404 case PrimitiveKind._pk_longdouble: 405 return primDef_longdouble_.asPrimitiveDef(); 406 407 case PrimitiveKind._pk_wchar: 408 return primDef_wchar_.asPrimitiveDef(); 409 410 case PrimitiveKind._pk_wstring: 411 return primDef_wstring_.asPrimitiveDef(); 412 413 case PrimitiveKind._pk_value_base: 414 return primDef_value_base_.asPrimitiveDef(); 415 } 416 417 return null; 418 } 419 420 423 public StringDef 424 create_string(int bound) 425 { 426 StringDef_impl s = new StringDef_impl(getIFR()); 427 428 try 429 { 430 s.bound(bound); 431 } 432 catch(SystemException exc) 433 { 434 s.destroy(); 435 throw exc; 436 } 437 438 return s.asStringDef(); 439 } 440 441 444 public WstringDef 445 create_wstring(int bound) 446 { 447 WstringDef_impl s = new WstringDef_impl(getIFR()); 448 449 try 450 { 451 s.bound(bound); 452 } 453 catch(SystemException exc) 454 { 455 s.destroy(); 456 throw exc; 457 } 458 459 return s.asWstringDef(); 460 } 461 462 465 public SequenceDef 466 create_sequence(int bound, 467 IDLType element_type) 468 { 469 SequenceDef_impl s = new SequenceDef_impl(getIFR()); 470 471 try { 472 s.bound(bound); 473 s.element_type_def(element_type); 474 } catch(SystemException exc) { 475 s.destroy(); 476 throw exc; 477 } 478 479 return s.asSequenceDef(); 480 } 481 482 485 public ArrayDef 486 create_array(int length, 487 IDLType element_type) 488 { 489 ArrayDef_impl a = new ArrayDef_impl(getIFR()); 490 491 try 492 { 493 a.length(length); 494 a.element_type_def(element_type); 495 } 496 catch(SystemException exc) 497 { 498 a.destroy(); 499 throw exc; 500 } 501 502 return a.asArrayDef(); 503 } 504 505 508 public FixedDef 509 create_fixed(short digits, 510 short scale) 511 { 512 FixedDef_impl f = new FixedDef_impl(getIFR()); 513 514 try 515 { 516 f.digits(digits); 517 f.scale(scale); 518 } 519 catch(SystemException exc) 520 { 521 f.destroy(); 522 throw exc; 523 } 524 525 return f.asFixedDef(); 526 } 527 } 528 | Popular Tags |