1 27 28 package org.objectweb.ccm.visitorIDL3.xmi; 29 30 32 35 public class XMIPrinter 36 extends org.objectweb.ccm.visitorIDL3.common.Printer { 37 38 protected XMITranslator translator_; 39 protected org.objectweb.ccm.util.Table stereotypes_; 40 protected org.objectweb.ccm.util.Table types_; 41 protected org.objectweb.ccm.util.Vector external_refs_; 42 protected org.objectweb.ccm.util.Table generalizations_; 43 protected org.objectweb.ccm.util.Table dependencies_tree_; 44 protected org.objectweb.ccm.util.Table associations_; 45 protected org.objectweb.ccm.util.Table assoc_ccm_manages_; 46 protected org.objectweb.ccm.util.Table assoc_union_members_; 47 protected org.objectweb.ccm.util.Table assoc_typedefs_; 48 protected org.objectweb.ccm.util.Table constants_; 49 protected long id_counter_; 50 protected java.lang.String root_id_; 51 52 private int depth_ = 0; 53 54 62 public XMIPrinter(org.objectweb.ccm.visitorIDL3.common.Generator gen, 63 java.lang.String indent) 64 throws fr.lifl.cim.jidlscript.lang.JISError { 65 66 super(gen, '$', '#', indent); 67 68 translator_ = new XMITranslator(); 70 id_counter_ = java.lang.System.currentTimeMillis(); 71 external_refs_ = new org.objectweb.ccm.util.Vector(); 72 dependencies_tree_ = new org.objectweb.ccm.util.Table(); 73 generalizations_ = new org.objectweb.ccm.util.Table(); 74 associations_ = new org.objectweb.ccm.util.Table(); 75 assoc_ccm_manages_ = new org.objectweb.ccm.util.Table(); 76 assoc_union_members_ = new org.objectweb.ccm.util.Table(); 77 assoc_typedefs_ = new org.objectweb.ccm.util.Table(); 78 constants_ = new org.objectweb.ccm.util.Table(); 79 initStereotypes(); 80 initTypes(); 81 82 super.setAlias("self", this); 84 85 super.loadFile("xmi.template"); 87 } 88 89 95 private void log(java.lang.String msg) { 96 java.lang.String tab = ""; 97 98 for (int i = 0; i < depth_; i++) { 99 tab = tab + " "; 100 } 101 102 System.err.println(tab + msg); 103 } 104 105 108 private void incDepth() { 109 depth_++; 110 } 111 112 115 private void decDepth() { 116 depth_--; 117 } 118 119 122 protected void initStereotypes() { 123 stereotypes_ = new org.objectweb.ccm.util.Table(); 124 125 stereotypes_.put("CORBAModule", "Package"); 127 128 stereotypes_.put("CORBAAlias", "Class"); 130 stereotypes_.put("CORBAArray", "Class"); 131 stereotypes_.put("CORBABoxedValue", "Class"); 132 stereotypes_.put("CORBAConstants", "Class"); 133 stereotypes_.put("CORBAEnum", "Class"); 134 stereotypes_.put("CORBAException", "Class"); 135 stereotypes_.put("CORBAInterface", "Class"); 136 stereotypes_.put("CORBASequence", "Class"); 137 stereotypes_.put("CORBAStruct", "Class"); 138 stereotypes_.put("CORBATypedef", "Class"); 139 stereotypes_.put("CORBAUnion", "Class"); 140 stereotypes_.put("CORBAValue", "Class"); 141 stereotypes_.put("CORBAValueFactory", "Class"); 142 stereotypes_.put("CORBAValueSupports", "Class"); 143 144 stereotypes_.put("CORBAConstant", "Attribute"); 146 147 stereotypes_.put("null", "DataType"); 149 stereotypes_.put("void", "DataType"); 150 stereotypes_.put("CORBAFixed", "DataType"); 151 stereotypes_.put("CORBAObject", "DataType"); 152 stereotypes_.put("CORBAany", "DataType"); 153 stereotypes_.put("CORBAboolean", "DataType"); 154 stereotypes_.put("CORBAchar", "DataType"); 155 stereotypes_.put("CORBAdouble", "DataType"); 156 stereotypes_.put("CORBAfloat", "DataType"); 157 stereotypes_.put("CORBAlong", "DataType"); 158 stereotypes_.put("CORBAlongdouble", "DataType"); 159 stereotypes_.put("CORBAlonglong", "DataType"); 160 stereotypes_.put("CORBAoctet", "DataType"); 161 stereotypes_.put("CORBAshort", "DataType"); 162 stereotypes_.put("CORBAstring", "DataType"); 163 stereotypes_.put("CORBAunsignedlong", "DataType"); 164 stereotypes_.put("CORBAunsignedshort", "DataType"); 165 stereotypes_.put("CORBAwchar", "DataType"); 166 stereotypes_.put("CORBAwstring", "DataType"); 167 168 170 stereotypes_.put("CCMComponent", "Class"); 172 stereotypes_.put("CCMHome", "Class"); 173 stereotypes_.put("CCMEvent", "Class"); 174 stereotypes_.put("CCMPrimaryKey", "Class"); 175 176 stereotypes_.put("CCMHomeFactory", "Class"); 178 stereotypes_.put("CCMHomeFinder", "Class"); 179 180 stereotypes_.put("CCMManages", "Association"); 182 stereotypes_.put("CCMProvides", "Association"); 183 stereotypes_.put("CCMUses", "Association"); 184 stereotypes_.put("CCMPublishes", "Association"); 185 stereotypes_.put("CCMConsumes", "Association"); 186 stereotypes_.put("CCMEmits", "Association"); 187 188 stereotypes_.put("readonly", "null"); 190 stereotypes_.put("readonlyEnd", "null"); 191 192 stereotypes_.put("CORBATypeCode", "DataType"); 194 stereotypes_.put("CORBAPrincipal", "DataType"); 195 } 196 197 200 protected void initTypes() { 201 types_ = new org.objectweb.ccm.util.Table(); 202 203 java.util.Enumeration keys = stereotypes_.keys(); 204 205 while (keys.hasMoreElements()) { 206 types_.put(keys.nextElement(), newId()); 207 } 208 } 209 210 216 protected java.lang.String getExternalId( 217 org.objectweb.ccm.IDL3.Declaration decl) { 218 219 java.lang.String id = newId(decl); 220 221 org.objectweb.ccm.IDL3.Declaration[] depend = null; 222 223 org.objectweb.ccm.IDL3.Declaration decl2 = decl; 229 while ((decl2.getParent().getDeclKind() != org.objectweb.ccm.IDL3.DeclarationKind._dk_module) && 230 (decl2.getParent().getDeclKind() != org.objectweb.ccm.IDL3.DeclarationKind._dk_repository)) { 231 232 decl2 = decl2.getParent(); 233 } 234 235 if (decl == decl2) { 236 external_refs_.add(decl); 237 } else if (!types_.containsKey(decl2.getId())) { 238 external_refs_.add(decl2); 239 newId(decl2); 240 } else { 241 return id; 242 } 243 244 depend = decl2.getDependencies(); 245 246 for (int i = 0; i < depend.length; i++) { 247 if (!types_.containsKey(depend[i].getId())) { 248 getExternalId(depend[i]); 249 } 250 } 251 252 return id; 253 } 254 255 258 public XMITranslator getXMITranslator() { 259 return translator_; 260 } 261 262 272 public java.lang.String modifyCurrentLine(java.lang.String str) { 273 int l = str.length(); 274 275 if (l == 0) { 276 return ""; 277 } 278 279 if ((l > 2) && (str.charAt(0) == '<') && 280 ((str.charAt(1) == '!') || (str.charAt(1) == '?'))) { 281 282 return str + "\\n"; 283 } 284 285 if ((l > 2) && 286 (str.charAt(l - 1) == '>') && 287 (str.charAt(l - 2) != '/') && 288 (str.indexOf("</") == -1)) { 289 290 return str + "\\n$self.inc()$"; 291 } 292 293 if ((l > 2) && (str.charAt(0) == '<') && 294 (str.charAt(1) == '/')) { 295 296 return "$self.dec()$" + str + "\\n"; 297 } 298 299 if ((str.charAt(0) != getCallChar()) || 300 (str.charAt(l - 1) != getCallChar())) { 301 302 return str+"\\n"; 303 } 304 305 return str; 306 } 307 308 311 public java.lang.String newId() { 312 id_counter_++; 313 314 return "xmi." + java.lang.Long.toString(id_counter_); 315 } 316 317 322 public java.lang.String newId(org.objectweb.ccm.IDL3.Declaration decl) { 323 java.lang.String res = (java.lang.String ) types_.get(decl.getId()); 324 325 if (res != null) { 326 return res; 327 } 328 329 res = newId(); 330 types_.put(decl.getId(), res); 331 332 return res; 333 } 334 335 338 public java.lang.String newRootId() { 339 root_id_ = newId(); 340 341 return root_id_; 342 } 343 344 349 public java.lang.String getXMIId(java.lang.String stereo_name) { 350 java.lang.String res = (java.lang.String ) types_.get(stereo_name); 351 352 if (res == null) { 353 res = ""; 354 } 355 356 return res; 357 } 358 359 364 public java.lang.String getXMIId(org.objectweb.ccm.IDL3.TypeRef type) { 365 if (type.isDeclaration()) { 366 org.objectweb.ccm.IDL3.Declaration decl = 367 (org.objectweb.ccm.IDL3.Declaration) type; 368 369 java.lang.String res = getXMIId(decl.getId()); 370 371 if (res.equals("")) { 372 res = getExternalId(decl); 373 } 374 375 return res; 376 } 377 378 return getXMIId(getXMITranslator().toXMIString(type)); 379 } 380 381 387 public java.lang.String isAbstract(org.objectweb.ccm.IDL3.ValueDecl value) { 388 if (value.isAbstract()) { 389 return "true"; 390 } else { 391 return "false"; 392 } 393 } 394 395 401 public java.lang.String toStringMode(int mode) { 402 if (mode == org.objectweb.ccm.IDL3.OperationDecl.PARAM_IN) { 403 return "in"; 404 } else if (mode == org.objectweb.ccm.IDL3.OperationDecl.PARAM_OUT) { 405 return "out"; 406 } else { 407 return "inout"; 408 } 409 } 410 411 414 public java.lang.String corbaStereotypes() { 415 java.util.Enumeration keys = stereotypes_.keys(); 416 java.util.Enumeration values = stereotypes_.elements(); 417 418 java.lang.String [] aliases = { "name", "base_class" }; 419 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 420 421 while (keys.hasMoreElements()) { 422 objs[0] = keys.nextElement(); 423 objs[1] = values.nextElement(); 424 super.map("STEREOTYPE", aliases, objs); 425 } 426 427 return ""; 428 } 429 430 435 public java.lang.String insertGeneralizableElement(java.lang.String gen_id) { 436 java.lang.String [] aliases = { "gen_id" }; 437 java.lang.Object [] objs = { gen_id }; 438 439 super.map("GENERALIZABLE_ELEMENT", aliases, objs); 440 441 return ""; 442 } 443 444 447 public java.lang.String generalizations() { 448 java.util.Enumeration keys = generalizations_.keys(); 449 java.util.Enumeration values = generalizations_.elements(); 450 451 java.lang.String [] aliases = { "gen_id", "child_id", "parent_id" }; 452 java.lang.Object [] objs = new java.lang.Object [3]; 453 454 while (keys.hasMoreElements()) { 455 objs[1] = getXMIId((java.lang.String ) keys.nextElement()); 456 org.objectweb.ccm.util.Vector[] elems = 457 (org.objectweb.ccm.util.Vector[]) values.nextElement(); 458 459 for (int i = 0; i < elems.length; i++) { 460 objs[0] = elems[i].get(0); 461 objs[2] = elems[i].get(1); 462 super.map("GENERALIZATION", aliases, objs); 463 } 464 } 465 466 return ""; 467 } 468 469 472 public java.lang.String associations() { 473 java.util.Enumeration keys = associations_.keys(); 474 java.util.Enumeration values = associations_.elements(); 475 476 java.lang.String [] aliases = { "assoc_id", "src_elem_ref", "dest_elem_ref", "name", 477 "stereotype", "visibility", "multiplicity_src", "multiplicity_dest" }; 478 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 479 480 while (keys.hasMoreElements()) { 481 objs[4] = ""; 482 keys.nextElement(); 483 org.objectweb.ccm.util.Vector[] elems = 484 (org.objectweb.ccm.util.Vector[]) values.nextElement(); 485 486 for (int i = 0; i < elems.length; i++) { 487 for (int j = 0; j < elems[i].size(); j++) { 488 objs[j] = elems[i].get(j); 489 } 490 491 super.map("ASSOCIATION", aliases, objs); 492 } 493 } 494 495 return ""; 496 } 497 498 501 public java.lang.String associations_ccm_manages() { 502 java.util.Enumeration keys = assoc_ccm_manages_.keys(); 503 java.util.Enumeration values = assoc_ccm_manages_.elements(); 504 505 java.lang.String [] aliases = { "assoc_id", "home_ref", "component_ref", "pk_ref" }; 506 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 507 508 for (int i = 0; i < objs.length; i++) { 510 objs[i] = ""; 511 } 512 513 while (keys.hasMoreElements()) { 514 keys.nextElement(); 515 org.objectweb.ccm.util.Vector[] elems = 516 (org.objectweb.ccm.util.Vector[]) values.nextElement(); 517 518 for (int i = 0; i < elems.length; i++) { 519 for (int j = 0; j < elems[i].size(); j++) { 520 objs[j] = elems[i].get(j); 521 } 522 523 if (elems[i].size() == 3) { 524 super.map("ASSOCIATION_CCM_MANAGES", aliases, objs); 525 } else { 526 super.map("ASSOCIATION_CCM_MANAGES_WITH_PK", aliases, objs); 527 } 528 } 529 } 530 531 return ""; 532 } 533 534 537 public java.lang.String associations_union_members() { 538 java.util.Enumeration keys = assoc_union_members_.keys(); 539 java.util.Enumeration values = assoc_union_members_.elements(); 540 541 java.lang.String [] aliases = { "assoc_id", "name", "src_elem_ref", 542 "dest_elem_ref", "idl_order", "label" }; 543 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 544 545 while (keys.hasMoreElements()) { 546 keys.nextElement(); 547 org.objectweb.ccm.util.Vector[] elems = 548 (org.objectweb.ccm.util.Vector[]) values.nextElement(); 549 550 for (int i = 0; i < elems.length; i++) { 551 for (int j = 0; j < elems[i].size(); j++) { 552 objs[j] = elems[i].get(j); 553 } 554 555 super.map("ASSOCIATION_UNION_MEMBER", aliases, objs); 556 } 557 } 558 559 return ""; 560 } 561 562 565 public java.lang.String associations_typedefs() { 566 java.util.Enumeration keys = assoc_typedefs_.keys(); 567 java.util.Enumeration values = assoc_typedefs_.elements(); 568 569 java.lang.String [] aliases = { "assoc_id", "src_elem_ref", 570 "dest_elem_ref", "obj", "multiplicity" }; 571 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 572 573 while (keys.hasMoreElements()) { 574 keys.nextElement(); 575 org.objectweb.ccm.util.Vector[] elems = 576 (org.objectweb.ccm.util.Vector[]) values.nextElement(); 577 578 for (int i = 0; i < elems.length; i++) { 579 for (int j = 0; j < elems[i].size() - 1; j++) { 580 objs[j] = elems[i].get(j); 581 } 582 583 if (((java.lang.String ) 584 elems[i].get(elems[i].size() - 1)).equals("CORBASequence")) { 585 586 super.map("ASSOCIATION_SEQUENCE", aliases, objs); 587 } else { 588 super.map("ASSOCIATION_ARRAY", aliases, objs); 589 } 590 } 591 } 592 593 return ""; 594 } 595 596 602 public java.lang.String getScopeId(org.objectweb.ccm.IDL3.Declaration decl) { 603 java.lang.String id = ""; 604 id = getXMIId(decl.getParent().getId()); 605 606 if (decl.getParent().getDeclKind() == 607 org.objectweb.ccm.IDL3.DeclarationKind._dk_repository) { 608 609 return root_id_; 610 } else { 611 return id; 612 } 613 } 614 615 620 public java.lang.String visitModule(org.objectweb.ccm.IDL3.Declaration decl) { 621 if (decl.getDeclKind() != org.objectweb.ccm.IDL3.DeclarationKind._dk_module) { 622 java.lang.String msg = 623 "error in class org.objectweb.ccm.visitorIDL3.XMIPrinter\n" + 624 " operation : visitModule\n" + 625 " message : root visited object must be a module"; 626 throw new Error (msg); 627 } 628 629 java.lang.String [] aliases = { "obj" }; 630 java.lang.Object [] objs = { decl }; 631 super.map("MODULE", aliases, objs); 632 633 return ""; 634 } 635 636 641 public java.lang.String contents(org.objectweb.ccm.IDL3.Scope scope) { 642 org.objectweb.ccm.IDL3.Declaration[] decls = null; 643 644 decls = scope.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_all); 645 646 for (int i = 0; i < decls.length; i++) { 647 visitContained(decls[i], ""); 648 } 649 650 return ""; 651 } 652 653 659 public java.lang.String visitContained(org.objectweb.ccm.IDL3.Declaration contained, 660 java.lang.String extension) { 661 662 java.lang.String id = 663 org.objectweb.ccm.IDL3.DeclarationKind.toString( 664 contained.getDeclKind()).toUpperCase() + extension; 665 666 java.lang.String [] aliases = { "obj" }; 667 java.lang.Object [] objs = { contained }; 668 super.map(id, aliases, objs); 669 670 return ""; 671 } 672 673 679 public java.lang.String baseComponent( 680 org.objectweb.ccm.IDL3.ComponentDecl component) { 681 682 org.objectweb.ccm.IDL3.InterfaceDecl[] supportedInterfaces = null; 683 supportedInterfaces = 684 ((org.objectweb.ccm.IDL3.ComponentDecl) component).getSupportedInterfaces(); 685 686 java.lang.String gen_id = ""; 687 org.objectweb.ccm.util.Vector gen_bases = new org.objectweb.ccm.util.Vector(); 688 689 for (int i = 0; i < supportedInterfaces.length; i++) { 690 gen_id = newId(); 691 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 692 ids.add(gen_id); 693 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) supportedInterfaces[i])); 694 gen_bases.add(ids); 695 696 insertGeneralizableElement(gen_id); 697 } 698 699 org.objectweb.ccm.IDL3.ComponentDecl baseComponent = null; 700 baseComponent = component.getBaseComponent(); 701 702 if (baseComponent != null) { 703 gen_id = newId(); 704 705 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 706 ids.add(gen_id); 707 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) baseComponent)); 708 gen_bases.add(ids); 709 710 insertGeneralizableElement(gen_id); 711 } 712 713 generalizations_.put(component.getId(), 714 (org.objectweb.ccm.util.Vector[]) 715 gen_bases.toArray(new org.objectweb.ccm.util.Vector[0])); 716 717 return ""; 718 } 719 720 726 public java.lang.String baseHome(org.objectweb.ccm.IDL3.HomeDecl home) { 727 org.objectweb.ccm.IDL3.InterfaceDecl[] supportedInterfaces = null; 728 supportedInterfaces = 729 ((org.objectweb.ccm.IDL3.HomeDecl) home).getSupportedInterfaces(); 730 731 java.lang.String gen_id = ""; 732 org.objectweb.ccm.util.Vector gen_bases = new org.objectweb.ccm.util.Vector(); 733 734 for (int i = 0; i < supportedInterfaces.length; i++) { 735 gen_id = newId(); 736 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 737 ids.add(gen_id); 738 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) supportedInterfaces[i])); 739 gen_bases.add(ids); 740 741 insertGeneralizableElement(gen_id); 742 } 743 744 org.objectweb.ccm.IDL3.HomeDecl baseHome = null; 745 baseHome = home.getBaseHome(); 746 747 if (baseHome != null) { 748 gen_id = newId(); 749 750 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 751 ids.add(gen_id); 752 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) baseHome)); 753 gen_bases.add(ids); 754 755 insertGeneralizableElement(gen_id); 756 } 757 758 generalizations_.put(home.getId(), 759 (org.objectweb.ccm.util.Vector[]) 760 gen_bases.toArray(new org.objectweb.ccm.util.Vector[0])); 761 762 return ""; 763 } 764 765 770 public java.lang.String managedComponent(org.objectweb.ccm.IDL3.HomeDecl home) { 771 org.objectweb.ccm.IDL3.ComponentDecl component = null; 772 component = home.getManagedComponent(); 773 org.objectweb.ccm.IDL3.ValueDecl pk = null; 774 pk = home.getPrimaryKey(); 775 776 java.lang.String assoc_id = ""; 778 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 779 780 assoc_id = newId(); 781 782 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 783 ids.add(assoc_id); 784 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) home)); 785 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) component)); 786 787 if (pk != null) { 788 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) pk)); 789 } 790 assoc_ends.add(ids); 791 792 assoc_ccm_manages_.put(home.getId(), 793 (org.objectweb.ccm.util.Vector[]) 794 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 795 796 return ""; 797 } 798 799 800 805 public java.lang.String baseInterfaces(org.objectweb.ccm.IDL3.InterfaceDecl itf) { 806 org.objectweb.ccm.IDL3.InterfaceDecl[] bases = null; 807 bases = itf.getBaseInterfaces(); 808 809 java.lang.String gen_id = ""; 811 org.objectweb.ccm.util.Vector gen_bases = new org.objectweb.ccm.util.Vector(); 812 813 for (int i = 0; i < bases.length; i++) { 814 gen_id = newId(); 815 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 816 ids.add(gen_id); 817 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) bases[i])); 818 gen_bases.add(ids); 819 820 insertGeneralizableElement(gen_id); 821 } 822 823 generalizations_.put(itf.getId(), 824 (org.objectweb.ccm.util.Vector[]) 825 gen_bases.toArray(new org.objectweb.ccm.util.Vector[0])); 826 827 return ""; 828 } 829 830 835 public java.lang.String provides(org.objectweb.ccm.IDL3.ProvidesDecl _provides) { 836 org.objectweb.ccm.IDL3.TypeRef type = null; 837 type = _provides.getType(); 838 839 if (type != null) { 840 java.lang.String assoc_id = ""; 842 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 843 844 assoc_id = newId(); 845 846 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 847 ids.add(assoc_id); 848 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) _provides.getParent())); 849 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) type)); 850 ids.add(_provides.getName()); 851 ids.add("stereotype='" + getXMIId("CCMProvides") + "'"); 852 ids.add("public"); 853 ids.add("1"); 854 ids.add("1"); 855 assoc_ends.add(ids); 856 857 associations_.put(_provides.getId(), 858 (org.objectweb.ccm.util.Vector[]) 859 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 860 } 861 862 return ""; 863 } 864 865 870 public java.lang.String uses(org.objectweb.ccm.IDL3.UsesDecl _uses) { 871 org.objectweb.ccm.IDL3.TypeRef type = null; 872 type = _uses.getType(); 873 874 if (type != null) { 875 java.lang.String assoc_id = ""; 877 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 878 879 assoc_id = newId(); 880 881 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 882 ids.add(assoc_id); 883 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) _uses.getParent())); 884 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) type)); 885 ids.add(_uses.getName()); 886 ids.add("stereotype='" + getXMIId("CCMUses") + "'"); 887 ids.add("public"); 888 ids.add("1"); 889 ids.add(_uses.isMultiple() ? "*" : "1"); 890 assoc_ends.add(ids); 891 892 associations_.put(_uses.getId(), 893 (org.objectweb.ccm.util.Vector[]) 894 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 895 } 896 897 return ""; 898 } 899 900 905 public java.lang.String publishes(org.objectweb.ccm.IDL3.PublishesDecl _publishes) { 906 org.objectweb.ccm.IDL3.TypeRef type = null; 907 type = _publishes.getType(); 908 909 if (type != null) { 910 java.lang.String assoc_id = ""; 912 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 913 914 assoc_id = newId(); 915 916 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 917 ids.add(assoc_id); 918 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) _publishes.getParent())); 919 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) type)); 920 ids.add(_publishes.getName()); 921 ids.add("stereotype='" + getXMIId("CCMPublishes") + "'"); 922 ids.add("public"); 923 ids.add("1"); 924 ids.add("1"); 925 assoc_ends.add(ids); 926 927 associations_.put(_publishes.getId(), 928 (org.objectweb.ccm.util.Vector[]) 929 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 930 } 931 932 return ""; 933 } 934 935 940 public java.lang.String consumes(org.objectweb.ccm.IDL3.ConsumesDecl _consumes) { 941 org.objectweb.ccm.IDL3.TypeRef type = null; 942 type = _consumes.getType(); 943 944 if (type != null) { 945 java.lang.String assoc_id = ""; 947 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 948 949 assoc_id = newId(); 950 951 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 952 ids.add(assoc_id); 953 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) _consumes.getParent())); 954 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) type)); 955 ids.add(_consumes.getName()); 956 ids.add("stereotype='" + getXMIId("CCMConsumes") + "'"); 957 ids.add("public"); 958 ids.add("1"); 959 ids.add("1"); 960 assoc_ends.add(ids); 961 962 associations_.put(_consumes.getId(), 963 (org.objectweb.ccm.util.Vector[]) 964 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 965 } 966 967 return ""; 968 } 969 970 975 public java.lang.String emits(org.objectweb.ccm.IDL3.EmitsDecl _emits) { 976 org.objectweb.ccm.IDL3.TypeRef type = null; 977 type = _emits.getType(); 978 979 if (type != null) { 980 java.lang.String assoc_id = ""; 982 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 983 984 assoc_id = newId(); 985 986 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 987 ids.add(assoc_id); 988 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) _emits.getParent())); 989 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) type)); 990 ids.add(_emits.getName()); 991 ids.add("stereotype='" + getXMIId("CCMEmits") + "'"); 992 ids.add("public"); 993 ids.add("1"); 994 ids.add("1"); 995 assoc_ends.add(ids); 996 997 associations_.put(_emits.getId(), 998 (org.objectweb.ccm.util.Vector[]) 999 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1000 } 1001 1002 return ""; 1003 } 1004 1005 1010 public java.lang.String operationExceptions(org.objectweb.ccm.IDL3.OperationDecl op) { 1011 org.objectweb.ccm.IDL3.ExceptionDecl[] excs = op.getExceptions(); 1012 1013 java.lang.String [] aliases = {"exception"}; 1014 java.lang.Object [] objs = new java.lang.Object [1]; 1015 1016 for (int i = 0; i < excs.length; i++) { 1017 objs[0] = excs[i].getAbsoluteName().substring(2); 1018 super.map("OPERATION_EXCEPTION", aliases, objs); 1019 } 1020 1021 return ""; 1022 } 1023 1024 1029 public java.lang.String operationParams(org.objectweb.ccm.IDL3.OperationDecl op) { 1030 org.objectweb.ccm.IDL3.ParameterList params = op.getParameters(); 1031 org.objectweb.ccm.IDL3.TypeRef[] types = params.getParamTypes(); 1032 java.lang.String [] names = params.getParamNames(); 1033 int[] modes = params.getParamModes(); 1034 1035 java.lang.String [] aliases = {"name", "kind", "operation", "type"}; 1036 java.lang.Object [] objs = new java.lang.Object [4]; 1037 objs[2] = getXMIId(op.getId()); 1038 1039 for (int i = 0; i < names.length; i++) { 1040 objs[0] = names[i]; 1041 objs[1] = toStringMode(modes[i]); 1042 objs[3] = getXMIId(types[i]); 1043 1044 super.map("OPERATION_PARAMETER", aliases, objs); 1045 } 1046 1047 return ""; 1048 } 1049 1050 1055 public java.lang.String attribute(org.objectweb.ccm.IDL3.AttributeDecl attrib) { 1056 org.objectweb.ccm.IDL3.TypeRef attrib_type = attrib.getType(); 1057 java.lang.String id = ""; 1058 id = newId(attrib); 1059 1060 if (attrib_type.isDeclaration()) { 1061 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 1063 1064 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1065 ids.add(id); 1066 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) attrib.getParent())); 1067 ids.add(getXMIId(attrib_type)); 1068 ids.add(attrib.getName()); 1069 ids.add(attrib.isReadonly() ? ("stereotype='" + getXMIId("readonlyEnd") + "'") : ""); 1070 ids.add("public"); 1071 ids.add("1"); 1072 ids.add("1"); 1073 assoc_ends.add(ids); 1074 1075 associations_.put(attrib.getId(), 1076 (org.objectweb.ccm.util.Vector[]) 1077 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1078 } else { 1079 java.lang.String [] aliases = { "attrib_id", "name", "visibility", 1080 "multiplicity", "stereotype", "scope_id", "type" }; 1081 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1082 1083 objs[0] = id; 1084 objs[1] = attrib.getName(); 1085 objs[2] = "public"; 1086 objs[3] = ""; 1087 objs[4] = attrib.isReadonly() ? ("stereotype='" + getXMIId("readonly") + "'") : ""; 1088 objs[5] = getScopeId(attrib); 1089 objs[6] = getXMIId(attrib_type); 1090 1091 super.map("ATTRIBUTE_BASIC_TYPES", aliases, objs); 1092 } 1093 1094 return ""; 1095 } 1096 1097 1102 public java.lang.String enumMembers(org.objectweb.ccm.IDL3.EnumDecl enumDecl) { 1103 java.lang.String [] names = enumDecl.getMembers(); 1104 1105 java.lang.String [] aliases = {"name", "owner_id", "idl_order"}; 1106 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1107 1108 objs[1] = getXMIId(enumDecl.getId()); 1109 1110 for (int i = 0; i < names.length; i++) 1111 { 1112 objs[0] = names[i]; 1113 objs[2] = java.lang.Integer.toString(i); 1114 super.map("ENUM_MEMBER", aliases, objs); 1115 } 1116 1117 return ""; 1118 } 1119 1120 1126 public java.lang.String structMembers(java.lang.String struct_id, 1127 org.objectweb.ccm.IDL3.StructMembers members) { 1128 1129 org.objectweb.ccm.IDL3.TypeRef[] types = members.getMemberTypes(); 1130 java.lang.String [] names = members.getMemberNames(); 1131 boolean is_inner = false; 1132 1133 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 1134 java.lang.String id = ""; 1135 1136 for (int i = 0; i < names.length; i++) { 1137 if ((types[i].getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_struct) || 1139 (types[i].getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_union) || 1140 (types[i].getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_enum)) { 1141 1142 org.objectweb.ccm.IDL3.Declaration decl = null; 1143 decl = (org.objectweb.ccm.IDL3.Declaration) types[i]; 1144 1145 if (decl.getParent().getId().equals(struct_id)) { 1146 is_inner = true; 1147 } else { 1148 is_inner = false; 1149 } 1150 } else { 1151 is_inner = false; 1152 } 1153 1154 if (is_inner) { 1155 switch (types[i].getTypeKind()) { 1156 case org.objectweb.ccm.IDL3.TypeKind._tk_struct : 1157 { 1158 java.lang.String [] aliases = { "obj" }; 1159 java.lang.Object [] objs = { (org.objectweb.ccm.IDL3.StructDecl) types[i] }; 1160 super.map("STRUCT", aliases, objs); 1161 } 1162 break; 1163 case org.objectweb.ccm.IDL3.TypeKind._tk_union : 1164 { 1165 java.lang.String [] aliases = { "obj" }; 1166 java.lang.Object [] objs = { (org.objectweb.ccm.IDL3.UnionDecl) types[i] }; 1167 super.map("UNION", aliases, objs); 1168 } 1169 break; 1170 case org.objectweb.ccm.IDL3.TypeKind._tk_enum : 1171 { 1172 java.lang.String [] aliases = { "obj" }; 1173 java.lang.Object [] objs = { (org.objectweb.ccm.IDL3.EnumDecl) types[i] }; 1174 super.map("ENUM", aliases, objs); 1175 } 1176 break; 1177 default : 1178 break; 1179 } 1180 } 1181 1182 id = newId(); 1183 1184 if (types[i].isDeclaration()) { 1185 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1187 ids.add(id); 1188 ids.add(getXMIId(struct_id)); 1189 ids.add(getXMIId(types[i])); 1190 ids.add(names[i]); 1191 ids.add(""); 1192 ids.add("public"); 1193 ids.add("1"); 1194 ids.add("1"); 1195 assoc_ends.add(ids); 1196 } else { 1197 java.lang.String [] aliases = { "attrib_id", "name", "visibility", 1199 "multiplicity", "stereotype", "scope_id", "type" }; 1200 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1201 1202 objs[0] = id; 1203 objs[1] = names[i]; 1204 objs[2] = "public"; 1205 objs[3] = "multiplicity='1..1'"; 1206 objs[4] = ""; 1207 objs[5] = getXMIId(struct_id); 1208 objs[6] = getXMIId(types[i]); 1209 1210 super.map("ATTRIBUTE_BASIC_TYPES", aliases, objs); 1211 } 1212 } 1213 1214 associations_.put(struct_id, 1215 (org.objectweb.ccm.util.Vector[]) 1216 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1217 1218 return ""; 1219 } 1220 1221 1226 public java.lang.String unionMembers(org.objectweb.ccm.IDL3.UnionDecl union) { 1227 boolean is_inner = false; 1228 1229 org.objectweb.ccm.IDL3.TypeRef discriminator = union.getType(); 1231 1232 java.lang.String owner_id = ""; 1233 owner_id = getXMIId((org.objectweb.ccm.IDL3.TypeRef) union); 1234 1235 java.lang.String id = ""; 1236 id = newId(); 1237 1238 if (discriminator.isDeclaration()) { 1239 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 1241 1242 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1243 ids.add(id); 1244 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) union)); 1245 ids.add(getXMIId(discriminator)); 1246 ids.add(getXMITranslator().toXMI(discriminator) + "_switch"); 1247 ids.add(""); 1248 ids.add("public"); 1249 ids.add("1"); 1250 ids.add("1"); 1251 assoc_ends.add(ids); 1252 1253 associations_.put(union.getId(), 1254 (org.objectweb.ccm.util.Vector[]) 1255 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1256 } else { 1257 java.lang.String [] aliases = { "attrib_id", "name", "visibility", 1258 "multiplicity", "stereotype", "scope_id", "type" }; 1259 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1260 1261 objs[0] = id; 1262 objs[1] = getXMITranslator().toXMI(discriminator) + "_switch"; 1263 objs[2] = "public"; 1264 objs[3] = "multiplicity='1..1'"; 1265 objs[4] = ""; 1266 objs[5] = owner_id; 1267 objs[6] = getXMIId(discriminator); 1268 1269 super.map("ATTRIBUTE_BASIC_TYPES", aliases, objs); 1270 } 1271 1272 org.objectweb.ccm.IDL3.TypeRef[] types = union.getMembers().getMemberTypes(); 1274 org.objectweb.ccm.IDL3.AnyValue[] labels = union.getMembers().getMemberValues(); 1275 java.lang.String [] names = union.getMembers().getMemberNames(); 1276 int default_index = union.getDefaultIndex(); 1277 1278 java.lang.String [] aliases = { "attrib_id", "name", "scope_id", 1279 "type", "idl_order", "label" }; 1280 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1281 1282 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 1283 1284 for (int i = 0; i < names.length; i++) { 1285 if ((types[i].getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_struct) || 1287 (types[i].getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_union) || 1288 (types[i].getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_enum)) { 1289 1290 org.objectweb.ccm.IDL3.Declaration decl = null; 1291 decl = (org.objectweb.ccm.IDL3.Declaration) types[i]; 1292 1293 if (decl.getParent().getId().equals(union.getId())) { 1294 is_inner = true; 1295 } else { 1296 is_inner = false; 1297 } 1298 } else { 1299 is_inner = false; 1300 } 1301 1302 if (is_inner) { 1303 switch (types[i].getTypeKind()) { 1304 case org.objectweb.ccm.IDL3.TypeKind._tk_struct : 1305 { 1306 java.lang.String [] aliases_ = { "obj" }; 1307 java.lang.Object [] objs_ = { (org.objectweb.ccm.IDL3.StructDecl) types[i] }; 1308 super.map("STRUCT", aliases_, objs_); 1309 } 1310 break; 1311 case org.objectweb.ccm.IDL3.TypeKind._tk_union : 1312 { 1313 java.lang.String [] aliases_ = { "obj" }; 1314 java.lang.Object [] objs_ = { (org.objectweb.ccm.IDL3.UnionDecl) types[i] }; 1315 super.map("UNION", aliases_, objs_); 1316 } 1317 break; 1318 case org.objectweb.ccm.IDL3.TypeKind._tk_enum : 1319 { 1320 java.lang.String [] aliases_ = { "obj" }; 1321 java.lang.Object [] objs_ = { (org.objectweb.ccm.IDL3.EnumDecl) types[i] }; 1322 super.map("ENUM", aliases_, objs_); 1323 } 1324 break; 1325 default : 1326 break; 1327 } 1328 } 1329 1330 id = newId(); 1331 1332 if (types[i].isDeclaration()) { 1333 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1335 ids.add(id); 1336 ids.add(names[i]); 1337 ids.add(owner_id); 1338 ids.add(getXMIId(types[i])); 1339 ids.add(java.lang.Integer.toString(i)); 1340 if (default_index == i) { 1341 ids.add("default"); 1342 } else { 1343 ids.add(getXMITranslator().toString(labels[i], discriminator)); 1344 } 1345 assoc_ends.add(ids); 1346 } else { 1347 objs[0] = id; 1348 objs[1] = names[i]; 1349 objs[2] = owner_id; 1350 objs[3] = getXMIId(types[i]); 1351 objs[4] = java.lang.Integer.toString(i); 1352 if (default_index == i) { 1353 objs[5] = "default"; 1354 } else { 1355 objs[5] = getXMITranslator().toString(labels[i], discriminator); 1356 } 1357 super.map("ATTRIBUTE_UNION_MEMBER", aliases, objs); 1358 } 1359 } 1360 1361 assoc_union_members_.put(union.getId(), 1362 (org.objectweb.ccm.util.Vector[]) 1363 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1364 1365 return ""; 1366 } 1367 1368 1373 public java.lang.String baseValues(org.objectweb.ccm.IDL3.ValueDecl value) { 1374 org.objectweb.ccm.IDL3.ValueDecl[] bases = null; 1375 bases = value.getAbstractValues(); 1376 1377 java.lang.String gen_id = ""; 1379 org.objectweb.ccm.util.Vector gen_bases = new org.objectweb.ccm.util.Vector(); 1380 1381 for (int i = 0; i < bases.length; i++) { 1382 gen_id = newId(); 1383 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1384 ids.add(gen_id); 1385 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) bases[i])); 1386 gen_bases.add(ids); 1387 1388 insertGeneralizableElement(gen_id); 1389 } 1390 1391 org.objectweb.ccm.IDL3.ValueDecl base = value.getBaseValue(); 1392 1393 if (base != null) { 1394 gen_id = newId(); 1395 1396 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1397 ids.add(gen_id); 1398 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) base)); 1399 gen_bases.add(ids); 1400 1401 insertGeneralizableElement(gen_id); 1402 } 1403 1404 generalizations_.put(value.getId(), 1405 (org.objectweb.ccm.util.Vector[]) 1406 gen_bases.toArray(new org.objectweb.ccm.util.Vector[0])); 1407 1408 return ""; 1409 } 1410 1411 1416 public java.lang.String initializer(org.objectweb.ccm.IDL3.ValueDecl value) { 1417 org.objectweb.ccm.IDL3.Initializer[] initializers = value.getInitializers(); 1418 1419 if (initializers.length == 0) { 1420 return ""; 1421 } 1422 1423 java.lang.String [] aliases = { "init", "owner_id" }; 1424 java.lang.Object [] objs = { initializers[0], 1425 getXMIId((org.objectweb.ccm.IDL3.TypeRef) value) }; 1426 1427 super.map("INITIALIZER", aliases, objs); 1428 1429 return ""; 1430 } 1431 1432 1438 public java.lang.String 1439 initializerParams(java.lang.String initializerId, 1440 org.objectweb.ccm.IDL3.ParameterList params) { 1441 1442 org.objectweb.ccm.IDL3.TypeRef[] types = params.getParamTypes(); 1443 java.lang.String [] names = params.getParamNames(); 1444 int[] modes = params.getParamModes(); 1445 1446 java.lang.String [] aliases = {"name", "kind", "operation", "type"}; 1447 java.lang.Object [] objs = new java.lang.Object [4]; 1448 objs[2] = initializerId; 1449 1450 for (int i = 0; i < names.length; i++) { 1451 objs[0] = names[i]; 1452 objs[1] = toStringMode(modes[i]); 1453 objs[3] = getXMIId(types[i]); 1454 1455 super.map("OPERATION_PARAMETER", aliases, objs); 1456 } 1457 1458 return ""; 1459 } 1460 1461 1466 public java.lang.String valueMember(org.objectweb.ccm.IDL3.ValueMemberDecl member) { 1467 org.objectweb.ccm.IDL3.TypeRef member_type = member.getType(); 1468 java.lang.String id = ""; 1469 id = newId(member); 1470 1471 if (member_type.isDeclaration()) { 1472 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 1474 1475 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1476 ids.add(id); 1477 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) member.getParent())); 1478 ids.add(getXMIId(member_type)); 1479 ids.add(member.getName()); 1480 ids.add(""); 1481 ids.add(member.isPrivate() ? "private" : "public"); 1482 ids.add("1"); 1483 ids.add("1"); 1484 assoc_ends.add(ids); 1485 1486 associations_.put(member.getId(), 1487 (org.objectweb.ccm.util.Vector[]) 1488 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1489 } else { 1490 java.lang.String [] aliases = { "attrib_id", "name", "visibility", 1491 "multiplicity", "stereotype", "scope_id", "type" }; 1492 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1493 1494 objs[0] = id; 1495 objs[1] = member.getName(); 1496 objs[2] = member.isPrivate() ? "private" : "public"; 1497 objs[3] = "multiplicity='1..1'"; 1498 objs[4] = ""; 1499 objs[5] = getScopeId(member); 1500 objs[6] = getXMIId(member_type); 1501 1502 super.map("ATTRIBUTE_BASIC_TYPES", aliases, objs); 1503 } 1504 1505 return ""; 1506 } 1507 1508 1513 public java.lang.String boxedType(org.objectweb.ccm.IDL3.ValueBoxDecl valuebox) { 1514 java.lang.String gen_id = ""; 1515 gen_id = newId(); 1516 1517 org.objectweb.ccm.util.Vector gen_bases = new org.objectweb.ccm.util.Vector(); 1518 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1519 ids.add(gen_id); 1520 ids.add(getXMIId(valuebox.getType())); 1521 gen_bases.add(ids); 1522 1523 insertGeneralizableElement(gen_id); 1524 1525 return ""; 1526 } 1527 1528 1535 public java.lang.String 1536 constant(org.objectweb.ccm.IDL3.ConstantDecl _constant) 1537 { 1538 org.objectweb.ccm.IDL3.TypeRef type = null; 1539 type = _constant.getType(); 1540 org.objectweb.ccm.IDL3.AnyValue value = null; 1541 value = _constant.getAnyValue(); 1542 1543 java.lang.String id = ""; 1544 id = newId(); 1545 1546 java.lang.String initvalue = ""; 1547 if (value.isInteger()) { 1548 initvalue = java.lang.Long.toString(value.getAsInteger()); 1549 } else if (value.isString()) { 1550 initvalue = value.getAsString(); 1551 } else if (value.isWString()) { 1552 initvalue = value.getAsWString(); 1553 } else if (value.isChar()) { 1554 initvalue = java.lang.String.valueOf(value.getAsChar()); 1555 } else if (value.isWChar()) { 1556 initvalue = java.lang.String.valueOf(value.getAsWChar()); 1557 } else if (value.isFixed()) { 1558 initvalue = value.getAsFixed(); 1559 } else if (value.isFloating()) { 1560 initvalue = java.lang.Double.toString(value.getAsFloating()); 1561 } else if (value.isBoolean()) { 1562 initvalue = java.lang.String.valueOf(value.getAsBoolean()); 1563 } else if (value.isEnum()) { 1564 initvalue = value.getAsEnum(); 1565 } 1566 1567 if ((_constant.getParent().getDeclKind() == org.objectweb.ccm.IDL3.DeclarationKind._dk_module) || 1568 (_constant.getParent().getDeclKind() == org.objectweb.ccm.IDL3.DeclarationKind._dk_repository)) { 1569 1570 org.objectweb.ccm.util.Vector v = new org.objectweb.ccm.util.Vector(); 1571 1572 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1573 ids.add(id); 1574 ids.add(_constant.getName()); 1575 ids.add("public"); 1576 ids.add(getXMIId((org.objectweb.ccm.IDL3.TypeRef) _constant.getParent())); 1577 ids.add(getXMIId(type)); 1578 ids.add(initvalue); 1579 v.add(ids); 1580 1581 constants_.put(_constant.getId(), 1582 (org.objectweb.ccm.util.Vector[]) 1583 v.toArray(new org.objectweb.ccm.util.Vector[0])); 1584 } else { 1585 java.lang.String [] aliases = { "attrib_id", "name", "visibility", 1586 "scope_id", "type", "init_value" }; 1587 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1588 1589 objs[0] = id; 1590 objs[1] = _constant.getName(); 1591 objs[2] = "public"; 1592 objs[3] = getXMIId((org.objectweb.ccm.IDL3.TypeRef) _constant.getParent()); 1593 objs[4] = getXMIId(type); 1594 objs[5] = initvalue; 1595 1596 super.map("ATTRIBUTE_CONSTANT", aliases, objs); 1597 } 1598 1599 return ""; 1600 } 1601 1602 1607 public java.lang.String corbaConstants(java.lang.String scope_id) { 1608 if (constants_.size() > 0) { 1609 java.lang.String [] aliases = { "scope_id" }; 1610 java.lang.Object [] objs = { scope_id }; 1611 1612 super.map("CONSTANT_IN_MODULE_SCOPE", aliases, objs); 1613 } 1614 1615 return ""; 1616 } 1617 1618 1623 public java.lang.String constants_in_module_scope(java.lang.String owner_id) { 1624 java.util.Enumeration keys = constants_.keys(); 1625 java.util.Enumeration values = constants_.elements(); 1626 1627 java.lang.String [] aliases = { "attrib_id", "name", "visibility", 1628 "scope_id", "type", "init_value" }; 1629 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1630 1631 while (keys.hasMoreElements()) { 1632 keys.nextElement(); 1633 org.objectweb.ccm.util.Vector[] elems = 1634 (org.objectweb.ccm.util.Vector[]) values.nextElement(); 1635 1636 for (int i = 0; i < elems.length; i++) { 1637 for (int j = 0; j < elems[i].size(); j++) { 1638 objs[j] = elems[i].get(j); 1639 } 1640 objs[3] = owner_id; 1641 1642 super.map("ATTRIBUTE_CONSTANT", aliases, objs); 1643 } 1644 } 1645 1646 return ""; 1647 } 1648 1649 1654 public java.lang.String visit(org.objectweb.ccm.util.Vector vect) { 1655 org.objectweb.ccm.IDL3.Declaration[] decls = (org.objectweb.ccm.IDL3.Declaration[]) 1656 vect.toArray(new org.objectweb.ccm.IDL3.Declaration[0]); 1657 1658 for (int i = 0; i < decls.length; i++) { 1659 if (decls[i].getDeclKind() == org.objectweb.ccm.IDL3.DeclarationKind._dk_module) { 1660 java.lang.String [] aliases = { "obj", "vect" }; 1661 java.lang.Object [] objs = { decls[i], dependencies_tree_.get(decls[i]) }; 1662 super.map("MODULE_EXT_REFS", aliases, objs); 1663 } else { 1664 visitContained(decls[i], ""); 1665 } 1666 } 1667 1668 return ""; 1669 } 1670 1671 1674 public java.lang.String externalTypes() { 1675 org.objectweb.ccm.IDL3.Declaration[] depend = null; 1677 org.objectweb.ccm.IDL3.Scope parent = null; 1678 org.objectweb.ccm.util.Vector childs = null; 1679 org.objectweb.ccm.IDL3.Declaration obj1 = null; 1680 org.objectweb.ccm.util.Vector root_dependencies = new org.objectweb.ccm.util.Vector(); 1681 1682 depend = (org.objectweb.ccm.IDL3.Declaration[]) 1683 external_refs_.toArray(new org.objectweb.ccm.IDL3.Declaration[0]); 1684 1685 for (int i = 0; i < depend.length; i++) { 1686 obj1 = depend[i]; 1687 parent = obj1.getParent(); 1688 1689 while (parent.getDeclKind() != 1690 org.objectweb.ccm.IDL3.DeclarationKind._dk_repository) { 1691 1692 if (dependencies_tree_.containsKey(parent)) { 1693 childs = (org.objectweb.ccm.util.Vector) 1694 dependencies_tree_.get(parent); 1695 if (childs.indexOf(obj1) == -1) { 1696 childs.add(obj1); 1697 } 1698 } else { 1699 childs = new org.objectweb.ccm.util.Vector(); 1700 childs.add(obj1); 1701 dependencies_tree_.put(parent, childs); 1702 } 1703 1704 obj1 = parent; 1705 parent = obj1.getParent(); 1706 } 1707 1708 if (root_dependencies.indexOf(obj1) == -1) { 1709 root_dependencies.add(obj1); 1710 } 1711 } 1712 1713 visit(root_dependencies); 1714 1715 return ""; 1716 } 1717 1718 1724 public java.lang.String 1725 alias(org.objectweb.ccm.IDL3.AliasDecl _alias) { 1726 java.lang.String anon_id = newId(_alias); 1727 java.lang.String gen_id = newId(); 1728 java.lang.String name = _alias.getName(); 1729 java.lang.String scope_id = getScopeId(_alias); 1730 java.lang.String type_id = _alias.getId(); 1731 1732 org.objectweb.ccm.util.Vector ids = new org.objectweb.ccm.util.Vector(); 1733 org.objectweb.ccm.util.Vector gen_bases = new org.objectweb.ccm.util.Vector(); 1734 org.objectweb.ccm.util.Vector assoc_ends = new org.objectweb.ccm.util.Vector(); 1735 ids.add(gen_id); 1736 1737 org.objectweb.ccm.IDL3.TypeRef type = _alias.getType(); 1739 1740 org.objectweb.ccm.IDL3.TypeRefImpl impl = null; 1741 1742 if (type.getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_sequence) { 1743 java.lang.String [] aliases = { "seq_id", "name", "scope_id", "type_id" }; 1744 java.lang.Object [] objs = { anon_id, name, scope_id, type_id }; 1745 1746 super.map("TYPEDEF_SEQUENCE", aliases, objs); 1747 1748 impl = (org.objectweb.ccm.IDL3.TypeRefImpl) type; 1749 org.objectweb.ccm.IDL3.TypeRef implType = impl.getContentType(); 1750 ids.add(anon_id); 1751 ids.add(getXMIId(implType)); 1752 ids.add(impl); 1753 if (implType.getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_value_box) { 1754 ids.add("0..1"); 1755 } else { 1756 ids.add("1..1"); 1757 } 1758 ids.add("CORBASequence"); 1759 1760 assoc_ends.add(ids); 1762 assoc_typedefs_.put(type_id, 1763 (org.objectweb.ccm.util.Vector[]) 1764 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1765 } else if (type.getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_array) { 1766 java.lang.String [] aliases = { "array_id", "name", "scope_id", "type_id" }; 1767 java.lang.Object [] objs = { anon_id, name, scope_id, type_id }; 1768 1769 super.map("TYPEDEF_ARRAY", aliases, objs); 1770 1771 impl = (org.objectweb.ccm.IDL3.TypeRefImpl) type; 1772 while (impl.getContentType().getTypeKind() == 1773 org.objectweb.ccm.IDL3.TypeKind._tk_array) { 1774 1775 impl = (org.objectweb.ccm.IDL3.TypeRefImpl) impl.getContentType(); 1776 } 1777 1778 ids.add(anon_id); 1779 1780 if (impl.getContentType().getTypeKind() != 1781 org.objectweb.ccm.IDL3.TypeKind._tk_sequence) { 1782 1783 ids.add(getXMIId(impl.getContentType())); 1784 } else { 1785 impl = (org.objectweb.ccm.IDL3.TypeRefImpl) impl.getContentType(); 1786 1787 java.lang.String anon_seq_id = newId(); 1788 1789 java.lang.String [] aliases_ = { "seq_id", "scope_id" }; 1790 java.lang.Object [] objs_ = { anon_seq_id, scope_id }; 1791 1792 super.map("ANONYMOUS_SEQUENCE", aliases_, objs_); 1793 1794 org.objectweb.ccm.util.Vector ids2 = new org.objectweb.ccm.util.Vector(); 1795 org.objectweb.ccm.IDL3.TypeRef implType = impl.getContentType(); 1796 1797 ids2.add(newId()); 1798 ids2.add(anon_seq_id); 1799 ids2.add(getXMIId(implType)); 1800 ids2.add(impl); 1801 if (implType.getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_value_box) { 1802 ids2.add("0..1"); 1803 } else { 1804 ids2.add("1..1"); 1805 } 1806 ids2.add("CORBASequence"); 1807 1808 assoc_ends.add(ids2); 1810 assoc_typedefs_.put(type_id, 1811 (org.objectweb.ccm.util.Vector[]) 1812 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1813 1814 ids.add(anon_seq_id); 1815 } 1816 1817 ids.add(type); 1818 ids.add("1..1"); 1819 ids.add("CORBAArray"); 1820 1821 assoc_ends.add(ids); 1823 assoc_typedefs_.put(type_id, 1824 (org.objectweb.ccm.util.Vector[]) 1825 assoc_ends.toArray(new org.objectweb.ccm.util.Vector[0])); 1826 } else if (type.getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_fixed) { 1827 impl = (org.objectweb.ccm.IDL3.TypeRefImpl) type; 1828 java.lang.String digits = java.lang.String.valueOf(impl.getDigits()); 1829 java.lang.String scale = java.lang.String.valueOf(impl.getScale()); 1830 1831 java.lang.String [] aliases = { "fixed_id", "name", "scope_id", "type_id", "digits", "scale" }; 1832 java.lang.Object [] objs = { anon_id, name, scope_id, type_id, digits, scale }; 1833 1834 super.map("TYPEDEF_FIXED", aliases, objs); 1835 1836 ids.add(getXMIId("CORBAFixed")); 1837 1838 gen_bases.add(ids); 1840 generalizations_.put(type_id, 1841 (org.objectweb.ccm.util.Vector[]) 1842 gen_bases.toArray(new org.objectweb.ccm.util.Vector[0])); 1843 } else { 1844 java.lang.String [] aliases = { "alias_id", "name", "scope_id", "gen_id", "type_id" }; 1845 java.lang.Object [] objs = { anon_id, name, scope_id, gen_id, type_id }; 1846 1847 super.map("TYPEDEF", aliases, objs); 1848 1849 ids.add(getXMIId(type)); 1850 1851 gen_bases.add(ids); 1853 generalizations_.put(type_id, 1854 (org.objectweb.ccm.util.Vector[]) 1855 gen_bases.toArray(new org.objectweb.ccm.util.Vector[0])); 1856 } 1857 1858 return ""; 1859 } 1860 1861 1867 public java.lang.String 1868 qualifierAttribute(java.lang.String kind, 1869 org.objectweb.ccm.IDL3.TypeRefImpl impl) { 1870 1871 java.lang.String [] aliases = { "name", "value" }; 1872 java.lang.Object [] objs = new java.lang.Object [aliases.length]; 1873 1874 if (kind.equals("CORBASequence")) { 1875 objs[0] = "index"; 1876 int upperBound = impl.getLength(); 1877 objs[1] = (upperBound == 0) ? "*" : java.lang.String.valueOf(upperBound); 1878 1879 super.map("ATTRIBUTE_ASSOCIATION_QUALIFIER", aliases, objs); 1880 } else { 1881 org.objectweb.ccm.util.Vector arrayDims = new org.objectweb.ccm.util.Vector(); 1882 arrayDims.add(new java.lang.Integer (impl.getLength())); 1883 1884 while (impl.getContentType().getTypeKind() == org.objectweb.ccm.IDL3.TypeKind._tk_array) { 1885 impl = (org.objectweb.ccm.IDL3.TypeRefImpl) impl.getContentType(); 1886 arrayDims.add(new java.lang.Integer (impl.getLength())); 1887 } 1888 1889 for (int i = 0; i < arrayDims.size(); i++) { 1890 objs[0] = "index" + java.lang.String.valueOf(i); 1891 objs[1] = java.lang.String.valueOf(arrayDims.get(arrayDims.size() - 1 - i)); 1892 1893 super.map("ATTRIBUTE_ASSOCIATION_QUALIFIER", aliases, objs); 1894 } 1895 } 1896 1897 return ""; 1898 } 1899 1900 1905 public java.lang.String 1906 printShortFileName(java.lang.String filename) { 1907 java.io.File f = new java.io.File (filename); 1908 1909 return f.getName(); 1910 } 1911} 1912 | Popular Tags |