1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.*; 31 import org.omg.CORBA.ValueDefPackage.FullValueDescription; 32 33 41 42 public class ValueDef_impl 43 extends Container_impl 44 implements ValueDefOperations 45 { 46 52 53 protected InterfaceDef_ref[] supported_interfaces_; 54 55 56 protected Initializer_impl[] initializers_; 57 58 59 protected ValueDef_ref base_value_; 60 61 62 protected ValueDef_ref[] abstract_base_values_; 63 64 65 protected boolean is_abstract_; 66 67 68 protected boolean is_custom_; 69 70 71 protected boolean is_truncatable_; 72 73 79 80 public 81 ValueDef_impl(IFR ifr, 82 Container_impl container) 83 { 84 super(ifr, container); 86 87 setServant(new ValueDefPOATie(this)); 89 90 supported_interfaces_ = null; 92 initializers_ = new Initializer_impl[0]; 93 base_value_ = new ValueDef_ref(this); 94 abstract_base_values_ = null; 95 is_abstract_ = false; 96 is_custom_ = false; 97 is_truncatable_ = false; 98 } 99 100 106 109 protected ValueDef_ref[] 110 getAbstractBaseValues() 111 { 112 return abstract_base_values_; 113 } 114 115 118 protected ValueDef_ref 119 getBaseValue() 120 { 121 return base_value_; 122 } 123 124 130 134 protected TypeCode 135 recursiveType(java.util.List idSeq) 136 { 137 int idx = idSeq.indexOf(id()); 138 if (idx!=-1) 139 return getIFR().getTCF().create_recursive_tc(id()); 140 141 idSeq.add(id()); 142 143 short mode = (short)0; 144 if(is_custom()) 145 mode = (short)1; 146 else if(is_abstract()) 147 mode = (short)2; 148 else if(is_truncatable()) 149 mode = (short)3; 150 else 151 mode = (short)0; 152 153 org.omg.CORBA.TypeCode tc = getBaseValue().recursiveType(idSeq); 155 156 if(tc == null) 158 tc = org.objectweb.openccm.corba.TheORB.get_null_valuebase_tc(); 159 160 ValueMember[] members = getValueMemberSeq(idSeq); 161 idSeq.remove(id()); 162 163 return getIFR().getTCF(). 165 create_value_tc(id(), name(), mode, 166 tc, members); 167 } 168 169 175 178 public ValueDef 179 asValueDef() 180 { 181 return ValueDefHelper.narrow(asObject()); 182 } 183 184 187 public ValueMember[] 188 getValueMemberSeq(java.util.List idSeq) 189 { 190 java.util.List selection = new java.util.ArrayList (); 191 192 selectContained(selection, DefinitionKind.dk_ValueMember, true); 193 194 ValueMember[] result = new ValueMember[selection.size()]; 195 196 for(int i=0; i<selection.size(); i++) 197 result[i] = ((ValueMemberDef_impl)selection.get(i)) 198 .getValueMember(idSeq); 199 200 return result; 201 } 202 203 206 public ValueMember[] 207 getValueMemberSeq() 208 { 209 java.util.List selection = new java.util.ArrayList (); 210 211 selectContained(selection, DefinitionKind.dk_ValueMember, true); 212 213 ValueMember[] result = new ValueMember[selection.size()]; 214 215 for(int i=0; i<selection.size(); i++) 216 result[i] = ((ValueMemberDef_impl)selection.get(i)) 217 .getValueMember(); 218 219 return result; 220 } 221 222 225 public void 226 checkNameInit(String name, 227 boolean exclude_inherited, 228 boolean in_inherited, 229 boolean check_init) 230 { 231 super.checkName(name, exclude_inherited, in_inherited); 233 234 if(check_init) 238 { 239 for(int i=0; i<initializers_.length; i++) 240 { 241 if(name.equalsIgnoreCase(initializers_[i].getName())) 242 { 243 if(in_inherited) 244 throw exceptionNameClashInInheritedContext(name); 245 else 246 throw exceptionNameAlreadyUsed(name); 247 } 248 } 249 } 250 251 if(!exclude_inherited) 252 { 253 if(getBaseValue().getImpl() != null) 257 getBaseValue().getImpl().checkNameInit(name, false, true, check_init); 258 259 ValueDef_ref[] abs_refs = getAbstractBaseValues(); 263 for(int i=0; i<abs_refs.length; i++) 264 abs_refs[i].getImpl().checkNameInit(name, false, 265 true, check_init); 266 267 for(int i=0; i<supported_interfaces_.length; i++) 271 supported_interfaces_[i].getImpl().checkName(name, false, true); 272 } 273 } 274 275 278 public ValueDescription 279 getValueDescription() 280 { 281 ValueDescription description = new ValueDescription(); 283 description.name = name(); 284 description.id = id(); 285 description.is_abstract = is_abstract(); 286 description.is_custom = is_custom(); 287 description.defined_in = getContainerID(); 288 description.version = version(); 289 description.supported_interfaces = InterfaceDef_ref. 290 computeRepositoryIdSeq(supported_interfaces_); 291 description.abstract_base_values = ValueDef_ref. 292 computeRepositoryIdSeq(getAbstractBaseValues()); 293 description.is_truncatable = is_truncatable(); 294 description.base_value = getBaseValue().getId(); 295 296 return description; 297 } 298 299 305 308 public void 309 setDescriptionValue(Any any) 310 { 311 ValueDescriptionHelper.insert(any, getValueDescription()); 313 } 314 315 321 324 public boolean 325 checkDefinitionKind(DefinitionKind dk) 326 { 327 return (dk == DefinitionKind.dk_Attribute) 328 || (dk == DefinitionKind.dk_Constant) 329 || (dk == DefinitionKind.dk_Exception) 330 || (dk == DefinitionKind.dk_Operation) 331 || (dk == DefinitionKind.dk_Alias) 332 || (dk == DefinitionKind.dk_Struct) 333 || (dk == DefinitionKind.dk_Union) 334 || (dk == DefinitionKind.dk_Enum) 335 || (dk == DefinitionKind.dk_Native) 336 || (dk == DefinitionKind.dk_ValueMember); 337 } 338 339 342 public void 343 checkName(String name, 344 boolean exclude_inherited, 345 boolean in_inherited) 346 { 347 checkNameInit(name, exclude_inherited, in_inherited, true); 348 } 349 350 353 public java.util.List 354 selectNamedContained(java.util.List selection, 355 String search_name, 356 int levels_to_search, 357 DefinitionKind limit_type, 358 boolean exclude_inherited) 359 { 360 super.selectNamedContained(selection, search_name, levels_to_search, 362 limit_type, exclude_inherited); 363 364 if(!exclude_inherited) 365 { 366 for(int i=0; i<supported_interfaces_.length; i++) 367 { 368 supported_interfaces_[i].getImpl().selectNamedContained(selection, 369 search_name, levels_to_search, 370 limit_type, false); 371 } 372 373 if(getBaseValue().getImpl() != null) 374 getBaseValue().getImpl().selectNamedContained(selection, 375 search_name, levels_to_search, 376 limit_type, false); 377 378 ValueDef_ref[] abs_refs = getAbstractBaseValues(); 379 for(int i=0; i<abs_refs.length; i++) 380 { 381 abs_refs[i].getImpl().selectNamedContained(selection, 382 search_name, levels_to_search, 383 limit_type, false); 384 } 385 386 } 387 388 return selection; 389 } 390 391 394 public java.util.List 395 selectContained(java.util.List selection, 396 DefinitionKind limit_type, 397 boolean exclude_inherited) 398 { 399 super.selectContained(selection, limit_type, exclude_inherited); 401 402 if(!exclude_inherited) 403 { 404 for(int i=0; i<supported_interfaces_.length; i++) 405 { 406 supported_interfaces_[i].getImpl().selectContained( 407 selection, limit_type, false); 408 } 409 410 if(getBaseValue().getImpl() != null) 411 getBaseValue().getImpl().selectContained( 412 selection, limit_type, false); 413 414 ValueDef_ref[] abs_refs = getAbstractBaseValues(); 415 for(int i=0; i<abs_refs.length; i++) 416 { 417 abs_refs[i].getImpl().selectContained( 418 selection, limit_type, false); 419 } 420 421 } 422 423 return selection; 424 } 425 426 432 435 protected void 436 cutDependencies() 437 { 438 InterfaceDef_ref.cutDependencies(supported_interfaces_); 440 supported_interfaces_ = null; 441 442 for(int i=0; i<initializers_.length; i++) 444 initializers_[i].cutDependencies(); 445 initializers_ = null; 446 447 base_value_.cutDependency(); 449 base_value_ = null; 450 451 ValueDef_ref.cutDependencies(abstract_base_values_); 453 abstract_base_values_ = null; 454 455 super.cutDependencies(); 457 } 458 459 465 468 public DefinitionKind 469 def_kind() 470 { 471 return DefinitionKind.dk_Value; 472 } 473 474 480 483 public TypeCode 484 type() 485 { 486 java.util.List idSeq = new java.util.ArrayList (); 488 return recursiveType(idSeq); 489 } 490 491 497 500 public Contained 501 lookup(String search_name) 502 { 503 Contained contained = super.lookup(search_name); 505 506 if (contained == null) 507 { 508 for(int i=0; i<supported_interfaces_.length; i++) 509 { 510 contained = supported_interfaces_[i].getImpl(). 511 lookup(search_name); 512 if(contained != null) 513 break; 514 } 515 } 516 517 if (contained == null) 518 { 519 if(getBaseValue().getImpl() != null) 520 contained = getBaseValue().getImpl().lookup(search_name); 521 } 522 523 if (contained == null) 524 { 525 ValueDef_ref[] abs_refs = getAbstractBaseValues(); 526 for(int i=0; i<abs_refs.length; i++) 527 { 528 Contained contained2 = abs_refs[i].getImpl().lookup(search_name); 529 if(contained2 != null) 530 { 531 if(contained != null) 532 { 533 String id1 = contained.id(); 534 String id2 = contained2.id(); 535 if(!id1.equals(id2)) 536 throw exceptionAmbiguousLookup(id1, id2); 537 } 538 539 contained = contained2; 540 } 541 } 542 } 543 544 return contained; 545 } 546 547 553 556 public InterfaceDef[] 557 supported_interfaces() 558 { 559 return InterfaceDef_ref.computeInterfaceDefSeq(supported_interfaces_); 560 } 561 562 565 public void 566 supported_interfaces(InterfaceDef[] val) 567 { 568 InterfaceDef_impl[] itfs = new InterfaceDef_impl[val.length]; 569 for (int i=0; i<val.length; i++) 570 itfs[i] = castToLocal(val[i]); 571 572 574 InterfaceDef_ref[] refs = new InterfaceDef_ref[val.length]; 575 for (int i=0; i<val.length; i++) 576 refs[i] = new InterfaceDef_ref( this, itfs[i] ); 577 578 InterfaceDef_ref.cutDependencies(supported_interfaces_); 580 581 supported_interfaces_ = refs; 582 } 583 584 587 public Initializer[] 588 initializers() 589 { 590 Initializer[] result = new Initializer[initializers_.length]; 591 592 for(int i=0; i<result.length; i++) 593 result[i] = initializers_[i].getInitializer(); 594 595 return result; 596 } 597 598 601 public void 602 initializers(Initializer[] val) 603 { 604 Initializer_impl[] tmp = new Initializer_impl[val.length]; 605 for(int i=0; i<tmp.length; i++) 606 { 607 tmp[i] = new Initializer_impl(this); 608 tmp[i].setInitializer(val[i]); 609 } 610 initializers_ = tmp; 611 } 612 613 616 public ValueDef 617 base_value() 618 { 619 return getBaseValue().asValueDef(); 621 } 622 623 626 public void 627 base_value(ValueDef val) 628 { 629 if (val == null) 630 getBaseValue().setDependency(null); 631 else 632 { 633 getBaseValue().setDependency( castToLocal(val) ); 636 } 637 } 638 639 642 public ValueDef[] 643 abstract_base_values() 644 { 645 ValueDef_ref[] abs_refs = getAbstractBaseValues(); 646 ValueDef[] result = new ValueDef[abs_refs.length]; 647 648 for(int i=0; i<abs_refs.length; i++) 649 result[i] = abs_refs[i].asValueDef(); 650 651 return result; 652 } 653 654 657 public void 658 abstract_base_values(ValueDef[] val) 659 { 660 ValueDef_impl[] values = new ValueDef_impl[val.length]; 661 for (int i=0; i<val.length; i++) 662 values[i] = castToLocal(val[i]); 663 664 666 ValueDef_ref[] refs = new ValueDef_ref[val.length]; 667 for (int i=0; i<val.length; i++) 668 refs[i] = new ValueDef_ref( this, values[i] ); 669 670 ValueDef_ref.cutDependencies(abstract_base_values_); 672 673 abstract_base_values_ = refs; 674 } 675 676 679 public boolean 680 is_abstract() 681 { 682 return is_abstract_; 683 } 684 685 688 public void 689 is_abstract(boolean val) 690 { 691 is_abstract_ = val; 693 } 694 695 698 public boolean 699 is_custom() 700 { 701 return is_custom_; 702 } 703 704 707 public void 708 is_custom(boolean val) 709 { 710 is_custom_ = val; 712 } 713 714 717 public boolean 718 is_truncatable() 719 { 720 return is_truncatable_; 721 } 722 723 726 public void 727 is_truncatable(boolean val) 728 { 729 is_truncatable_ = val; 731 } 732 733 736 public boolean 737 is_a(String the_id) 738 { 739 if(the_id.equals(id())) 740 return true; 741 742 for(int i=0; i<supported_interfaces_.length; i++) 743 if (supported_interfaces_[i].getImpl().is_a(the_id)) 744 return true; 745 746 if(getBaseValue().getImpl() != null 747 && getBaseValue().getImpl().is_a(the_id)) 748 return true; 749 750 ValueDef_ref[] abs_refs = getAbstractBaseValues(); 751 for(int i=0; i<abs_refs.length; i++) 752 if (abs_refs[i].getImpl().is_a(the_id)) 753 return true; 754 755 return false; 756 } 757 758 761 public FullValueDescription 762 describe_value() 763 { 764 FullValueDescription description = new FullValueDescription(); 765 description.name = name(); 766 description.id = id(); 767 description.is_abstract = is_abstract(); 768 description.is_custom = is_custom(); 769 description.defined_in = getContainerID(); 770 description.version = version(); 771 description.operations = getOpDescriptionSeq(); 772 description.attributes = getAttrDescriptionSeq(); 773 description.members = getValueMemberSeq(); 774 description.initializers = initializers(); 775 description.supported_interfaces = InterfaceDef_ref. 776 computeRepositoryIdSeq(supported_interfaces_); 777 description.abstract_base_values = ValueDef_ref. 778 computeRepositoryIdSeq(getAbstractBaseValues()); 779 description.is_truncatable = is_truncatable(); 780 description.base_value = getBaseValue().getId(); 781 description.type = type(); 782 return description; 783 } 784 785 788 public ValueMemberDef 789 create_value_member(String id, 790 String name, 791 String version, 792 IDLType type, 793 short access) 794 { 795 ValueMemberDef_impl vm = new ValueMemberDef_impl(getIFR(), this); 796 797 try 798 { 799 addContained(vm, id, name, version); 800 vm.type_def(type); 801 vm.access(access); 802 } 803 catch(SystemException exc) 804 { 805 vm.destroy(); 806 throw exc; 807 } 808 809 return vm.asValueMemberDef(); 810 } 811 812 815 public AttributeDef 816 create_attribute(String id, 817 String name, 818 String version, 819 IDLType type, 820 AttributeMode mode) 821 { 822 AttributeDef_impl attr = new AttributeDef_impl(getIFR(), this); 823 824 try 825 { 826 addContained(attr, id, name, version); 827 attr.type_def(type); 828 attr.mode(mode); 829 } 830 catch(SystemException exc) 831 { 832 attr.destroy(); 833 throw exc; 834 } 835 836 return attr.asAttributeDef(); 837 } 838 839 842 public OperationDef 843 create_operation(String id, 844 String name, 845 String version, 846 IDLType result, 847 OperationMode mode, 848 ParameterDescription[] params, 849 ExceptionDef[] exceptions, 850 String [] contexts) 851 { 852 OperationDef_impl op = new OperationDef_impl(getIFR(), this); 853 854 try 855 { 856 addContained(op, id, name, version); 857 op.result_def(result); 858 op.mode(mode); 859 op.params(params); 860 op.exceptions(exceptions); 861 op.contexts(contexts); 862 } 863 catch(SystemException exc) 864 { 865 op.destroy(); 866 throw exc; 867 } 868 869 return op.asOperationDef(); 870 } 871 } 872 | Popular Tags |