1 20 package org.objectweb.modfact.corba.idl; 21 22 import org.objectweb.modfact.corba.generator.BracketGenerator; 23 import org.objectweb.modfact.corba.helper.MOFCommon; 24 import org.objectweb.modfact.corba.helper.IDLCommon; 25 import org.objectweb.modfact.corba.logging.Level; 26 import org.objectweb.modfact.corba.logging.ModFactLogger; 27 28 import org.omg.mof.Model.*; 29 import org.omg.mof.Reflective.*; 30 import java.util.Vector ; 31 32 import org.omg.CORBA.TypeCode ; 33 import org.omg.CORBA.TypeCodePackage.*; 34 35 38 public class PackageGenerator extends BracketGenerator { 39 40 private org.omg.mof.Model.Package[] input; 41 42 private MOFCommon mofHelper; 43 private IDLCommon idlHelper; 44 45 private ModFactLogger logger; 46 47 50 public void setInput(org.omg.mof.Model.ModelElement[] elt) { 51 input = new org.omg.mof.Model.Package[elt.length]; 52 for (int i = 0; i < input.length; i++) { 53 input[i] = (org.omg.mof.Model.Package) elt[i]; 54 } 55 } 56 57 60 public void setLogger(ModFactLogger log) { 61 logger = log; 62 } 63 64 67 public void generate() 68 throws MofError, NotSet, BadKind, org.omg.CORBA.TypeCodePackage.Bounds { 69 70 org.omg.mof.Model.Package _package = 71 (org.omg.mof.Model.Package) input[0]; 72 String packageName = idlHelper.format2(_package.name()); 73 74 outputln("#ifndef " + packageName + "_idl"); 75 outputln("#define " + packageName + "_idl"); 76 outputln("#include <Reflective.idl>"); 77 78 org.omg.mof.Model.Tag[] _tags = mofHelper.tagsOfPackage(_package); 79 for (int i = 0; i < _tags.length; i++) 81 tagTemplate(_tags[i]); 82 83 org.omg.mof.Model.Import[] _imports = 84 mofHelper.importsOfPackage(_package); 85 86 for (int i = 0; i < _imports.length; i++) { 88 Import _import = _imports[i]; 89 org.omg.mof.Model.Namespace importedPackage = 90 _import.imported_namespace(); 91 outputln( 92 "#include <" 93 + idlHelper.format1(importedPackage.name()) 94 + ".idl>"); 95 } 96 packageModuleTemplate(_package); 97 98 outputln("#endif"); 99 flushFile(); 100 101 } 102 103 public void packageModuleTemplate(org.omg.mof.Model.Package _package) 104 throws MofError, BadKind, org.omg.CORBA.TypeCodePackage.Bounds , NotSet { 105 106 logger.log(Level.FINE, "IDL packageModuleTemplate"); 107 if (_package.visibility().equals(VisibilityKind.public_vis)) { 108 109 111 org.omg.mof.Model.DataType[] _datatypes = 112 mofHelper.datatypesOfPackage(_package); 113 org.omg.mof.Model.Package[] _packages = 114 mofHelper.packagesOfPackage(_package); 115 org.omg.mof.Model.Class[] _classes = 116 mofHelper.classesOfPackageOrderedByInheritance(_package); 117 org.omg.mof.Model.Association[] _associations = 118 mofHelper.associationsOfPackage(_package); 119 org.omg.mof.Model.MofException[] _exceptions = 120 mofHelper.exceptionsOfPackage(_package); 121 org.omg.mof.Model.Constraint[] _constraints = 122 mofHelper.constraintsOfPackage(_package); 123 org.omg.mof.Model.Constant[] _constants = 124 mofHelper.constantsOfPackage(_package); 125 org.omg.mof.Model.Tag[] _tags = mofHelper.tagsOfPackage(_package); 126 org.omg.mof.Model.Import[] _imports = 127 mofHelper.importsOfPackage(_package); 128 129 logger.log(Level.FINE, "Cache is Ok"); 130 131 135 annotationTemplate(_package.annotation()); 137 String _packageName1 = idlHelper.format1(_package.name()); 138 outputln("module " + _packageName1 + " {"); 140 141 outputln("interface " + _packageName1 + "Package ;"); 143 144 for (int i = 0; i < _classes.length; i++) 145 classForwardDeclarationTemplate(_classes[i]); 146 logger.log(Level.FINE, _classes.length + " ClassForward are Ok"); 147 148 for (int i = 0; i < _packages.length; i++) 150 packageModuleTemplate(_packages[i]); 151 logger.log(Level.FINE, _packages.length + " PackageModule are Ok"); 152 153 for (int i = 0; i < _datatypes.length; i++) 154 dataTypeTemplate(_datatypes[i]); 155 logger.log(Level.FINE, _datatypes.length + " DataTypes are Ok"); 156 157 for (int i = 0; i < _exceptions.length; i++) 158 exceptionTemplate(_exceptions[i]); 159 logger.log(Level.FINE, _exceptions.length + " Exceptions are Ok"); 160 161 for (int i = 0; i < _classes.length; i++) 162 classTemplate(_classes[i]); 163 logger.log(Level.FINE, _classes.length + " Classes are Ok"); 164 165 for (int i = 0; i < _associations.length; i++) 166 associationTemplate(_associations[i]); 167 logger.log( 168 Level.FINE, 169 _associations.length + " Associations are Ok"); 170 171 for (int i = 0; i < _constraints.length; i++) 172 constraintTemplate(_constraints[i]); 173 logger.log(Level.FINE, _constraints.length + " Constraints are Ok"); 174 175 for (int i = 0; i < _constants.length; i++) 176 constantTemplate(_constants[i]); 177 logger.log(Level.FINE, _constants.length + " Constants are Ok"); 178 179 packageFactoryTemplate(_package); 181 logger.log(Level.FINE, "PackageFactories are Ok"); 182 183 packageTemplate(_package); 185 186 outputln("}; //end of module " + _packageName1); 187 outputln(""); 188 } else { 189 } } 191 192 public void tagTemplate(Tag tag) throws MofError { 194 if (tag.tag_id().compareTo("org.omg.mof.idl_prefix") == 0) 195 outputln( 196 "#pragma prefix \"" + tag.values()[0].extract_string() + "\""); 197 } 198 199 public void annotationTemplate(String _annotation) throws MofError { 201 logger.log(Level.FINE, "IDL annotationTemplate"); 202 outputln("//" + _annotation); 203 } 204 205 public void classForwardDeclarationTemplate(org.omg.mof.Model.Class _class) 206 throws MofError, NotSet { 207 logger.log(Level.FINE, "IDL classForwardDeclarationTemplate"); 208 if (_class.visibility().equals(VisibilityKind.public_vis)) { 209 String _classname = idlHelper.className(_class); 210 outputln("interface " + _classname + "Class;"); 211 outputln("interface " + _classname + ";"); 212 outputln( 213 "typedef sequence <" 214 + _classname 215 + "> " 216 + _classname 217 + "Set;"); 218 outputln( 219 "typedef sequence <" 220 + _classname 221 + "> " 222 + _classname 223 + "Bag;"); 224 outputln( 225 "typedef sequence <" 226 + _classname 227 + "> " 228 + _classname 229 + "List;"); 230 outputln( 231 "typedef sequence <" 232 + _classname 233 + "> " 234 + _classname 235 + "UList;"); 236 outputln(); 237 } else { 238 }; } 240 241 public void dataTypeTemplate(DataType _datatype) 242 throws MofError, BadKind, org.omg.CORBA.TypeCodePackage.Bounds { 243 logger.log(Level.FINE, "IDL dataTypeTemplate"); 244 if (_datatype.visibility().equals(VisibilityKind.public_vis)) { 245 annotationTemplate(_datatype.annotation()); 246 String _datatypename = _datatype.name(); 247 TypeCode tc = _datatype.type_code(); 248 249 if (idlHelper.isBaseType(tc)) { 250 String tcName = getBaseTypeName(tc); 252 String _idlbasename = idlBaseType(tcName); 253 outputln( 254 "typedef sequence <" 255 + tcName 256 + "> " 257 + _idlbasename 258 + "Set;"); 259 outputln( 260 "typedef sequence <" 261 + tcName 262 + "> " 263 + _idlbasename 264 + "Bag;"); 265 outputln( 266 "typedef sequence <" 267 + tcName 268 + "> " 269 + _idlbasename 270 + "List;"); 271 outputln( 272 "typedef sequence <" 273 + tcName 274 + "> " 275 + _idlbasename 276 + "UList;"); 277 278 } else { 279 String _datatypename1 = idlHelper.format1(_datatype.name()); 280 org.omg.CORBA.TypeCode _typecode = _datatype.type_code(); 281 typeCode2IDL(_typecode, 0, _datatypename); 282 for (int i = 0; i < _datatype.constraints().length; i++) { 283 constraintTemplate(_datatype.constraints()[i]); 284 } 285 outputln( 286 "typedef sequence <" 287 + _datatypename1 288 + "> " 289 + _datatypename1 290 + "Set;"); 291 outputln( 292 "typedef sequence <" 293 + _datatypename1 294 + "> " 295 + _datatypename1 296 + "Bag;"); 297 outputln( 298 "typedef sequence <" 299 + _datatypename1 300 + "> " 301 + _datatypename1 302 + "List;"); 303 outputln( 304 "typedef sequence <" 305 + _datatypename1 306 + "> " 307 + _datatypename1 308 + "UList;"); 309 310 } 311 } 312 } 313 314 public void typeCode2IDL( 315 org.omg.CORBA.TypeCode _typecode, 316 int _level, 317 String _datatypename) 318 throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds { 319 logger.log(Level.FINE, "IDL typeCode2IDL"); 320 switch (_typecode.kind().value()) { 321 case org.omg.CORBA.TCKind._tk_alias : 322 { 323 org.omg.CORBA.TypeCode _tc = _typecode.content_type(); 324 output("typedef "); 325 typeCode2IDL(_tc, 0, ""); 327 outputln(" " + idlHelper.format1(_datatypename) + " ;"); 329 break; 330 } 331 case org.omg.CORBA.TCKind._tk_struct : 332 { 333 output( 335 "struct " + idlHelper.format1(_datatypename) + "{"); 336 int _temp = _level + 1; 337 for (int i = 0; i < _typecode.member_count(); i++) { 338 typeCode2IDL( 339 _typecode.member_type(i), 340 _temp, 341 _typecode.member_name(i)); 342 output(" " + _typecode.member_name(i) + "; "); 344 } 345 output(" } "); 346 if (_level == 0) 347 outputln(";"); 348 break; 349 } 350 case org.omg.CORBA.TCKind._tk_enum : 351 { 352 output( 354 "enum " + idlHelper.format1(_datatypename) + "{"); 355 for (int i = 0; i < _typecode.member_count(); i++) { 356 output(_typecode.member_name(i)); 357 if (!(i == (_typecode.member_count() - 1))) 358 output(", "); 359 } 360 output(" } "); 361 if (_level == 0) 362 outputln(";"); 363 break; 364 } 365 case org.omg.CORBA.TCKind._tk_sequence : 366 { 367 org.omg.CORBA.TypeCode _tc = _typecode.content_type(); 368 output("typedef sequence <"); 369 int _temp = _level + 1; 370 typeCode2IDL(_tc, _temp, ""); 371 if (_typecode.length() > 1) 372 output(" ," + String.valueOf(_typecode.length()) + ">"); 373 else 374 output(">"); 375 if (_level == 0) 376 outputln(" " + idlHelper.format1(_datatypename) + ";"); 377 break; 378 } 379 default : 380 typeCode2IDLBase(_typecode); 381 } 382 } 383 384 public void typeCode2IDLBase(org.omg.CORBA.TypeCode _typecode) 385 throws BadKind { 386 logger.log(Level.FINE, "IDL typeCode2IDLBase"); 387 switch (_typecode.kind().value()) { 388 case org.omg.CORBA.TCKind._tk_boolean : 389 { 390 output("boolean"); 391 break; 392 } 393 case org.omg.CORBA.TCKind._tk_octet : 394 { 395 output("octet"); 396 break; 397 } 398 case org.omg.CORBA.TCKind._tk_char : 399 { 400 output("char"); 401 break; 402 } 403 case org.omg.CORBA.TCKind._tk_wchar : 404 { 405 output("wchar"); 406 break; 407 } 408 case org.omg.CORBA.TCKind._tk_short : 409 { 410 output("short"); 411 break; 412 } 413 case org.omg.CORBA.TCKind._tk_ushort : 414 { 415 output("unsigned short"); 416 break; 417 } 418 case org.omg.CORBA.TCKind._tk_long : 419 { 420 output("long"); 421 break; 422 } 423 case org.omg.CORBA.TCKind._tk_ulong : 424 { 425 output("unsigned long"); 426 break; 427 } 428 case org.omg.CORBA.TCKind._tk_longlong : 429 { 430 output("long long"); 431 break; 432 } 433 case org.omg.CORBA.TCKind._tk_ulonglong : 434 { 435 output("unsigned long long"); 436 break; 437 } 438 case org.omg.CORBA.TCKind._tk_double : 439 { 440 output("double"); 441 break; 442 } 443 case org.omg.CORBA.TCKind._tk_float : 444 { 445 output("float"); 446 break; 447 } 448 case org.omg.CORBA.TCKind._tk_string : 449 { 450 output("string"); 451 break; 452 } 453 case org.omg.CORBA.TCKind._tk_wstring : 454 { 455 output("wstring"); 456 break; 457 } 458 case org.omg.CORBA.TCKind._tk_TypeCode : 459 { 460 output("CORBA::TypeCode"); 461 break; 462 } 463 case org.omg.CORBA.TCKind._tk_any : 464 { 465 output("any"); 466 break; 467 } 468 case org.omg.CORBA.TCKind._tk_objref : 469 { 470 output("Object"); 471 break; 472 } 473 default : 474 throw new BadKind(); 475 } 476 } 477 478 public String getBaseTypeName(org.omg.CORBA.TypeCode _typecode) 479 throws BadKind { 480 logger.log(Level.FINE, "IDL typeCode2IDLBase"); 481 switch (_typecode.kind().value()) { 482 case org.omg.CORBA.TCKind._tk_boolean : 483 { 484 return "boolean"; 485 } 486 case org.omg.CORBA.TCKind._tk_octet : 487 { 488 return "octet"; 489 } 490 case org.omg.CORBA.TCKind._tk_char : 491 { 492 return "char"; 493 } 494 case org.omg.CORBA.TCKind._tk_wchar : 495 { 496 return "wchar"; 497 } 498 case org.omg.CORBA.TCKind._tk_short : 499 { 500 return "short"; 501 } 502 case org.omg.CORBA.TCKind._tk_ushort : 503 { 504 return "unsigned short"; 505 } 506 case org.omg.CORBA.TCKind._tk_long : 507 { 508 return "long"; 509 } 510 case org.omg.CORBA.TCKind._tk_ulong : 511 { 512 return "unsigned long"; 513 } 514 case org.omg.CORBA.TCKind._tk_longlong : 515 { 516 return "long long"; 517 } 518 case org.omg.CORBA.TCKind._tk_ulonglong : 519 { 520 return "unsigned long long"; 521 } 522 case org.omg.CORBA.TCKind._tk_double : 523 { 524 return "double"; 525 } 526 case org.omg.CORBA.TCKind._tk_float : 527 { 528 return "float"; 529 } 530 case org.omg.CORBA.TCKind._tk_string : 531 { 532 return "string"; 533 } 534 case org.omg.CORBA.TCKind._tk_wstring : 535 { 536 return "wstring"; 537 } 538 case org.omg.CORBA.TCKind._tk_TypeCode : 539 { 540 return "CORBA::TypeCode"; 541 } 542 case org.omg.CORBA.TCKind._tk_any : 543 { 544 return "any"; 545 } 546 case org.omg.CORBA.TCKind._tk_objref : 547 { 548 return "Object"; 549 } 550 default : 551 throw new BadKind(); 552 } 553 } 554 555 557 public String idlBaseType(String _in) { 558 logger.log(Level.FINE, "IDL idlBaseType"); 559 if (_in.compareToIgnoreCase("boolean") == 0) 560 return "Boolean"; 561 else if (_in.compareToIgnoreCase("octet") == 0) 562 return "Octet"; 563 else if (_in.compareToIgnoreCase("char") == 0) 564 return "Char"; 565 else if (_in.compareToIgnoreCase("wchar") == 0) 566 return "WChar"; 567 else if (_in.compareToIgnoreCase("short") == 0) 568 return "Short"; 569 else if (_in.compareToIgnoreCase("unsigned short") == 0) 570 return "UShort"; 571 else if (_in.compareToIgnoreCase("long") == 0) 572 return "Long"; 573 else if (_in.compareToIgnoreCase("unsigned long") == 0) 574 return "ULong"; 575 else if (_in.compareToIgnoreCase("long long") == 0) 576 return "LLong"; 577 else if (_in.compareToIgnoreCase("unsigned long long") == 0) 578 return "ULLong"; 579 else if (_in.compareToIgnoreCase("double") == 0) 580 return "Double"; 581 else if (_in.compareToIgnoreCase("float") == 0) 582 return "Float"; 583 else if (_in.compareToIgnoreCase("string") == 0) 584 return "String"; 585 else if (_in.compareToIgnoreCase("wstring") == 0) 586 return "WString"; 587 else if (_in.compareToIgnoreCase("any") == 0) 588 return "Any"; 589 else if (_in.compareToIgnoreCase("CORBA::TypeCode") == 0) 590 return "TypeCode"; 591 else if (_in.compareToIgnoreCase("Object") == 0) 592 return "Object"; 593 else 594 return _in; 595 } 596 597 public String idlType(Classifier _classifier) 598 throws MofError, BadKind, Bounds, NotSet { 599 logger.log(Level.FINE, "IDL idlType"); 600 String resu = null; 601 if (_classifier._is_a(DataTypeHelper.id())) { 602 DataType dt = DataTypeHelper.narrow(_classifier); 604 TypeCode tc = dt.type_code(); 605 if (idlHelper.isBaseType(tc)) 606 resu = getBaseTypeName(tc); 607 else { 608 Namespace container = dt.container(); 610 if (container._is_a(ClassHelper.id())) { resu = 612 idlHelper.qualifiedName(container) 613 + "Class::" 614 + idlHelper.format1(dt.name()); 615 } else 616 resu = idlHelper.qualifiedName(_classifier); 617 } 618 } else { 619 resu = idlHelper.qualifiedName(_classifier); 620 } 621 return resu; 622 } 623 624 public void exceptionTemplate(MofException _exception) 625 throws MofError, BadKind, Bounds, NotSet { 626 logger.log(Level.FINE, "IDL exceptionTemplate"); 627 if (_exception.visibility().equals(VisibilityKind.public_vis)) { 628 String _exceptionname = idlHelper.format1(_exception.name()); 629 annotationTemplate(_exception.annotation()); 630 outputln("exception " + _exceptionname + " {"); 631 for (int i = 0; i < _exception.contents().length; i++) { 632 Parameter _parameter = 633 ParameterHelper.narrow(_exception.contents()[i]); 634 output(idlBaseType(idlType(_parameter.type()))); 635 if ((_parameter.multiplicity().upper > 1) 636 || (_parameter.multiplicity().upper == -1)) { 637 if (_parameter.multiplicity().isOrdered) { 638 if (_parameter.multiplicity().isUnique) { 639 output("UList"); 640 } else { 641 output("List"); 642 } 643 } else { 644 if (_parameter.multiplicity().isUnique) { 645 output("Set"); 646 } else { 647 output("Bag"); 648 } 649 } 650 } 651 output(" " + idlHelper.format1(_parameter.name()) + " ;"); 652 653 } 654 outputln("} ;"); 655 } 656 } 657 658 public void classTemplate(org.omg.mof.Model.Class _class) 660 throws MofError, BadKind, org.omg.CORBA.TypeCodePackage.Bounds , NotSet { 661 662 logger.log(Level.FINE, "IDL classTemplate"); 663 if (_class.visibility().equals(VisibilityKind.public_vis)) { 664 annotationTemplate(_class.annotation()); 665 classProxyTemplate(_class); 666 instanceTemplate(_class); 667 } 668 } 669 public void associationTemplate(Association _association) 670 throws MofError, BadKind, Bounds, NotSet { 671 672 logger.log(Level.FINE, "IDL associationTemplate"); 673 if (_association.visibility().equals(VisibilityKind.public_vis)) { 674 String _associationformat1 = idlHelper.format1(_association.name()); 675 String _associationformat2 = idlHelper.format2(_association.name()); 676 677 AssociationEnd[] _ends = 678 mofHelper.associationEndsOfAssociation(_association); 679 680 AssociationEnd _source = _ends[0]; 682 String _sourceformat1 = idlType(_source.type()); 683 String _sourceformat2 = idlHelper.format2(_source.name()); 684 String _sourceformat2IdlConflict = idlHelper.format2IdlConflict(_source.name()); 685 MultiplicityType _multiplicity_source = _source.multiplicity(); 686 int _upper_source = _multiplicity_source.upper; 687 int _lower_source = _multiplicity_source.lower; 688 boolean _is_ordered_source = _multiplicity_source.isOrdered; 689 boolean _is_unique_source = _multiplicity_source.isUnique; 690 boolean _is_changeable_source = _source.is_changeable(); 691 boolean _is_navigable_source = _source.is_navigable(); 692 693 AssociationEnd _dest = _ends[1]; 695 String _destformat1 = idlType(_dest.type()); 696 String _destformat2 = idlHelper.format2(_dest.name()); 697 String _destformat2IdlConflict = idlHelper.format2IdlConflict(_dest.name()); 698 MultiplicityType _multiplicity_dest = _dest.multiplicity(); 699 int _upper_dest = _multiplicity_dest.upper; 700 int _lower_dest = _multiplicity_dest.lower; 701 boolean _is_ordered_dest = _multiplicity_dest.isOrdered; 702 boolean _is_unique_dest = _multiplicity_dest.isUnique; 703 boolean _is_changeable_dest = _dest.is_changeable(); 704 boolean _is_navigable_dest = _dest.is_navigable(); 705 706 outputln("struct " + _associationformat1 + "Link {"); 708 outputln(_sourceformat1 + " " + _sourceformat2IdlConflict + "; "); 709 outputln(_destformat1 + " " + _destformat2IdlConflict + "; "); 710 outputln("};"); 711 712 outputln( 713 "typedef sequence " 714 + "<" 715 + _associationformat1 716 + "Link> " 717 + _associationformat1 718 + "LinkSet;"); 719 720 annotationTemplate(_association.annotation()); 721 outputln( 722 "interface " 723 + _associationformat1 724 + ":Reflective::RefAssociation {"); 725 outputln( 726 _associationformat1 727 + "LinkSet all_" 728 + _associationformat2 729 + "_Links () raises (Reflective::MofError) ;"); 730 output("boolean exists ("); 731 output("in " + _sourceformat1 + " " + _sourceformat2IdlConflict + ", "); 732 output("in " + _destformat1 + " " + _destformat2IdlConflict + ")"); 733 outputln("raises (Reflective::MofError);"); 734 735 if (_is_navigable_source) { 736 if ((_upper_source > 1) || (_upper_source == -1)) { 737 output(idlBaseType(_sourceformat1)); 739 if ((_is_unique_source) && (_is_ordered_source)) { 740 output("UList "); 741 } else { 742 if (_is_ordered_source) { 743 output("List "); 744 } else { 745 if (_is_unique_source) { 746 output("Set "); 747 } else 748 output("Bag "); 749 } 750 } 751 } else { 752 output(_sourceformat1 + " "); 753 } 754 outputln( 755 _sourceformat2IdlConflict 756 + "(in " 757 + _destformat1 758 + " " 759 + _destformat2IdlConflict 760 + ") raises (Reflective::MofError);"); 761 } 762 if (_is_navigable_dest) { 763 if ((_upper_dest > 1) || (_upper_dest == -1)) { 764 output(idlBaseType(_destformat1)); 766 if ((_is_unique_dest) && (_is_ordered_dest)) { 767 output("UList "); 768 } else { 769 if (_is_ordered_dest) { 770 output("List "); 771 } else { 772 if (_is_unique_dest) { 773 output("Set "); 774 } else 775 output("Bag "); 776 } 777 } 778 } else { 779 output(_destformat1 + " "); 780 } 781 outputln( 782 _destformat2IdlConflict 783 + "(in " 784 + _sourceformat1 785 + " " 786 + _sourceformat2IdlConflict 787 + ") raises (Reflective::MofError);"); 788 } 789 790 if (_is_changeable_source && _is_changeable_dest) { 791 outputln( 792 "void add ( in " 793 + _sourceformat1 794 + " " 795 + _sourceformat2IdlConflict 796 + ", in " 797 + _destformat1 798 + " " 799 + _destformat2IdlConflict 800 + ") raises (Reflective::MofError);"); 801 } 802 if (_is_changeable_source 803 && _is_navigable_source 804 && _is_changeable_dest 805 && ((_upper_source > 1) || (_upper_source == -1)) 806 && _is_ordered_source) { 807 outputln( 808 "void add_before_" 809 + _sourceformat2 810 + "( in " 811 + _sourceformat1 812 + " " 813 + _sourceformat2IdlConflict 814 + ", in " 815 + _destformat1 816 + " " 817 + _destformat2IdlConflict 818 + ", in " 819 + _sourceformat1 820 + " before) raises (Reflective::NotFound, Reflective::MofError);"); 821 } 822 if (_is_changeable_dest 823 && _is_navigable_dest 824 && _is_changeable_source 825 && ((_upper_dest > 1) || (_upper_dest == -1)) 826 && _is_ordered_dest) { 827 outputln( 828 "void add_before_" 829 + _destformat2 830 + "( in " 831 + _sourceformat1 832 + " " 833 + _sourceformat2IdlConflict 834 + ", in " 835 + _destformat1 836 + " " 837 + _destformat2IdlConflict 838 + ", in " 839 + _destformat1 840 + " before) raises (Reflective::NotFound, Reflective::MofError);"); 841 } 842 if (_is_navigable_source && _is_changeable_source) { 843 outputln( 844 "void modify_" 845 + _sourceformat2 846 + " ( in " 847 + _sourceformat1 848 + " " 849 + _sourceformat2IdlConflict 850 + ", in " 851 + _destformat1 852 + " " 853 + _destformat2IdlConflict 854 + ", in " 855 + _sourceformat1 856 + " new_" 857 + _sourceformat2 858 + ") raises (Reflective::NotFound, Reflective::MofError);"); 859 } 860 if (_is_navigable_dest && _is_changeable_dest) { 861 outputln( 862 "void modify_" 863 + _destformat2 864 + " ( in " 865 + _sourceformat1 866 + " " 867 + _sourceformat2IdlConflict 868 + ", in " 869 + _destformat1 870 + " " 871 + _destformat2IdlConflict 872 + ", in " 873 + _destformat1 874 + " new_" 875 + _destformat2 876 + ") raises (Reflective::NotFound, Reflective::MofError);"); 877 } 878 if (_is_changeable_source && _is_changeable_dest) { 879 outputln( 880 "void remove ( in " 881 + _sourceformat1 882 + " " 883 + _sourceformat2IdlConflict 884 + ", in " 885 + _destformat1 886 + " " 887 + _destformat2IdlConflict 888 + ") raises (Reflective::NotFound, Reflective::MofError);"); 889 } 890 outputln("}; // end of interface " + _associationformat1); 891 } 892 outputln(); 893 } 894 895 public void constraintTemplate(Constraint _constraint) throws MofError { 896 logger.log(Level.FINE, "IDL constraintTemplate"); 897 annotationTemplate(_constraint.annotation()); 898 outputln( 899 "const string " + idlHelper.format3(_constraint.name())); 900 } 901 902 public void constantTemplate(Constant _constant) 904 throws BadKind, MofError, Bounds, NotSet { 905 annotationTemplate(_constant.annotation()); 906 org.omg.CORBA.Any _value = _constant.value(); 907 int _tk = _value.type().kind().value(); 908 output( 909 "const " 910 + idlType(_constant.type()) 911 + " " 912 + idlHelper.format3(_constant.name()) 913 + " = "); 914 if ((_tk == org.omg.CORBA.TCKind._tk_char) 915 || (_tk == org.omg.CORBA.TCKind._tk_wchar) 916 || (_tk == org.omg.CORBA.TCKind._tk_string) 917 || (_tk == org.omg.CORBA.TCKind._tk_wstring)) { 918 output("\"" + mofHelper.valueOfConstant(_value) + "\""); 919 } else 920 output(mofHelper.valueOfConstant(_value)); 921 outputln(" ;"); 922 } 923 924 public void packageFactoryTemplate(org.omg.mof.Model.Package _package) 925 throws MofError, BadKind, Bounds, NotSet { 926 logger.log(Level.FINE, "IDL packageFactoryTemplate"); 927 928 String _packageformat1 = idlHelper.format1(_package.name()); 929 String _packageformat2 = idlHelper.format2(_package.name()); 930 931 org.omg.mof.Model.Class[] orderedClasses = 933 mofHelper.classesOfPackage(_package); 934 935 937 Vector attributes = new Vector (); 938 939 for (int i = 0; i < orderedClasses.length; i++) { 940 941 943 947 org.omg.mof.Model.MofAttribute[] attributes_temp = 948 mofHelper.allAttributesOfClass( 949 orderedClasses[i], 950 ScopeKind.classifier_level, 951 false); 952 953 for (int j = 0; j < attributes_temp.length; j++) { 954 attributes.addElement(attributes_temp[j]); 955 } 956 } 957 958 outputln("interface " + _packageformat1 + "PackageFactory {"); 959 output( 960 _packageformat1 961 + "Package create_" 962 + _packageformat2 963 + "_package("); 964 965 for (int i = 0; i < attributes.size(); i++) { 967 MofAttribute _current = (MofAttribute) attributes.elementAt(i); 968 String _currentformat1 = idlType(_current.type()); 969 String _attributeqname = " "; 970 String [] _qualified_name = _current.qualified_name(); 971 for (int j = 0; j < _qualified_name.length; j++) { 972 if (j > 0) 973 _attributeqname = 974 idlHelper.format2(_qualified_name[j]) 975 + "_" 976 + _attributeqname; 977 else 978 _attributeqname = idlHelper.format2(_qualified_name[j]); 979 } 980 981 if (!((i != 0) || (i != (attributes.size() - 1)))) 982 outputln(", "); 983 984 if ((_current.multiplicity().upper > 1) 985 || (_current.multiplicity().upper == -1)) { 986 987 output(idlBaseType(_currentformat1)); 988 if ((_current.multiplicity().isUnique) 989 && (_current.multiplicity().isOrdered)) { 990 output("UList " + _attributeqname); 991 } else { 992 if (_current.multiplicity().isOrdered) { 993 output("List " + _attributeqname); 994 } else { 995 if (_current.multiplicity().isUnique) { 996 output("Set " + _attributeqname); 997 } else 998 output("Bag " + _attributeqname); 999 } 1000 } 1001 } else { 1002 output(_currentformat1 + " " + _attributeqname); 1003 } 1004 } 1005 outputln(") raises (Reflective::MofError);"); 1006 outputln("}; "); 1007 } 1008 1009 public void packageTemplate(org.omg.mof.Model.Package _package) 1011 throws MofError, NotSet { 1012 1013 logger.log(Level.FINE, "IDL packageTemplate"); 1014 String _pformat1 = idlHelper.format1(_package.name()); 1015 String _pformat2 = idlHelper.format2(_package.name()); 1016 1017 output("interface " + _pformat1 + "Package :"); 1018 1019 if (_package.all_supertypes().length == 0) 1020 outputln("Reflective::RefPackage {"); 1021 1022 1026 org.omg.mof.Model.Import[] imports = 1027 mofHelper.importsOfPackage(_package); 1028 org.omg.mof.Model.Package[] packages = 1029 mofHelper.packagesOfPackage(_package); 1030 org.omg.mof.Model.Class[] classes = 1031 mofHelper.classesOfPackage(_package); 1032 org.omg.mof.Model.Association[] associations = 1033 mofHelper.associationsOfPackage(_package); 1034 1035 for (int i = 0; i < imports.length; i++) { 1036 Import _import = imports[i]; 1037 Namespace imported = _import.imported_namespace(); 1038 if (imported._is_a(PackageHelper.id())) { 1039 org.omg.mof.Model.Package cluteredPackage = 1040 PackageHelper.narrow(imported); 1041 if ((_import.visibility().equals(VisibilityKind.public_vis)) 1042 && (_import.is_clustered()) 1043 && (cluteredPackage 1044 .visibility() 1045 .equals(VisibilityKind.public_vis))) 1046 outputln( 1047 "readonly attribute ::" 1048 + idlHelper.qualifiedName(cluteredPackage) 1049 + "::" 1050 + idlHelper.format1(cluteredPackage.name()) 1051 + "Package " 1052 + idlHelper.format2(cluteredPackage.name()) 1053 + "_ref;"); 1054 } 1055 } 1056 for (int i = 0; i < packages.length; i++) { 1057 org.omg.mof.Model.Package nestedPackage = packages[i]; 1058 if (nestedPackage.visibility().equals(VisibilityKind.public_vis)) { 1059 String nestedName = idlHelper.format1(nestedPackage.name()); 1060 outputln( 1061 "readonly attribute " 1062 + idlHelper.qualifiedName(nestedPackage) 1063 + "::" 1064 + nestedName 1065 + "Package " 1066 + idlHelper.format2(nestedPackage.name()) 1067 + "_ref;"); 1068 1069 } 1070 } 1071 for (int i = 0; i < classes.length; i++) { 1072 org.omg.mof.Model.Class _class = classes[i]; 1073 if (_class.visibility().equals(VisibilityKind.public_vis)) 1074 outputln( 1075 "readonly attribute " 1076 + idlHelper.className(_class) 1077 + "Class " 1078 + idlHelper.format2(idlHelper.className(_class)) 1079 + "_ref;"); 1080 } 1081 for (int i = 0; i < associations.length; i++) { 1082 Association association = associations[i]; 1083 if (association.visibility().equals(VisibilityKind.public_vis)) 1084 outputln( 1085 "readonly attribute " 1086 + idlHelper.format1(association.name()) 1087 + " " 1088 + idlHelper.format2(association.name()) 1089 + "_ref;"); 1090 } 1091 1092 outputln("};"); 1093 } 1094 1095 public void classProxyTemplate(org.omg.mof.Model.Class _class) 1096 throws MofError, BadKind, org.omg.CORBA.TypeCodePackage.Bounds , NotSet { 1097 1098 logger.log(Level.FINE, "IDL classProxyTemplate"); 1099 String _cformat1 = idlHelper.className(_class); 1100 String _cformat2 = idlHelper.format2(idlHelper.className(_class)); 1101 1102 outputln(); 1103 output("interface " + _cformat1 + "Class :"); 1104 1105 GeneralizableElement[] supertypes = _class.supertypes(); 1106 1107 if (supertypes.length == 0) 1108 output("Reflective::RefObject"); 1109 else { 1110 for (int i = 0; i < supertypes.length; i++) { 1111 org.omg.mof.Model.Class _temp = 1112 ClassHelper.narrow(supertypes[i]); 1113 output(idlType(_temp) + "Class "); 1114 if (i != (supertypes.length - 1)) 1115 output(", "); 1116 } 1117 } 1118 outputln("{ "); 1119 outputln( 1120 "readonly attribute " 1121 + _cformat1 1122 + "Set all_of_type_" 1123 + _cformat2 1124 + " ;"); 1125 if (!_class.is_abstract()) { 1126 outputln( 1127 "readonly attribute " 1128 + _cformat1 1129 + "Set all_of_class_" 1130 + _cformat2 1131 + " ;"); 1132 } 1133 1134 1136 Constant[] _constants = mofHelper.constantsOfClass(_class); 1137 DataType[] _datatypes = mofHelper.datatypesOfClass(_class); 1138 MofException[] _exceptions = mofHelper.exceptionsOfClass(_class); 1139 Constraint[] _constraints = mofHelper.constraintsOfClass(_class); 1140 MofAttribute[] _attributes_cl = 1141 mofHelper.allAttributesOfClass( 1142 _class, 1143 ScopeKind.classifier_level, 1144 true); 1145 Operation[] _operations_cl = 1146 mofHelper.allOperationsOfClass(_class, ScopeKind.classifier_level); 1147 1154 for (int i = 0; i < _constants.length; i++) 1155 constantTemplate(_constants[i]); 1156 1157 for (int i = 0; i < _datatypes.length; i++) 1158 dataTypeTemplate(_datatypes[i]); 1159 1160 for (int i = 0; i < _exceptions.length; i++) 1161 exceptionTemplate(_exceptions[i]); 1162 1163 for (int i = 0; i < _constraints.length; i++) 1164 constraintTemplate(_constraints[i]); 1165 1166 for (int i = 0; i < _attributes_cl.length; i++) 1167 attributeTemplate(_attributes_cl[i]); 1168 1169 for (int i = 0; i < _operations_cl.length; i++) 1170 operationTemplate(_operations_cl[i]); 1171 1172 if (!_class.is_abstract()) 1174 classCreateTemplate(_class); 1175 outputln("} ; // end of interface " + _cformat1 + "Class"); 1176 outputln(); 1177 } 1178 1179 public void instanceTemplate(org.omg.mof.Model.Class _class) 1181 throws MofError, BadKind, Bounds, NotSet { 1182 1183 logger.log(Level.FINE, "IDL instanceTemplate"); 1184 String _cformat1 = idlHelper.className(_class); 1186 1188 output("interface " + _cformat1 + ": " + _cformat1 + "Class"); 1189 1190 GeneralizableElement[] supertypes = _class.supertypes(); 1191 1192 for (int i = 0; i < supertypes.length; i++) { 1193 org.omg.mof.Model.Class _temp = ClassHelper.narrow(supertypes[i]); 1194 output(", "); 1196 output(idlType(_temp)); 1197 } 1198 1199 outputln("{"); 1200 1201 1203 MofAttribute[] _attributes_inst = 1204 mofHelper.attributesOfClass(_class, ScopeKind.instance_level, true); 1205 Operation[] _operations_inst = 1206 mofHelper.operationsOfClass(_class, ScopeKind.instance_level); 1207 Reference[] _references = mofHelper.referencesOfClass(_class); 1208 1212 for (int i = 0; i < _attributes_inst.length; i++) 1213 attributeTemplate(_attributes_inst[i]); 1214 1215 for (int i = 0; i < _operations_inst.length; i++) 1216 operationTemplate(_operations_inst[i]); 1217 1218 for (int i = 0; i < _references.length; i++) 1219 referenceTemplate(_references[i]); 1220 1221 outputln("} ; // end of interface " + _cformat1); 1222 } 1223 1224 public void attributeTemplate(MofAttribute _attribute) 1225 throws MofError, BadKind, Bounds, NotSet { 1226 1227 logger.log(Level.FINE, "IDL attributeTemplate"); 1228 if (_attribute.visibility().equals(VisibilityKind.public_vis)) { 1229 annotationTemplate(_attribute.annotation()); 1230 String _aformat1 = idlType(_attribute.type()); 1231 String _aformat2 = idlHelper.format2(_attribute.name()); 1232 String _aformat2IdlConflict = idlHelper.format2IdlConflict(_attribute.name()); 1233 String _qualifiedName = idlHelper.qualifiedName(_attribute.type().container()); 1234 MultiplicityType _multiplicity = _attribute.multiplicity(); 1235 int _upper = _multiplicity.upper; 1236 int _lower = _multiplicity.lower; 1237 boolean _is_ordered = _multiplicity.isOrdered; 1238 boolean _is_unique = _multiplicity.isUnique; 1239 boolean _is_changeable = _attribute.is_changeable(); 1240 boolean _is_derived = _attribute.is_derived(); 1241 1242 String _aformat1_qn = idlHelper.format1(_aformat1); 1243 if (!_attribute.type().container()._is_equivalent(input[0]) 1244 && ((_upper > 1) || (_upper == -1)) 1245 && (_aformat1.indexOf("::") == -1)) 1246 _aformat1_qn = _qualifiedName + "::" + idlHelper.format1(_aformat1); 1247 1248 if ((_lower == 0) && (_upper == 1)) 1249 outputln( 1250 _aformat1 1251 + " " 1252 + _aformat2IdlConflict 1253 + "() raises (Reflective::NotSet, Reflective::MofError); "); 1254 if ((_lower == 1) && (_upper == 1)) 1255 outputln( 1256 _aformat1 1257 + " " 1258 + _aformat2IdlConflict 1259 + "() raises (Reflective::MofError); "); 1260 if ((_upper > 1) || (_upper == -1)) { 1261 output(_aformat1_qn); 1264 if (_is_unique && _is_ordered) { 1265 output("UList " + _aformat2IdlConflict); 1266 } else { 1267 if (_is_ordered) { 1268 output("List " + _aformat2IdlConflict); 1269 } else { 1270 if (_is_unique) { 1271 output("Set " + _aformat2IdlConflict); 1272 } else 1273 output("Bag " + _aformat2IdlConflict); 1274 } 1275 } 1276 outputln("() raises (Reflective::MofError); "); 1277 } 1278 if ((_upper == 1) && (_is_changeable)) 1279 outputln( 1280 "void set_" 1281 + _aformat2 1282 + " (in " 1283 + _aformat1 1284 + " new_value) raises (Reflective::MofError); "); 1285 if (((_upper > 1) || (_upper == -1)) && (_is_changeable)) { 1286 output("void set_" + _aformat2 + " (in "); 1287 output(_aformat1_qn); 1290 if (_is_unique && _is_ordered) { 1291 output("UList "); 1292 } else { 1293 if (_is_ordered) { 1294 output("List "); 1295 } else { 1296 if (_is_unique) { 1297 output("Set "); 1298 } else 1299 output("Bag "); 1300 } 1301 } 1302 outputln(" new_value) raises (Reflective::MofError); "); 1303 } 1304 if ((_lower == 0) && (_upper == 1) && (_is_changeable)) 1305 outputln( 1306 "void unset_" 1307 + _aformat2 1308 + " () raises (Reflective::MofError); "); 1309 if ((_upper > 1) || (_upper == -1) && (_is_changeable)) 1310 outputln( 1311 "void add_" 1312 + _aformat2 1313 + " (in " 1314 + _aformat1 1315 + " new_element) raises (Reflective::MofError); "); 1316 if ((_upper > 1) 1317 || (_upper == -1) 1318 && (_is_changeable) 1319 && (_is_ordered)) 1320 outputln( 1321 "void add_" 1322 + _aformat2 1323 + "_before ( in " 1324 + _aformat1 1325 + " new_element, in " 1326 + _aformat1 1327 + " before_element) raises (Reflective::NotFound, Reflective::MofError); "); 1328 if ((_upper > 1) 1329 || (_upper == -1) 1330 && (_is_changeable) 1331 && (_is_ordered) 1332 && (!_multiplicity.isUnique)) 1333 outputln( 1334 "void add_" 1335 + _aformat2 1336 + "_at (in " 1337 + _aformat1 1338 + " new_element, in unsigned long position) raises (Reflective::BadPosition, Reflective::MofError); "); 1339 if ((_upper > 1) || (_upper == -1) && (_is_changeable)) 1340 outputln( 1341 "void modify_" 1342 + _aformat2 1343 + " (in " 1344 + _aformat1 1345 + " old_element, in " 1346 + _aformat1 1347 + " new_element) raises (Reflective::NotFound, Reflective::MofError); "); 1348 if ((_upper > 1) 1349 || (_upper == -1) 1350 && (_is_changeable) 1351 && (_is_ordered) 1352 && (!_is_unique)) 1353 outputln( 1354 "void modify_" 1355 + _aformat2 1356 + "_at (in " 1357 + _aformat1 1358 + " new_element, in unsigned long position) raises (Reflective::BadPosition, Reflective::MofError); "); 1359 if ((_upper > 1) 1360 || (_upper == -1) 1361 && (_upper != _lower) 1362 && (_is_changeable)) 1363 outputln( 1364 "void remove_" 1365 + _aformat2 1366 + " (in " 1367 + _aformat1 1368 + " old_element ) raises (Reflective::NotFound, Reflective::MofError); "); 1369 if ((_upper > 1) 1370 || (_upper == -1) 1371 && (_upper != _lower) 1372 && (_is_changeable) 1373 && (_is_ordered) 1374 && (!_is_unique)) 1375 outputln( 1376 "void remove_" 1377 + _aformat2 1378 + "_at (in unsigned long position) raises (Reflective::BadPosition, Reflective::MofError); "); 1379 } 1380 } 1381 1382 public void operationTemplate(Operation _operation) 1383 throws MofError, BadKind, Bounds, NotSet { 1384 1385 logger.log(Level.FINE, "IDL operationTemplate"); 1386 1387 if (_operation.visibility().equals(VisibilityKind.public_vis)) { 1388 String _oformat2 = idlHelper.format2IdlConflict(_operation.name()); 1390 annotationTemplate(_operation.annotation()); 1391 1392 ModelElement[] _contents = _operation.contents(); 1394 1395 boolean bool = false; 1397 int j = 0; 1398 while (!bool && (j < _contents.length)) { 1399 Parameter _parameter = ParameterHelper.narrow(_contents[j]); 1400 if ((_parameter.direction()) 1401 .equals(DirectionKind.return_dir)) { 1402 bool = true; 1403 String _typeparameter = idlType(_parameter.type()); 1404 MultiplicityType _multiplicity = _parameter.multiplicity(); 1405 boolean _is_unique = _multiplicity.isUnique; 1406 boolean _is_ordered = _multiplicity.isOrdered; 1407 if ((_multiplicity.upper > 1) 1408 || (_multiplicity.upper == -1)) { 1409 output(idlBaseType(_typeparameter)); 1410 if ((_is_unique) && (_is_ordered)) { 1411 output("UList " + _oformat2 + " ("); 1412 } else { 1413 if (_is_ordered) { 1414 output("List " + _oformat2 + " ("); 1415 } else { 1416 if (_is_unique) { 1417 output("Set " + _oformat2 + " ("); 1418 } else 1419 output("Bag " + _oformat2 + " ("); 1420 } 1421 } 1422 } else 1423 output( 1424 _typeparameter + " " + _oformat2 + " ("); 1425 } 1426 j++; 1427 } 1428 if (!bool) { 1429 output("void " + _oformat2 + " ("); 1430 } 1431 1432 for (int i = 0; i < _contents.length; i++) { 1434 Parameter _parameter = ParameterHelper.narrow(_contents[i]); 1435 1436 if (!(_parameter 1437 .direction() 1438 .equals(DirectionKind.return_dir))) { 1439 1440 String _pformat2 = idlHelper.format2IdlConflict(_parameter.name()); 1443 String _typeparameter = idlType(_parameter.type()); 1444 MultiplicityType _multiplicity = _parameter.multiplicity(); 1445 int _upper = _multiplicity.upper; 1446 int _lower = _multiplicity.lower; 1447 boolean _is_unique = _multiplicity.isUnique; 1448 boolean _is_ordered = _multiplicity.isOrdered; 1449 DirectionKind _direction = _parameter.direction(); 1450 1451 if (_direction.equals(DirectionKind.in_dir)) 1453 output("in "); 1454 else if (_direction.equals(DirectionKind.out_dir)) 1455 output("out "); 1456 else if (_direction.equals(DirectionKind.inout_dir)) 1457 output("inout "); 1458 1459 if ((_upper > 1) || (_upper == -1)) { 1460 output(idlBaseType(_typeparameter)); 1461 if ((_is_unique) && (_is_ordered)) { 1462 output("UList " + _pformat2); 1463 } else { 1464 if (_is_ordered) { 1465 output("List " + _pformat2); 1466 } else { 1467 if (_is_unique) { 1468 output("Set " + _pformat2); 1469 } else 1470 output("Bag " + _pformat2); 1471 } 1472 } 1473 } else 1474 output(_typeparameter + " " + _pformat2); 1475 if (i != (_contents.length - 1)) 1476 outputln(" ,"); 1477 } 1478 } 1479 output(") raises ("); 1480 1481 MofException[] _exceptions = _operation.exceptions(); 1483 for (int i = 0; i < _exceptions.length; i++) { 1484 MofException _exception = 1485 MofExceptionHelper.narrow(_exceptions[i]); 1486 String _eformat1 = idlHelper.format1(_exception.name()); 1487 output(_eformat1); 1488 outputln(" ,"); 1489 } 1490 outputln("Reflective::MofError );"); 1491 1492 Constraint[] _constraints = _operation.constraints(); 1494 for (int i = 0; i < _constraints.length; i++) { 1495 Constraint _constraint = 1496 ConstraintHelper.narrow(_constraints[i]); 1497 constraintTemplate(_constraint); 1498 } 1499 } 1500 } 1501 1502 public void classCreateTemplate(org.omg.mof.Model.Class _class) 1503 throws MofError, BadKind, Bounds, NotSet { 1504 1505 logger.log(Level.FINE, "IDL classCreateTemplate"); 1506 1507 if (_class.visibility().equals(VisibilityKind.public_vis)) { 1508 String _typeclass = idlType(_class); 1509 String _cformat2 = idlHelper.format2(idlHelper.className(_class)); 1510 output(_typeclass + " create_" + _cformat2 + " ("); 1511 1512 MofAttribute[] attributes = 1514 mofHelper.allAttributesOfClass( 1515 _class, 1516 ScopeKind.instance_level, 1517 false); 1518 1519 for (int i = 0; i < attributes.length; i++) { 1520 MofAttribute _current = attributes[i]; 1521 String _aformat2 = idlHelper.format2(_current.name()); 1522 String _typeattribute = idlType(_current.type()); 1523 MultiplicityType _multiplicity = _current.multiplicity(); 1524 boolean _is_unique = _multiplicity.isUnique; 1525 boolean _is_ordered = _multiplicity.isOrdered; 1526 if ((_multiplicity.upper > 1) || (_multiplicity.upper == -1)) { 1527 String _aformat1 = idlType(_current.type()); 1528 String _aformat1_qn = idlHelper.format1(_aformat1); 1529 String _qualifiedName = idlHelper.qualifiedName(_current.type().container()); 1530 if (!_current.type().container()._is_equivalent(input[0]) 1531 && ((_multiplicity.upper > 1) || (_multiplicity.upper == -1)) 1532 && (_aformat1.indexOf("::") == -1)) 1533 _aformat1_qn = _qualifiedName + "::" + idlHelper.format1(_aformat1); 1534 if (_is_unique && _is_ordered) { 1535 output( 1536 "in " 1537 + _aformat1_qn 1538 + "UList " 1539 + _aformat2); 1540 } else { 1541 if (_is_ordered) { 1542 output( 1543 "in " 1544 + _aformat1_qn 1545 + "List " 1546 + _aformat2); 1547 } else { 1548 if (_is_unique) { 1549 output( 1550 "in " 1551 + _aformat1_qn 1552 + "Set " 1553 + _aformat2); 1554 } else 1555 output( 1556 "in " 1557 + _aformat1_qn 1558 + "Bag " 1559 + _aformat2); 1560 } 1561 } 1562 } else 1563 output("in " + _typeattribute + " " + _aformat2); 1564 if (i != (attributes.length - 1)) 1565 output(" ,"); 1566 } 1567 outputln(") raises (Reflective::MofError);"); 1568 } 1569 } 1570 1571 public void referenceTemplate(Reference _reference) 1572 throws MofError, BadKind, Bounds, NotSet { 1573 1574 logger.log(Level.FINE, "IDL referenceTemplate"); 1575 if (_reference.visibility().equals(VisibilityKind.public_vis)) { 1576 annotationTemplate(_reference.annotation()); 1577 String _rformat1 = idlHelper.format1(_reference.name()); 1578 String _rformat2 = idlHelper.format2(_reference.name()); 1579 String _rformat2IdlConflict = idlHelper.format2IdlConflict(_reference.name()); 1580 String _typereference = idlType(_reference.type()); 1581 MultiplicityType _multiplicity = _reference.multiplicity(); 1582 int _upper = _multiplicity.upper; 1583 int _lower = _multiplicity.lower; 1584 1585 if ((_lower == 0) && (_upper == 1)) 1586 outputln( 1587 _typereference 1588 + " " 1589 + _rformat2IdlConflict 1590 + "() raises (Reflective::NotSet, Reflective::MofError);"); 1591 1592 if ((_lower == 1) && (_upper == 1)) 1593 outputln( 1594 _typereference 1595 + " " 1596 + _rformat2IdlConflict 1597 + "() raises (Reflective::MofError);"); 1598 1599 if ((_upper > 1) || (_upper == -1)) { 1600 output(idlBaseType(_typereference)); 1602 if (_multiplicity.isUnique && _multiplicity.isOrdered) { 1603 output("UList "); 1604 } else { 1605 if (_multiplicity.isOrdered) { 1606 output("List "); 1607 } else { 1608 if (_multiplicity.isUnique) { 1609 output("Set "); 1610 } else 1611 output("Bag "); 1612 } 1613 } 1614 outputln(_rformat2IdlConflict + "() raises (Reflective::MofError);"); 1615 } 1616 1617 if ((_upper == 1) && (_reference.is_changeable())) 1618 outputln( 1619 "void set_" 1620 + _rformat2 1621 + " (in " 1622 + _typereference 1623 + " new_value ) raises (Reflective::MofError);"); 1624 1625 if (((_upper > 1) || (_upper == -1)) 1626 && (_reference.is_changeable())) { 1627 output("void set_" + _rformat2 + " ( "); 1628 if (_multiplicity.isUnique && _multiplicity.isOrdered) { 1629 output("in " + idlBaseType(_typereference) + "UList "); 1630 } else { 1631 if (_multiplicity.isOrdered) { 1632 output( 1633 "in " + idlBaseType(_typereference) + "List "); 1634 } else { 1635 if (_multiplicity.isUnique) { 1636 output( 1637 "in " + idlBaseType(_typereference) + "Set "); 1638 } else 1639 output( 1640 "in " + idlBaseType(_typereference) + "Bag "); 1641 } 1642 } 1643 outputln(" new_value ) raises (Reflective::MofError);"); 1644 } 1645 1646 if ((_lower == 0) && (_upper == 1) && (_reference.is_changeable())) 1647 outputln( 1648 "void unset_" 1649 + _rformat2 1650 + " () raises (Reflective::MofError);"); 1651 1652 if (((_upper > 1) || (_upper == -1)) 1653 && (_reference.is_changeable())) 1654 outputln( 1655 "void add_" 1656 + _rformat2 1657 + " ( in " 1658 + _typereference 1659 + " new_element ) raises (Reflective::MofError);"); 1660 1661 if (((_upper > 1) || (_upper == -1)) 1662 && (_multiplicity.isOrdered) 1663 && (_reference.is_changeable())) { 1664 output("void add_" + _rformat2 + "_before ( "); 1665 output("in " + _typereference + " new_element, "); 1666 outputln( 1667 "in " 1668 + _typereference 1669 + " before_element ) raises (Reflective::NotFound, Reflective::MofError);"); 1670 } 1671 1672 if (((_upper > 1) || (_upper == -1)) 1673 && (_reference.is_changeable())) { 1674 output("void modify_" + _rformat2 + " ( "); 1675 output("in " + _typereference + " old_element, "); 1676 outputln( 1677 "in " 1678 + _typereference 1679 + " new_element ) raises (Reflective::NotFound, Reflective::MofError);"); 1680 } 1681 1682 if (((_upper > 1) || (_upper == -1)) 1683 && (_lower != _upper) 1684 && (_reference.is_changeable())) { 1685 output("void remove_" + _rformat2 + " ("); 1686 output("in " + _typereference + " old_element "); 1687 outputln( 1688 " ) raises (Reflective::NotFound, Reflective::MofError);"); 1689 } 1690 } 1691 } 1692 1693 1697 public IDLCommon getIdlHelper() { 1698 return idlHelper; 1699 } 1700 1701 1705 public MOFCommon getMofHelper() { 1706 return mofHelper; 1707 } 1708 1709 1713 public void setIdlHelper(IDLCommon idlHelper) { 1714 this.idlHelper = idlHelper; 1715 } 1716 1717 1721 public void setMofHelper(MOFCommon mofHelper) { 1722 this.mofHelper = mofHelper; 1723 } 1724 1725} 1726 | Popular Tags |