1 20 package org.objectweb.modfact.corba.xmi; 21 22 import org.omg.mof.Model.Association; 23 import org.omg.mof.Model.MofAttribute; 24 import org.omg.mof.Model.Reference; 25 import org.omg.mof.Reflective.NotSet; 26 27 import org.objectweb.modfact.corba.generator.PrintGenerator; 28 import org.objectweb.modfact.corba.helper.XMICommon; 29 import org.objectweb.modfact.corba.helper.MOFCommon; 30 import org.objectweb.modfact.corba.logging.Level; 31 import org.objectweb.modfact.corba.logging.ModFactLogger; 32 33 37 public class PackageGenerator extends PrintGenerator { 38 39 private org.omg.mof.Model.Package[] input; 40 41 private MOFCommon mofHelper; 42 private XMICommon xmiHelper; 43 44 private ModFactLogger logger; 45 46 49 public void setInput(org.omg.mof.Model.ModelElement[] elt) { 50 input = new org.omg.mof.Model.Package[elt.length]; 51 for (int i = 0; i < input.length; i++) { 52 input[i] = (org.omg.mof.Model.Package) elt[i]; 53 } 54 } 55 56 59 public void setLogger(ModFactLogger log) { 60 logger = log; 61 } 62 63 66 public void generate() throws 67 org.omg.mof.Reflective.MofError, 68 org.omg.CORBA.TypeCodePackage.BadKind , 69 org.omg.CORBA.TypeCodePackage.Bounds , 70 org.omg.mof.Reflective.NotSet { 71 generate(input[0]); 72 out.flush(); 73 } 74 75 76 78 public String getAllInstanceAttributes( 80 org.omg.mof.Model.Class cls, 81 String previousCls) 82 throws org.omg.mof.Reflective.MofError , NotSet{ 83 logger.log(Level.FINER, "DTD getAllInstanceAttributes of a class"); 84 String _nclass = cls.ref_mof_id(); 85 if (previousCls.indexOf(_nclass) != -1) 86 return ""; 87 else { 88 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 89 String parentAtts = ""; 90 for (int i = 0; i < parent.length; i++) { 91 String temp = 92 getAllInstanceAttributes( 93 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 94 previousCls); 95 if ((parentAtts.length() > 0) && (temp.length() > 0)) { 96 parentAtts = parentAtts + ", "; 97 } 98 parentAtts = parentAtts + temp; 99 } 100 String atts = getAttributes(cls, "instance"); 101 if ((parentAtts.length() > 0) && (atts.length() > 0)) { 102 parentAtts = parentAtts + ", "; 103 } 104 previousCls = previousCls + " " + _nclass; 105 return parentAtts + atts; 106 } 107 } 108 109 111 public String getAttributes(org.omg.mof.Model.Class cls, String type) 112 throws org.omg.mof.Reflective.MofError , NotSet { 113 logger.log(Level.FINER, "DTD getAttrinbutes of a class"); 114 String rslt = ""; 115 org.omg.mof.Model.MofAttribute[] attributes; 116 if (type == "instance") 117 attributes = 118 mofHelper.attributesOfClass( 119 cls, 120 org.omg.mof.Model.ScopeKind.instance_level, 121 true); 122 else 123 attributes = 124 mofHelper.attributesOfClass( 125 cls, 126 org.omg.mof.Model.ScopeKind.classifier_level, 127 true); 128 for (int i = 0; i < attributes.length; i++) { 129 String name = xmiHelper.qualifiedName(attributes[i]); 130 String m; 131 int _upper = attributes[i].multiplicity().upper; 132 int _lower = attributes[i].multiplicity().lower; 133 if ((_lower == 1) && ((_upper > 1) || (_upper == -1))) 134 m = "*"; 135 else if ((_lower == 0) && (_upper == 1)) 136 m = "?"; 137 else if ((_lower != 1) && (_upper != 1)) 138 m = "*"; 139 else 140 m = "?"; 141 if (rslt.length() > 0) 142 rslt = rslt + ", "; 143 rslt = rslt + name + m; 144 } 145 return rslt; 146 } 147 148 public String getAllReferences( 150 org.omg.mof.Model.Class cls, 151 String previousCls) 152 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 153 logger.log(Level.FINER, "DTD getAllReferences of a class"); 154 String _nclass = cls.name(); 155 if (previousCls.indexOf(_nclass) != -1) 156 return ""; 157 else { 158 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 159 String parentRefs = ""; 160 for (int i = 0; i < parent.length; i++) { 161 String temp = 162 getAllReferences( 163 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 164 previousCls); 165 if ((parentRefs.length() > 0) && (temp.length() > 0)) { 166 parentRefs = parentRefs + temp; 167 } 168 } 169 String refs = getReferences(cls); 170 if ((parentRefs.length() > 0) && (refs.length() > 0)) { 171 parentRefs = parentRefs + ", "; 172 } 173 previousCls = previousCls + " " + _nclass; 174 return parentRefs + refs; 175 } 176 } 177 178 public String getReferences(org.omg.mof.Model.Class cls) 180 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 181 logger.log(Level.FINER, "DTD getReferences of a class"); 182 String refs = ""; 183 Reference[] references = mofHelper.referencesOfClass(cls); 184 for (int i = 0; i < references.length; i++) { 185 org.omg.mof.Model.AssociationEnd _association_end = 186 references[i].exposed_end(); 187 org.omg.mof.Model.AggregationKind _aggregation = 188 _association_end.aggregation(); 189 190 org.omg.mof.Model.Association _association = 192 org.omg.mof.Model.AssociationHelper.narrow( 193 _association_end.container()); 194 if (!_association.is_derived()) { 195 if (!_aggregation 196 .equals(org.omg.mof.Model.AggregationKind.composite)) { 197 String name = xmiHelper.qualifiedName(references[i]); 198 String m = getReferenceMultiplicity(references[i]); 199 String temp = name + m; 200 if (refs.length() > 0) 201 refs = refs + ", "; 202 refs = refs + temp; 203 } 204 } 205 } 206 return refs; 207 } 208 209 public String getReferenceMultiplicity(org.omg.mof.Model.Reference ref) 211 throws org.omg.mof.Reflective.MofError { 212 213 logger.log(Level.FINER, "DTD getReferenceMultiplicity of a reference"); 214 org.omg.mof.Model.MultiplicityType _mult = 215 ref.referenced_end().multiplicity(); 216 int _upper = _mult.upper; 217 int _lower = _mult.lower; 218 String m; 219 if (((_lower == 0) && (_upper == 1)) 220 || (ref 221 .referenced_end() 222 .equals(org.omg.mof.Model.AggregationKind.composite))) 223 m = "?"; 224 else if ((_lower == 1) && ((_upper > 1) || (_upper == -1))) 225 m = "*"; 226 else if ((_lower != 1) && (_upper != 1)) 227 m = "*"; 228 else 229 m = "?"; 230 return m; 231 } 232 233 public String getContainedClasses( 235 org.omg.mof.Model.Class cls, 236 String previousCls) 237 throws org.omg.mof.Reflective.MofError , NotSet{ 238 logger.log(Level.FINER, "DTD getContainedClasses of a class"); 239 String _nclass = cls.name(); 240 if (previousCls.indexOf(_nclass) != -1) 241 return ""; 242 else { 243 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 244 String parentClasses = ""; 245 for (int i = 0; i < parent.length; i++) { 246 String temp = 247 getContainedClasses( 248 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 249 previousCls); 250 if ((parentClasses.length() > 0) && (temp.length() > 0)) { 251 parentClasses = parentClasses + ", "; 252 } 253 parentClasses = parentClasses + temp; 254 } 255 String classes = ""; 256 org.omg.mof.Model.ModelElement[] _contents = cls.contents(); 257 258 for (int i = 0; i < _contents.length; i++) { 260 org.omg.mof.Model.ModelElement _current = _contents[i]; 261 if (_current._is_a(org.omg.mof.Model.ClassHelper.id())) { 262 String Temp = xmiHelper.qualifiedName(_current); 263 if (classes.length() > 0) { 264 classes = classes + "|"; 265 } 266 classes = classes + Temp; 267 } 268 } 269 if (classes.length() > 0) { 270 if (parentClasses.length() > 0) { 271 parentClasses = parentClasses + ", "; 272 } 273 classes = classes + "(" + classes + ")" + "*"; 274 } 275 previousCls = previousCls + " " + _nclass; 276 return parentClasses + classes; 277 } 278 } 279 280 public String getAllComposedRoles( 282 org.omg.mof.Model.Class cls, 283 String previousCls) 284 throws org.omg.mof.Reflective.MofError , NotSet{ 285 logger.log(Level.FINER, "DTD getAllComposedRoles of a class"); 286 String _nclass = cls.name(); 287 if (previousCls.indexOf(_nclass) != -1) 288 return ""; 289 else { 290 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 291 String parentRoles = ""; 292 for (int i = 0; i < parent.length; i++) { 293 String temp = 294 getAllComposedRoles( 295 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 296 previousCls); 297 if ((parentRoles.length() > 0) && (temp.length() > 0)) { 298 parentRoles = parentRoles + ", "; 299 } 300 parentRoles = parentRoles + temp; 301 } 302 String roles = getComposedRoles(cls); 303 if ((roles.length() > 0) && (parentRoles.length() > 0)) { 304 parentRoles = parentRoles + ", "; 305 } 306 previousCls = previousCls + " " + _nclass; 307 return parentRoles + roles; 308 } 309 } 310 311 public String getComposedRoles(org.omg.mof.Model.Class cls) 313 throws org.omg.mof.Reflective.MofError , NotSet{ 314 logger.log(Level.FINER, "DTD getComposedRoles of a class"); 315 String rslt = ""; 316 Reference[] references = mofHelper.referencesOfClass(cls); 317 for (int i = 0; i < references.length; i++) { 318 org.omg.mof.Model.AggregationKind _aggregation = 319 references[i].exposed_end().aggregation(); 320 if (_aggregation 321 .equals(org.omg.mof.Model.AggregationKind.composite)) { 322 String name = xmiHelper.qualifiedName(references[i]); 323 String m = getReferenceMultiplicity(references[i]); 324 if (rslt.length() > 0) 325 rslt = rslt + ", "; 326 rslt = rslt + name + m; 327 } 328 } 329 return rslt; 330 } 331 332 public String getClasses(org.omg.mof.Model.Class Cls, String prevCls) 334 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 335 logger.log(Level.FINER, "DTD getClasses of a class"); 336 String rslt = xmiHelper.qualifiedName(Cls); 341 org.omg.mof.Model.Class[] subclass = mofHelper.subClassesOfClass(Cls); 342 for (int i = 0; i < subclass.length; i++) { 343 String Temp = xmiHelper.qualifiedName(subclass[i]); 345 if (Temp.length() > 0) { 346 rslt = rslt + "| "; 347 } 348 rslt = rslt + Temp; 349 } 350 return rslt; 351 352 } 353 354 public String getClassLevelAttributes(org.omg.mof.Model.Package pkg) 356 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 357 358 logger.log(Level.FINER, "DTD getClassLevelAttributes of a package"); 359 java.util.Vector _packages_c_p = new java.util.Vector (); 361 362 366 org.omg.mof.Model.GeneralizableElement[] _sup_packages = 368 pkg.supertypes(); 369 for (int i = 0; i < _sup_packages.length; i++) { 370 _packages_c_p.addElement( 371 org.omg.mof.Model.PackageHelper.narrow(_sup_packages[i])); 372 } 373 374 String parentAtts = ""; 376 for (int i = 0; i < _packages_c_p.size(); i++) { 377 parentAtts = 378 getClassLevelAttributes( 379 (org.omg.mof.Model.Package) _packages_c_p.elementAt(i)); 380 } 381 String atts = ""; 382 org.omg.mof.Model.Class[] classes = mofHelper.classesOfPackage(pkg); 384 385 for (int i = 0; i < classes.length; i++) { 386 String temp = getAttributes(classes[i], "classifier"); 387 if (temp.length() > 0) { 388 atts = atts + "| "; 389 } 390 atts = atts + temp; 391 } 392 if (atts.length() > 0) { 393 if (parentAtts.length() > 0) 394 parentAtts = parentAtts + ", "; 395 atts = "(" + atts + ")"; 396 } 397 return parentAtts + atts; 398 } 399 400 402 403 public String getNestedClassLevelAttributes(org.omg.mof.Model.Package pkg) 404 throws org.omg.mof.Reflective.MofError , NotSet{ 405 logger.log(Level.FINER, "DTD getNestedClassLevelAttribut of a package"); 406 String rslt = ""; 407 org.omg.mof.Model.Class[] classes = mofHelper.classesOfPackage(pkg); 409 410 for (int i = 0; i < classes.length; i++) { 411 String temp = getAttributes(classes[i], "classifier"); 412 if (temp.length() > 0) { 413 if (rslt.length() > 0) 414 rslt = rslt + "| "; 415 temp = "(" + temp + ") "; 416 } 417 rslt = rslt + temp; 418 } 419 420 return rslt; 421 } 422 423 425 public String getPackageClasses(org.omg.mof.Model.Package pkg) 426 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 427 428 logger.log(Level.FINER, "DTD getPackageClasses of a package"); 429 java.util.Vector _packages_c_p = new java.util.Vector (); 431 432 org.omg.mof.Model.GeneralizableElement[] _sup_packages = 434 pkg.supertypes(); 435 for (int i = 0; i < _sup_packages.length; i++) { 436 _packages_c_p.addElement( 437 org.omg.mof.Model.PackageHelper.narrow(_sup_packages[i])); 438 } 439 440 444 String parentClasses = ""; 446 for (int i = 0; i < _packages_c_p.size(); i++) { 447 parentClasses = 448 getPackageClasses( 449 (org.omg.mof.Model.Package) _packages_c_p.elementAt(i)); 450 } 451 String classes = ""; 452 org.omg.mof.Model.Class[] _classes = mofHelper.classesOfPackage(pkg); 454 455 for (int i = 0; i < _classes.length; i++) { 456 String Temp = xmiHelper.qualifiedName(_classes[i]); 457 if (classes.length() > 0) { 458 classes = classes + "| "; 459 } 460 classes = classes + Temp; 461 } 462 if (parentClasses.length() > 0) 463 parentClasses = parentClasses + "| "; 464 return parentClasses + classes; 465 } 466 467 public String getContainedPackages(org.omg.mof.Model.Package pkg) 469 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 470 logger.log(Level.FINER, "DTD getContainedPackages of a package"); 471 String parentPkgs = ""; 473 org.omg.mof.Model.GeneralizableElement[] _sup_packages = 475 pkg.supertypes(); 476 for (int i = 0; i < _sup_packages.length; i++) { 477 parentPkgs = 478 getContainedPackages( 479 org.omg.mof.Model.PackageHelper.narrow(_sup_packages[i])); 480 } 481 485 String pkgs = ""; 486 if ((parentPkgs.length() > 0) && (pkgs.length() > 0)) 493 parentPkgs = pkgs + "|"; 494 return parentPkgs + pkgs; 495 } 496 497 498 public String getUnreferencedAssociations(org.omg.mof.Model.Package pkg) 499 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 500 501 logger.log(Level.FINER, "DTD getUnreferencdAssociations of a package"); 502 String parentAssns = ""; 504 505 org.omg.mof.Model.GeneralizableElement[] _sup_packages = 507 pkg.supertypes(); 508 for (int i = 0; i < _sup_packages.length; i++) { 509 parentAssns = 510 getUnreferencedAssociations( 511 org.omg.mof.Model.PackageHelper.narrow(_sup_packages[i])); 512 } 513 514 Association[] associations = mofHelper.associationsOfPackage(pkg); 516 517 String assns = ""; 518 for (int i = 0; i < associations.length; i++) { 519 if (!associations[i].is_derived()) { 520 if (mofHelper.referencesOfAssociation(associations[i]).length == 0) { 521 String temp = xmiHelper.qualifiedName(associations[i]); 522 if (assns.length() > 0) 523 assns = assns + "|"; 524 assns = assns + temp; 525 } 526 } 527 } 528 if ((parentAssns.length() > 0) && (assns.length() > 0)) 529 parentAssns = parentAssns + "|"; 530 return parentAssns + assns; 531 } 532 533 535 public void outputEntityDefs2(org.omg.mof.Model.Package pkg) 537 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 538 539 logger.log(Level.FINER, "DTD ouputEntityDes2 of a package"); 540 org.omg.mof.Model.Class[] _classes_of_package = mofHelper.classesOfPackage(pkg); 542 543 for (int i = 0; i < _classes_of_package.length; i++) { 544 if (_classes_of_package[i].supertypes().length == 0) { 545 outputPropertiesEntityDef2(_classes_of_package[i], ", "); 546 outputRefsEntityDef2(_classes_of_package[i], ", "); 547 outputCompsEntityDef2(_classes_of_package[i], ", "); 548 } 549 } 550 } 551 552 public void outputPropertiesEntityDef2( 554 org.omg.mof.Model.Class cls, 555 String prevCls) 556 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 557 logger.log(Level.FINER, "DTD outputPRopertiesEntityDef2 of a class"); 558 String _nclass = cls.name(); 559 if (prevCls.indexOf(_nclass) != -1) { 560 String rslt = ""; 561 } else { 562 String PropsEntityName = xmiHelper.qualifiedName(cls) + "Properties"; 563 String PropsList = getAttributes(cls, "instance"); 564 if (PropsList.length() > 0) { 565 } 567 prevCls = prevCls + " " + _nclass; 568 569 org.omg.mof.Model.Class[] _sub_classes = mofHelper.subClassesOfClass(cls); 570 for (int i = 0; i < _sub_classes.length; i++) { 571 org.omg.mof.Model.Class _class = _sub_classes[i]; 572 outputPropertiesEntityDef2(_class, prevCls); 573 } 574 } 575 } 576 577 public void outputRefsEntityDef2( 579 org.omg.mof.Model.Class cls, 580 String prevCls) 581 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 582 583 logger.log(Level.FINER, "DTD ouputRefsEntityDef2 of a class"); 584 String _nclass = cls.name(); 585 if (prevCls.indexOf(_nclass) != -1) { 586 String rslt = ""; 587 } else { 588 String RefsEntityName = xmiHelper.qualifiedName(cls) + "Associations"; 589 String RefsList = getReferences(cls); 590 if (RefsList.length() > 0) { 591 RefsList = "(" + RefsList + ")"; 592 } 594 prevCls = prevCls + " " + _nclass; 595 596 org.omg.mof.Model.Class[] _sub_classes = mofHelper.subClassesOfClass(cls); 597 for (int i = 0; i < _sub_classes.length; i++) { 598 org.omg.mof.Model.Class _class = _sub_classes[i]; 599 outputRefsEntityDef2(_class, prevCls); 600 } 601 } 602 } 603 604 public void outputCompsEntityDef2( 606 org.omg.mof.Model.Class cls, 607 String prevCls) 608 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 609 610 logger.log(Level.FINER, "DTD outputCompsEntityDef2 of a class"); 611 String _nclass = cls.name(); 612 if (prevCls.indexOf(_nclass) != -1) { 613 String rslt = ""; 614 } else { 615 String CompsEntityName = xmiHelper.qualifiedName(cls) + "Compositions"; 616 String CompsList = getComposedRoles(cls); 617 if (CompsList.length() > 0) { 618 CompsList = "(" + CompsList + ")"; 619 } 621 prevCls = prevCls + " " + _nclass; 622 623 org.omg.mof.Model.Class[] _sub_classes = mofHelper.subClassesOfClass(cls); 624 for (int i = 0; i < _sub_classes.length; i++) { 625 org.omg.mof.Model.Class _class = _sub_classes[i]; 626 outputCompsEntityDef2(_class, prevCls); 627 } 628 } 629 } 630 631 public String getContainedClasses2(org.omg.mof.Model.Class cls) 633 throws org.omg.mof.Reflective.MofError, NotSet { 634 635 logger.log(Level.FINER, "DTD getContainedClasses2 of a class"); 636 String classes = ""; 637 org.omg.mof.Model.ModelElement[] _contents = cls.contents(); 638 639 for (int i = 0; i < _contents.length; i++) { 641 org.omg.mof.Model.ModelElement _current = _contents[i]; 642 if (_current._is_a(org.omg.mof.Model.ClassHelper.id())) { 643 String Temp = xmiHelper.qualifiedName(_current); 644 if (classes.length() > 0) { 645 classes = classes + "|"; 646 } 647 classes = classes + Temp; 648 } 649 } 650 651 return classes; 652 } 653 654 public String getPropertiesEntities2( 656 org.omg.mof.Model.Class cls, 657 String prevCls) 658 throws org.omg.mof.Reflective.MofError , NotSet{ 659 660 logger.log(Level.FINER, "DTD getPropertiesEntities2"); 661 String _nclass = cls.name(); 662 if (prevCls.indexOf(_nclass) != -1) 663 return ""; 664 else { 665 String parentProps = ""; 666 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 667 ; 668 for (int i = 0; i < parent.length; i++) { 669 String temp = 670 getPropertiesEntities2( 671 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 672 prevCls); 673 if (temp.length() > 0) { 674 if (parentProps.length() > 0) 675 parentProps = parentProps + ", "; 676 parentProps = parentProps + temp; 677 } 678 } 679 String ClassName = xmiHelper.qualifiedName(cls); 680 String props = ""; 681 if (parentProps.length() > 0) 683 parentProps = parentProps + ", "; 684 props = "%" + ClassName + "Properties" + ";"; 685 prevCls = prevCls + " " + _nclass; 686 return parentProps + props; 687 } 688 } 689 690 public String getRefsEntities2(org.omg.mof.Model.Class cls, String prevCls) 692 throws org.omg.mof.Reflective.MofError , NotSet{ 693 694 logger.log(Level.FINER, "DTD getRefsEntities2 of a class"); 695 String _nclass = cls.name(); 696 if (prevCls.indexOf(_nclass) != -1) 697 return ""; 698 else { 699 String parentRefs = ""; 700 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 701 ; 702 for (int i = 0; i < parent.length; i++) { 703 String temp = 704 getRefsEntities2( 705 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 706 prevCls); 707 if (temp.length() > 0) { 708 if (parentRefs.length() > 0) 709 parentRefs = parentRefs + ", "; 710 parentRefs = parentRefs + temp; 711 } 712 } 713 String ClassName = xmiHelper.qualifiedName(cls); 714 String refs = ""; 715 if (parentRefs.length() > 0) 717 parentRefs = parentRefs + ", "; 718 refs = "%" + ClassName + "Associations" + ";"; 719 prevCls = prevCls + " " + _nclass; 720 return parentRefs + refs; 721 } 722 } 723 724 public String getCompsEntities2( 726 org.omg.mof.Model.Class cls, 727 String prevCls) 728 throws org.omg.mof.Reflective.MofError , NotSet{ 729 730 logger.log(Level.FINER, "DTD getCompsEntities2"); 731 String _nclass = cls.name(); 732 if (prevCls.indexOf(_nclass) != -1) 733 return ""; 734 else { 735 String parentComps = ""; 736 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 737 ; 738 for (int i = 0; i < parent.length; i++) { 739 String temp = 740 getRefsEntities2( 741 org.omg.mof.Model.ClassHelper.narrow(parent[i]), 742 prevCls); 743 if (temp.length() > 0) { 744 if (parentComps.length() > 0) 745 parentComps = parentComps + ", "; 746 parentComps = parentComps + temp; 747 } 748 } 749 String ClassName = xmiHelper.qualifiedName(cls); 750 String comps = ""; 751 if (parentComps.length() > 0) 753 parentComps = parentComps + ", "; 754 comps = "%" + ClassName + "Compositions" + ";"; 755 prevCls = prevCls + " " + _nclass; 756 return parentComps + comps; 757 } 758 } 759 760 762 public void outputEntityDefs3(org.omg.mof.Model.Package pkg) 764 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 765 766 logger.log(Level.FINER, "DTD outputEntityDefs3 of a package"); 767 org.omg.mof.Model.Class[] _classes_of_package = mofHelper.classesOfPackage(pkg); 769 770 out.println(); 771 comment("The Entities of Properties"); 772 out.println(); 773 774 for (int i = 0; i < _classes_of_package.length; i++) { 775 if (_classes_of_package[i].supertypes().length == 0) { 776 outputPropertiesEntityDef3(_classes_of_package[i], "", ""); 777 } 778 } 779 780 out.println(); 781 comment("The Entities of References"); 782 out.println(); 783 784 for (int i = 0; i < _classes_of_package.length; i++) { 785 if (_classes_of_package[i].supertypes().length == 0) { 786 outputRefsEntityDef3(_classes_of_package[i], "", ""); 787 } 788 } 789 790 out.println(); 791 comment("The Entities of Compositions"); 792 out.println(); 793 794 for (int i = 0; i < _classes_of_package.length; i++) { 795 if (_classes_of_package[i].supertypes().length == 0) { 796 outputCompsEntityDef3(_classes_of_package[i], "", ""); 797 } 798 } 799 800 comment(""); 801 out.println(); 802 803 } 804 805 private java.util.Hashtable _entity_props = new java.util.Hashtable (); 807 public void outputPropertiesEntityDef3( 808 org.omg.mof.Model.Class cls, 809 String prevCls, 810 String baseCls) 811 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 812 813 String nm = cls.name(); 814 logger.log(Level.FINER, "DTD outputPropsertiesEntityDef3 of a class"+ nm); 815 String _key = cls.ref_mof_id(); 816 if (_entity_props.containsKey(_key)) { 817 } else { 818 String _nclass = _key; 819 if (prevCls.indexOf(_nclass) != -1) { 820 String rslt = ""; 821 } else { 822 String PropsEntityName = 823 xmiHelper.qualifiedName(cls) + "Properties"; 824 String temp = baseCls; 825 String PropsList = getAllInstanceAttributes3(cls, temp); 826 if (PropsList.length() > 0) { 827 PropsList = "(" + PropsList + ")"; 828 out.println( 830 "<!ENTITY % " 831 + PropsEntityName 832 + " \"" 833 + PropsList 834 + "\">"); 835 _entity_props.put(_key, ""); 836 } 837 baseCls = baseCls + " " + _nclass; 838 temp = baseCls; 839 prevCls = prevCls + " " + _nclass; 840 841 org.omg.mof.Model.Class[] _sub_classes = mofHelper.subClassesOfClass(cls); 843 for (int i = 0; i < _sub_classes.length; i++) { 844 org.omg.mof.Model.Class _class = _sub_classes[i]; 845 baseCls = temp; 846 outputPropertiesEntityDef3(_class, prevCls, baseCls); 847 } 848 } 849 } 850 } 851 852 private java.util.Hashtable _entity_refs = new java.util.Hashtable (); 854 public void outputRefsEntityDef3( 855 org.omg.mof.Model.Class cls, 856 String prevCls, 857 String baseCls) 858 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 859 860 logger.log(Level.FINER, "DTD outputRefsEntityDef3 of a class"); 861 String _key = cls.ref_mof_id(); 862 if (_entity_refs.containsKey(_key)) { 863 } else { 864 String _nclass = _key; 865 if (prevCls.indexOf(_nclass) != -1) { 866 String rslt = ""; 867 } else { 868 String RefsEntityName = 869 xmiHelper.qualifiedName(cls) + "Associations"; 870 String temp = baseCls; 871 String RefsList = getAllReferences3(cls, temp); 872 if (RefsList.length() > 0) { 873 RefsList = "(" + RefsList + ")"; 874 out.println( 876 "<!ENTITY % " 877 + RefsEntityName 878 + " \"" 879 + RefsList 880 + "\">"); 881 _entity_refs.put(_key, ""); 882 } 883 baseCls = baseCls + " " + _nclass; 884 temp = baseCls; 885 prevCls = prevCls + " " + _nclass; 886 887 org.omg.mof.Model.Class[] _sub_classes = mofHelper.subClassesOfClass(cls); 889 for (int i = 0; i < _sub_classes.length; i++) { 890 org.omg.mof.Model.Class _class = _sub_classes[i]; 891 baseCls = temp; 892 outputRefsEntityDef3(_class, prevCls, baseCls); 893 } 894 } 895 } 896 } 897 898 private java.util.Hashtable _entity_comps = new java.util.Hashtable (); 900 public void outputCompsEntityDef3( 901 org.omg.mof.Model.Class cls, 902 String prevCls, 903 String baseCls) 904 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 905 906 logger.log(Level.FINER, "DTD outputCompsEntiryDef3 of a class"); 907 String _key = cls.ref_mof_id(); 908 if (_entity_comps.containsKey(_key)) { 909 } else { 910 String _nclass = _key; 911 if (prevCls.indexOf(_nclass) != -1) { 912 String rslt = ""; 913 } else { 914 String CompsEntityName = 915 xmiHelper.qualifiedName(cls) + "Compositions"; 916 String temp = baseCls; 917 String CompsList = getAllComposedRoles3(cls, temp); 918 if (CompsList.length() > 0) { 919 CompsList = "(" + CompsList + ")"; 920 out.println( 922 "<!ENTITY % " 923 + CompsEntityName 924 + " \"" 925 + CompsList 926 + "\">"); 927 _entity_comps.put(_key, ""); 928 } 929 baseCls = baseCls + " " + _nclass; 930 temp = baseCls; 931 prevCls = prevCls + " " + _nclass; 932 933 org.omg.mof.Model.Class[] _sub_classes = mofHelper.subClassesOfClass(cls); 935 for (int i = 0; i < _sub_classes.length; i++) { 936 org.omg.mof.Model.Class _class = _sub_classes[i]; 937 baseCls = temp; 938 outputCompsEntityDef3(_class, prevCls, baseCls); 939 } 940 } 941 } 942 } 943 944 public String getAllInstanceAttributes3( 946 org.omg.mof.Model.Class cls, 947 String baseCls) 948 throws org.omg.mof.Reflective.MofError , NotSet{ 949 950 logger.log(Level.FINER, "DTD getAllInstanceAttributes3 of a class"); 951 String parentEntity = ""; 952 String parentContents = ""; 953 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 954 for (int i = 0; i < parent.length; i++) { 955 org.omg.mof.Model.Class _supertype = 956 org.omg.mof.Model.ClassHelper.narrow(parent[i]); 957 String _key = _supertype.ref_mof_id(); 958 String _nclass = _key; 959 if (baseCls.indexOf(_nclass) != -1) { 960 961 if (_entity_props.containsKey(_key)) { 963 parentEntity = 964 "%" + xmiHelper.qualifiedName(_supertype) + "Properties;"; 965 } 966 } else { 967 String temp = getParentAttributes3(_supertype, baseCls); 968 if ((temp.length() > 0) && (parentContents.length() > 0)) { 969 parentContents = parentContents + ", "; 970 } 971 parentContents = parentContents + temp; 972 } 973 } 974 975 if ((parentEntity.length() > 0) && (parentContents.length() > 0)) 976 parentEntity = parentEntity + ", "; 977 parentContents = parentEntity + parentContents; 978 String temp = getAttributes(cls, "instance"); 979 if ((temp.length() > 0) && (parentContents.length() > 0)) 980 parentContents = parentContents + ", "; 981 return parentContents + temp; 982 } 983 984 public String getAllReferences3( 986 org.omg.mof.Model.Class cls, 987 String baseCls) 988 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 989 990 logger.log(Level.FINER, "DTD getAllReferences3 of a class"); 991 String parentEntity = ""; 992 String parentContents = ""; 993 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 994 for (int i = 0; i < parent.length; i++) { 995 org.omg.mof.Model.Class _supertype = 996 org.omg.mof.Model.ClassHelper.narrow(parent[i]); 997 String _key = _supertype.ref_mof_id(); 998 String _nclass = _key; 999 if (baseCls.indexOf(_nclass) != -1) { 1000 if (_entity_refs.containsKey(_key)) { 1002 parentEntity = 1003 "%" 1004 + xmiHelper.qualifiedName(_supertype) 1005 + "Associations;"; 1006 } 1007 } else { 1008 String temp = getParentReferences3(_supertype, baseCls); 1009 if ((temp.length() > 0) && (parentContents.length() > 0)) { 1010 parentContents = parentContents + ", "; 1011 } 1012 parentContents = parentContents + temp; 1013 } 1014 } 1015 1016 if ((parentEntity.length() > 0) && (parentContents.length() > 0)) 1017 parentEntity = parentEntity + ", "; 1018 parentContents = parentEntity + parentContents; 1019 String temp = getReferences(cls); 1020 if ((temp.length() > 0) && (parentContents.length() > 0)) { 1025 parentContents = parentContents + ", "; 1026 temp = "(" + temp + ")"; 1027 } 1028 return parentContents + temp; 1029 } 1030 1031 public String getAllComposedRoles3( 1033 org.omg.mof.Model.Class cls, 1034 String baseCls) 1035 throws org.omg.mof.Reflective.MofError , NotSet{ 1036 1037 logger.log(Level.FINER, "DTD getAllComposedRoles3 of a class"); 1038 String parentEntity = ""; 1039 String parentContents = ""; 1040 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 1041 for (int i = 0; i < parent.length; i++) { 1042 org.omg.mof.Model.Class _supertype = 1043 org.omg.mof.Model.ClassHelper.narrow(parent[i]); 1044 String _key = _supertype.ref_mof_id(); 1045 String _nclass = _key; 1046 if (baseCls.indexOf(_nclass) != -1) { 1047 if (_entity_comps.containsKey(_key)) { 1049 parentEntity = 1050 "%" 1051 + xmiHelper.qualifiedName(_supertype) 1052 + "Compositions;"; 1053 } 1054 } else { 1055 String temp = getParentCompositionRoles3(_supertype, baseCls); 1056 if ((temp.length() > 0) && (parentContents.length() > 0)) { 1057 parentContents = parentContents + ", "; 1058 } 1059 parentContents = parentContents + temp; 1060 } 1061 } 1062 1063 if ((parentEntity.length() > 0) && (parentContents.length() > 0)) 1064 parentEntity = parentEntity + ", "; 1065 parentContents = parentEntity + parentContents; 1066 String temp = getComposedRoles(cls); 1067 if ((temp.length() > 0) && (parentContents.length() > 0)) 1068 parentContents = parentContents + ", "; 1069 return parentContents + temp; 1070 } 1071 1072 public String getParentAttributes3( 1074 org.omg.mof.Model.Class cls, 1075 String baseCls) 1076 throws org.omg.mof.Reflective.MofError , NotSet{ 1077 1078 logger.log(Level.FINER, "DTD getParentAttributes3 of a class"); 1079 String _nclass = cls.ref_mof_id(); 1080 if (baseCls.indexOf(_nclass) != -1) { 1081 return ""; 1082 } else { 1083 String parentContents = ""; 1084 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 1085 for (int i = 0; i < parent.length; i++) { 1086 org.omg.mof.Model.Class _supertype = 1087 org.omg.mof.Model.ClassHelper.narrow(parent[i]); 1088 String temp = getParentAttributes3(_supertype, baseCls); 1089 if ((temp.length() > 0) && (parentContents.length() > 0)) 1090 parentContents = parentContents + ", "; 1091 parentContents = parentContents + temp; 1092 } 1093 String temp = getAttributes(cls, "instance"); 1094 if ((temp.length() > 0) && (parentContents.length() > 0)) 1095 parentContents = parentContents + ", "; 1096 return parentContents + temp; 1097 } 1098 } 1099 1100 public String getParentReferences3( 1102 org.omg.mof.Model.Class cls, 1103 String baseCls) 1104 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1105 1106 logger.log(Level.FINER, "DTD getParentReferences3 of a class"); 1107 String _nclass = cls.ref_mof_id(); 1108 if (baseCls.indexOf(_nclass) != -1) { 1109 return ""; 1110 } else { 1111 String parentContents = ""; 1112 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 1113 for (int i = 0; i < parent.length; i++) { 1114 org.omg.mof.Model.Class _supertype = 1115 org.omg.mof.Model.ClassHelper.narrow(parent[i]); 1116 String temp = getParentAttributes3(_supertype, baseCls); 1117 if ((temp.length() > 0) && (parentContents.length() > 0)) 1118 parentContents = parentContents + ", "; 1119 parentContents = parentContents + temp; 1120 } 1121 String temp = getReferences(cls); 1122 if ((temp.length() > 0) && (parentContents.length() > 0)) 1123 parentContents = parentContents + ", "; 1124 return parentContents + temp; 1125 } 1126 } 1127 1128 public String getParentCompositionRoles3( 1130 org.omg.mof.Model.Class cls, 1131 String baseCls) 1132 throws org.omg.mof.Reflective.MofError , NotSet { 1133 1134 logger.log(Level.FINER, "DTD getParentCompositionRoles3 of a class"); 1135 String _nclass = cls.name(); 1136 if (baseCls.indexOf(_nclass) != -1) { 1137 return ""; 1138 } else { 1139 String parentContents = ""; 1140 org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes(); 1141 for (int i = 0; i < parent.length; i++) { 1142 org.omg.mof.Model.Class _supertype = 1143 org.omg.mof.Model.ClassHelper.narrow(parent[i]); 1144 String temp = getParentCompositionRoles3(_supertype, baseCls); 1145 if ((temp.length() > 0) && (parentContents.length() > 0)) 1146 parentContents = parentContents + ", "; 1147 parentContents = parentContents + temp; 1148 } 1149 String temp = getComposedRoles(cls); 1150 if ((temp.length() > 0) && (parentContents.length() > 0)) 1151 parentContents = parentContents + ", "; 1152 return parentContents + temp; 1153 } 1154 } 1155 1156 public void generate(org.omg.mof.Model.Package _package) 1159 throws 1160 org.omg.mof.Reflective.MofError, 1161 org.omg.mof.Reflective.NotSet, 1162 org.omg.CORBA.TypeCodePackage.BadKind , 1163 org.omg.CORBA.TypeCodePackage.Bounds { 1164 1165 logger.log(Level.FINE, "DTD generate the DTD"); 1166 out.println( 1168 "<!-- ______________________________________________________________ -->"); 1169 out.println("<!-- -->"); 1170 out.println( 1171 "<!-- XMI is the top-level XML element for XMI transfer text -->"); 1172 out.println( 1173 "<!-- ______________________________________________________________ -->"); 1174 out.println( 1175 "<!ELEMENT XMI (XMI.header?, XMI.content?, XMI.difference*, XMI.extensions*)>"); 1176 out.println("<!ATTLIST XMI"); 1177 out.println(" xmi.version CDATA #FIXED \"1.0\""); 1178 out.println(" timestamp CDATA #IMPLIED"); 1179 out.println(" verified (true | false) #IMPLIED"); 1180 out.println(">"); 1181 out.println( 1182 "<!-- _______________________________________________________________ -->"); 1183 out.println("<!-- -->"); 1184 out.println( 1185 "<!-- XMI.header contains documentation and identifies the model, -->"); 1186 out.println("<!-- metamodel, and metametamodel -->"); 1187 out.println( 1188 "<!-- _______________________________________________________________ -->"); 1189 out.println( 1190 "<!ELEMENT XMI.header (XMI.documentation?, XMI.model*, XMI.metamodel*, XMI.metametamodel*, XMI.import*)>"); 1191 out.println( 1192 "<!-- _______________________________________________________________ -->"); 1193 out.println("<!-- -->"); 1194 out.println("<!-- documentation for transfer data -->"); 1195 out.println( 1196 "<!-- _______________________________________________________________ -->"); 1197 out.println( 1198 "<!ELEMENT XMI.documentation (#PCDATA | XMI.owner | XMI.contact | XMI.longDescription | XMI.shortDescription | XMI.exporter | XMI.exporterVersion | XMI.notice)*>"); 1199 out.println("<!ELEMENT XMI.owner ANY>"); 1200 out.println("<!ELEMENT XMI.contact ANY>"); 1201 out.println("<!ELEMENT XMI.longDescription ANY>"); 1202 out.println("<!ELEMENT XMI.shortDescription ANY>"); 1203 out.println("<!ELEMENT XMI.exporter ANY>"); 1204 out.println("<!ELEMENT XMI.exporterVersion ANY>"); 1205 out.println("<!ELEMENT XMI.exporterID ANY>"); 1206 out.println("<!ELEMENT XMI.notice ANY>"); 1207 out.println( 1208 "<!-- _______________________________________________________________ -->"); 1209 out.println("<!-- -->"); 1210 out.println( 1211 "<!-- XMI.element.att defines the attributes that each XML element -->"); 1212 out.println( 1213 "<!-- that corresponds to a metamodel class must have to conform to -->"); 1214 out.println("<!-- the XMI specification. -->"); 1215 out.println( 1216 "<!-- _______________________________________________________________ -->"); 1217 out.println( 1218 "<!ENTITY % XMI.element.att \"xmi.id ID #IMPLIED xmi.label CDATA #IMPLIED xmi.uuid CDATA #IMPLIED \">"); 1219 out.println( 1220 "<!-- _______________________________________________________________ -->"); 1221 out.println("<!-- -->"); 1222 out.println( 1223 "<!-- XMI.link.att defines the attributes that each XML element that -->"); 1224 out.println( 1225 "<!-- corresponds to a metamodel class must have to enable it to -->"); 1226 out.println( 1227 "<!-- function as a simple XLink as well as refer to model -->"); 1228 out.println("<!-- constructs within the same XMI file. -->"); 1229 out.println( 1230 "<!-- _______________________________________________________________ -->"); 1231 out.println( 1232 "<!ENTITY % XMI.link.att \"href CDATA #IMPLIED xmi.idref IDREF #IMPLIED\">"); 1233 out.println( 1234 "<!-- _______________________________________________________________ -->"); 1235 out.println("<!-- -->"); 1236 out.println( 1237 "<!-- XMI.model identifies the model(s) being transferred -->"); 1238 out.println( 1239 "<!-- _______________________________________________________________ -->"); 1240 out.println("<!ELEMENT XMI.model ANY>"); 1241 out.println("<!ATTLIST XMI.model"); 1242 out.println(" %XMI.link.att; "); 1243 out.println(" xmi.name CDATA #REQUIRED"); 1244 out.println(" xmi.version CDATA #IMPLIED"); 1245 out.println(">"); 1246 out.println( 1247 "<!-- _______________________________________________________________ -->"); 1248 out.println("<!-- -->"); 1249 out.println( 1250 "<!-- XMI.metamodel identifies the metamodel(s) for the transferred -->"); 1251 out.println("<!-- data -->"); 1252 out.println( 1253 "<!-- _______________________________________________________________ -->"); 1254 out.println("<!ELEMENT XMI.metamodel ANY>"); 1255 out.println( 1256 "<!ATTLIST XMI.metamodel %XMI.link.att;xmi.name CDATA #REQUIRED xmi.version CDATA #IMPLIED >"); 1257 out.println( 1258 "<!-- _______________________________________________________________ -->"); 1259 out.println("<!-- -->"); 1260 out.println( 1261 "<!-- XMI.metametamodel identifies the metametamodel(s) for the -->"); 1262 out.println("<!-- transferred data -->"); 1263 out.println( 1264 "<!-- _______________________________________________________________ -->"); 1265 out.println("<!ELEMENT XMI.metametamodel ANY>"); 1266 out.println("<!ATTLIST XMI.metametamodel"); 1267 out.println(" %XMI.link.att; "); 1268 out.println(" xmi.name CDATA #REQUIRED"); 1269 out.println(" xmi.version CDATA #IMPLIED"); 1270 out.println(">"); 1271 out.println( 1272 "<!-- _______________________________________________________________ -->"); 1273 out.println("<!-- -->"); 1274 out.println("<!-- XMI.import identifies imported metamodel(s) -->"); 1275 out.println("<!-- -->"); 1276 out.println( 1277 "<!-- _______________________________________________________________ -->"); 1278 out.println("<!ELEMENT XMI.import ANY>"); 1279 out.println("<!ATTLIST XMI.import"); 1280 out.println(" %XMI.link.att; "); 1281 out.println(" xmi.name CDATA #REQUIRED"); 1282 out.println(" xmi.version CDATA #IMPLIED"); 1283 out.println(">"); 1284 out.println( 1285 "<!-- _______________________________________________________________ -->"); 1286 out.println("<!-- -->"); 1287 out.println( 1288 "<!-- XMI.content is the actual data being transferred -->"); 1289 out.println( 1290 "<!-- _______________________________________________________________ -->"); 1291 out.println("<!ELEMENT XMI.content ANY>"); 1292 out.println( 1293 "<!-- _______________________________________________________________ -->"); 1294 out.println("<!-- -->"); 1295 out.println( 1296 "<!-- XMI.extensions contains data to transfer that does not conform -->"); 1297 out.println("<!-- to the metamodel(s) in the header -->"); 1298 out.println( 1299 "<!-- _______________________________________________________________ -->"); 1300 out.println("<!ELEMENT XMI.extensions ANY>"); 1301 out.println("<!ATTLIST XMI.extensions"); 1302 out.println(" xmi.extender CDATA #REQUIRED"); 1303 out.println(">"); 1304 out.println( 1305 "<!-- _______________________________________________________________ -->"); 1306 out.println("<!-- -->"); 1307 out.println( 1308 "<!-- extension contains information related to a specific model -->"); 1309 out.println( 1310 "<!-- construct that is not defined in the metamodel(s) in the -->"); 1311 out.println("<!-- header -->"); 1312 out.println( 1313 "<!-- _______________________________________________________________ -->"); 1314 out.println("<!ELEMENT XMI.extension ANY>"); 1315 out.println("<!ATTLIST XMI.extension"); 1316 out.println(" %XMI.element.att; "); 1317 out.println(" %XMI.link.att; "); 1318 out.println(" xmi.extender CDATA #REQUIRED"); 1319 out.println(" xmi.extenderID CDATA #IMPLIED"); 1320 out.println(">"); 1321 out.println( 1322 "<!-- _______________________________________________________________ -->"); 1323 out.println("<!-- -->"); 1324 out.println( 1325 "<!-- XMI.difference holds XML elements representing differences to -->"); 1326 out.println("<!-- a base model -->"); 1327 out.println( 1328 "<!-- _______________________________________________________________ -->"); 1329 out.println( 1330 "<!ELEMENT XMI.difference (XMI.difference | XMI.delete | XMI.add | XMI.replace)*>"); 1331 out.println("<!ATTLIST XMI.difference"); 1332 out.println(" %XMI.element.att; "); 1333 out.println(" %XMI.link.att; "); 1334 out.println(">"); 1335 out.println( 1336 "<!-- _______________________________________________________________ -->"); 1337 out.println("<!-- -->"); 1338 out.println( 1339 "<!-- XMI.delete represents a deletion from a base model -->"); 1340 out.println( 1341 "<!-- _______________________________________________________________ -->"); 1342 out.println("<!ELEMENT XMI.delete EMPTY>"); 1343 out.println("<!ATTLIST XMI.delete"); 1344 out.println(" %XMI.element.att; "); 1345 out.println(" %XMI.link.att; "); 1346 out.println(">"); 1347 out.println( 1348 "<!-- _______________________________________________________________ -->"); 1349 out.println("<!-- -->"); 1350 out.println("<!-- XMI.add represents an addition to a base model -->"); 1351 out.println( 1352 "<!-- _______________________________________________________________ -->"); 1353 out.println("<!ELEMENT XMI.add ANY>"); 1354 out.println("<!ATTLIST XMI.add"); 1355 out.println(" %XMI.element.att; "); 1356 out.println(" %XMI.link.att; "); 1357 out.println(" xmi.position CDATA \"-1\""); 1358 out.println(">"); 1359 out.println( 1360 "<!-- _______________________________________________________________ -->"); 1361 out.println("<!-- -->"); 1362 out.println( 1363 "<!-- XMI.replace represents the replacement of a model construct -->"); 1364 out.println("<!-- with another model construct in a base model -->"); 1365 out.println( 1366 "<!-- _______________________________________________________________ -->"); 1367 out.println("<!ELEMENT XMI.replace ANY>"); 1368 out.println("<!ATTLIST XMI.replace"); 1369 out.println(" %XMI.element.att; "); 1370 out.println(" %XMI.link.att; "); 1371 out.println(" xmi.position CDATA \"-1\""); 1372 out.println(">"); 1373 out.println( 1374 "<!-- _______________________________________________________________ -->"); 1375 out.println("<!-- -->"); 1376 out.println( 1377 "<!-- XMI.reference may be used to refer to data types not defined -->"); 1378 out.println("<!-- in the metamodel -->"); 1379 out.println( 1380 "<!-- _______________________________________________________________ -->"); 1381 out.println("<!ELEMENT XMI.reference ANY>"); 1382 out.println("<!ATTLIST XMI.reference"); 1383 out.println(" %XMI.link.att; "); 1384 out.println(">"); 1385 out.println( 1386 "<!-- _______________________________________________________________ -->"); 1387 out.println("<!-- -->"); 1388 out.println( 1389 "<!-- This section contains the declaration of XML elements -->"); 1390 out.println("<!-- representing data types -->"); 1391 out.println( 1392 "<!-- _______________________________________________________________ -->"); 1393 out.println("<!ELEMENT XMI.TypeDefinitions ANY>"); 1394 out.println("<!ELEMENT XMI.field ANY>"); 1395 out.println("<!ELEMENT XMI.seqItem ANY>"); 1396 out.println("<!ELEMENT XMI.octetStream (#PCDATA)>"); 1397 out.println("<!ELEMENT XMI.unionDiscrim ANY>"); 1398 out.println("<!ELEMENT XMI.enum EMPTY>"); 1399 out.println("<!ATTLIST XMI.enum"); 1400 out.println(" xmi.value CDATA #REQUIRED"); 1401 out.println(">"); 1402 out.println("<!ELEMENT XMI.any ANY>"); 1403 out.println("<!ATTLIST XMI.any"); 1404 out.println(" %XMI.link.att; "); 1405 out.println(" xmi.type CDATA #IMPLIED"); 1406 out.println(" xmi.name CDATA #IMPLIED"); 1407 out.println(">"); 1408 out.println( 1409 "<!ELEMENT XMI.CorbaTypeCode (XMI.CorbaTcAlias | XMI.CorbaTcStruct | XMI.CorbaTcSequence | XMI.CorbaTcArray | XMI.CorbaTcEnum | XMI.CorbaTcUnion | XMI.CorbaTcExcept | XMI.CorbaTcString | XMI.CorbaTcWstring | XMI.CorbaTcShort | XMI.CorbaTcLong | XMI.CorbaTcUshort | XMI.CorbaTcUlong | XMI.CorbaTcFloat | XMI.CorbaTcDouble | XMI.CorbaTcBoolean | XMI.CorbaTcChar | XMI.CorbaTcWchar | XMI.CorbaTcOctet | XMI.CorbaTcAny | XMI.CorbaTcTypeCode | XMI.CorbaTcPrincipal | XMI.CorbaTcNull | XMI.CorbaTcVoid | XMI.CorbaTcLongLong | XMI.CorbaTcLongDouble)>"); 1410 out.println("<!ATTLIST XMI.CorbaTypeCode"); 1411 out.println(" %XMI.element.att; "); 1412 out.println(">"); 1413 out.println("<!ELEMENT XMI.CorbaTcAlias (XMI.CorbaTypeCode)>"); 1414 out.println("<!ATTLIST XMI.CorbaTcAlias"); 1415 out.println(" xmi.tcName CDATA #REQUIRED"); 1416 out.println(" xmi.tcId CDATA #IMPLIED"); 1417 out.println(">"); 1418 out.println("<!ELEMENT XMI.CorbaTcStruct (XMI.CorbaTcField)*>"); 1419 out.println("<!ATTLIST XMI.CorbaTcStruct"); 1420 out.println(" xmi.tcName CDATA #REQUIRED"); 1421 out.println(" xmi.tcId CDATA #IMPLIED"); 1422 out.println(">"); 1423 out.println("<!ELEMENT XMI.CorbaTcField (XMI.CorbaTypeCode)>"); 1424 out.println("<!ATTLIST XMI.CorbaTcField"); 1425 out.println(" xmi.tcName CDATA #REQUIRED"); 1426 out.println(">"); 1427 out.println( 1428 "<!ELEMENT XMI.CorbaTcSequence (XMI.CorbaTypeCode | XMI.CorbaRecursiveType)>"); 1429 out.println("<!ATTLIST XMI.CorbaTcSequence"); 1430 out.println(" xmi.tcLength CDATA #REQUIRED"); 1431 out.println(">"); 1432 out.println("<!ELEMENT XMI.CorbaRecursiveType EMPTY>"); 1433 out.println("<!ATTLIST XMI.CorbaRecursiveType"); 1434 out.println(" xmi.offset CDATA #REQUIRED"); 1435 out.println(">"); 1436 out.println("<!ELEMENT XMI.CorbaTcArray (XMI.CorbaTypeCode)>"); 1437 out.println("<!ATTLIST XMI.CorbaTcArray"); 1438 out.println(" xmi.tcLength CDATA #REQUIRED"); 1439 out.println(">"); 1440 out.println("<!ELEMENT XMI.CorbaTcObjRef EMPTY>"); 1441 out.println("<!ATTLIST XMI.CorbaTcObjRef"); 1442 out.println(" xmi.tcName CDATA #REQUIRED"); 1443 out.println(" xmi.tcId CDATA #IMPLIED"); 1444 out.println(">"); 1445 out.println("<!ELEMENT XMI.CorbaTcEnum (XMI.CorbaTcEnumLabel)>"); 1446 out.println("<!ATTLIST XMI.CorbaTcEnum"); 1447 out.println(" xmi.tcName CDATA #REQUIRED"); 1448 out.println(" xmi.tcId CDATA #IMPLIED"); 1449 out.println(">"); 1450 out.println("<!ELEMENT XMI.CorbaTcEnumLabel EMPTY>"); 1451 out.println("<!ATTLIST XMI.CorbaTcEnumLabel"); 1452 out.println(" xmi.tcName CDATA #REQUIRED"); 1453 out.println(">"); 1454 out.println( 1455 "<!ELEMENT XMI.CorbaTcUnionMbr (XMI.CorbaTypeCode, XMI.any)>"); 1456 out.println("<!ATTLIST XMI.CorbaTcUnionMbr"); 1457 out.println(" xmi.tcName CDATA #REQUIRED"); 1458 out.println(">"); 1459 out.println( 1460 "<!ELEMENT XMI.CorbaTcUnion (XMI.CorbaTypeCode, XMI.CorbaTcUnionMbr*)>"); 1461 out.println("<!ATTLIST XMI.CorbaTcUnion"); 1462 out.println(" xmi.tcName CDATA #REQUIRED"); 1463 out.println(" xmi.tcId CDATA #IMPLIED"); 1464 out.println(">"); 1465 out.println("<!ELEMENT XMI.CorbaTcExcept (XMI.CorbaTcField)*>"); 1466 out.println("<!ATTLIST XMI.CorbaTcExcept"); 1467 out.println(" xmi.tcName CDATA #REQUIRED"); 1468 out.println(" xmi.tcId CDATA #IMPLIED"); 1469 out.println(">"); 1470 out.println("<!ELEMENT XMI.CorbaTcString EMPTY>"); 1471 out.println("<!ATTLIST XMI.CorbaTcString"); 1472 out.println(" xmi.tcLength CDATA #REQUIRED"); 1473 out.println(">"); 1474 out.println("<!ELEMENT XMI.CorbaTcWstring EMPTY>"); 1475 out.println("<!ATTLIST XMI.CorbaTcWstring"); 1476 out.println(" xmi.tcLength CDATA #REQUIRED"); 1477 out.println(">"); 1478 out.println("<!ELEMENT XMI.CorbaTcFixed EMPTY>"); 1479 out.println("<!ATTLIST XMI.CorbaTcFixed"); 1480 out.println(" xmi.tcDigits CDATA #REQUIRED"); 1481 out.println(" xmi.tcScale CDATA #REQUIRED"); 1482 out.println(">"); 1483 out.println("<!ELEMENT XMI.CorbaTcShort EMPTY>"); 1484 out.println("<!ELEMENT XMI.CorbaTcLong EMPTY>"); 1485 out.println("<!ELEMENT XMI.CorbaTcUshort EMPTY>"); 1486 out.println("<!ELEMENT XMI.CorbaTcUlong EMPTY>"); 1487 out.println("<!ELEMENT XMI.CorbaTcFloat EMPTY>"); 1488 out.println("<!ELEMENT XMI.CorbaTcDouble EMPTY>"); 1489 out.println("<!ELEMENT XMI.CorbaTcBoolean EMPTY>"); 1490 out.println("<!ELEMENT XMI.CorbaTcChar EMPTY>"); 1491 out.println("<!ELEMENT XMI.CorbaTcWchar EMPTY>"); 1492 out.println("<!ELEMENT XMI.CorbaTcOctet EMPTY>"); 1493 out.println("<!ELEMENT XMI.CorbaTcAny EMPTY>"); 1494 out.println("<!ELEMENT XMI.CorbaTcTypeCode EMPTY>"); 1495 out.println("<!ELEMENT XMI.CorbaTcPrincipal EMPTY>"); 1496 out.println("<!ELEMENT XMI.CorbaTcNull EMPTY>"); 1497 out.println("<!ELEMENT XMI.CorbaTcVoid EMPTY>"); 1498 out.println("<!ELEMENT XMI.CorbaTcLongLong EMPTY>"); 1499 out.println("<!ELEMENT XMI.CorbaTcLongDouble EMPTY>"); 1500 1501 entityDTD(_package); 1503 packageDTD(_package); 1505 logger.log(Level.FINE, "DTD DTD is Generated"); 1506 } 1507 1508 public void packageDTD(org.omg.mof.Model.Package _package) 1510 throws 1511 org.omg.mof.Reflective.MofError, 1512 org.omg.mof.Reflective.NotSet, 1513 org.omg.CORBA.TypeCodePackage.BadKind , 1514 org.omg.CORBA.TypeCodePackage.Bounds { 1515 1516 logger.log(Level.FINER, "DTD packageDTD of a package"); 1517 comment("The Classifier Attributs"); 1520 out.println(); 1521 org.omg.mof.Model.Class[] _classes_package = mofHelper.classesOfPackage(_package); 1522 for (int i = 0; i < _classes_package.length; i++) { 1523 MofAttribute[] _attributes = mofHelper.attributesOfClass( 1524 _classes_package[i], 1525 org.omg.mof.Model.ScopeKind.classifier_level, 1526 true); 1527 for (int j = 0; j < _attributes.length; j++) { 1528 attributeElementDTD(_attributes[j]); 1530 } 1531 } 1532 comment(""); 1533 out.println(); 1534 1535 comment("The Associations"); 1537 out.println(); 1538 Association[] _associations_package = mofHelper.associationsOfPackage(_package); 1539 for (int i = 0; i < _associations_package.length; i++) { 1540 org.omg.mof.Model.AssociationEnd[] _ass_ends = 1541 mofHelper.associationEndsOfAssociation(_associations_package[i]); 1542 boolean _has_compo = false; 1543 int j = 0; 1544 while ((j < _ass_ends.length) && (!_has_compo)) { 1545 org.omg.mof.Model.AssociationEnd _ass_end = _ass_ends[j]; 1546 if (_ass_end 1547 .aggregation() 1548 .equals(org.omg.mof.Model.AggregationKind.composite)) 1549 _has_compo = true; 1550 j++; 1551 } 1552 if (mofHelper.referencesOfAssociation(_associations_package[i]).length == 0) { 1553 associationDTD(_associations_package[i]); 1555 } else if(_has_compo) { 1556 compositionDTD(_associations_package[i]); 1558 } 1559 } 1560 comment(""); 1561 out.println(); 1562 1563 comment("The Classes"); 1565 out.println(); 1566 for (int i = 0; i < _classes_package.length; i++) { 1567 classDTD(_classes_package[i]); 1569 } 1570 1571 comment(""); 1573 out.println(); 1574 packageElementDef(_package); 1575 } 1576 1577 public void classDTD(org.omg.mof.Model.Class _class) 1579 throws 1580 org.omg.mof.Reflective.MofError, 1581 org.omg.mof.Reflective.NotSet, 1582 org.omg.CORBA.TypeCodePackage.Bounds , 1583 org.omg.CORBA.TypeCodePackage.BadKind { 1584 1585 logger.log(Level.FINER, "DTD classDTD of a class"); 1586 1587 MofAttribute[] _attributes = mofHelper.attributesOfClass( 1589 _class, 1590 org.omg.mof.Model.ScopeKind.instance_level, 1591 true); 1592 comment(_class.name()); 1593 out.println(); 1594 for (int i = 0; i < _attributes.length; i++) { 1595 attributeElementDTD(_attributes[i]); 1597 } 1598 1599 Reference[] _references = mofHelper.referencesOfClass(_class); 1601 1602 for (int i = 0; i < _references.length; i++) { 1603 org.omg.mof.Model.AssociationEnd _association_end = 1604 _references[i].exposed_end(); 1605 org.omg.mof.Model.Association _association = 1606 org.omg.mof.Model.AssociationHelper.narrow( 1607 _association_end.container()); 1608 1609 if (!_association.is_derived()) { 1610 if (!_association_end 1611 .aggregation() 1612 .equals(org.omg.mof.Model.AggregationKind.composite)) { 1613 { 1614 referenceElementDef(_references[i]); 1616 } 1617 } 1618 } 1619 } 1620 1621 classElementDef(_class); 1623 } 1624 1625 private java.util.Hashtable _attribute_elementDTD = 1627 new java.util.Hashtable (); 1628 public void attributeElementDTD(org.omg.mof.Model.MofAttribute _attribute) 1629 throws 1630 org.omg.mof.Reflective.MofError, 1631 org.omg.CORBA.TypeCodePackage.BadKind , 1632 org.omg.CORBA.TypeCodePackage.Bounds , 1633 org.omg.mof.Reflective.NotSet { 1634 1635 logger.log(Level.FINER, "DTD attributeElementDTD of an attribute"); 1636 org.omg.mof.Model.Classifier _type = _attribute.type(); 1637 if (_type._is_a(org.omg.mof.Model.DataTypeHelper.id())) { 1638 org.omg.mof.Model.DataType _data_type = 1639 org.omg.mof.Model.DataTypeHelper.narrow(_type); 1640 org.omg.CORBA.TypeCode _type_code = _data_type.type_code(); 1641 int _kind = _type_code.kind().value(); 1642 if ((_kind == org.omg.CORBA.TCKind._tk_boolean) 1643 || (_kind == org.omg.CORBA.TCKind._tk_enum)) { 1644 String _key = _type.ref_mof_id(); 1645 if (!_attribute_elementDTD.containsKey(_key)) { 1646 attributeEntityDef(_data_type); 1648 _attribute_elementDTD.put(_key, _type); 1649 } 1650 } 1651 } 1652 attributeElementDef(_attribute); 1654 1655 } 1656 1657 public void attributeEntityDef(org.omg.mof.Model.DataType _data_type) 1659 throws 1660 org.omg.mof.Reflective.MofError, 1661 org.omg.CORBA.TypeCodePackage.BadKind , 1662 org.omg.CORBA.TypeCodePackage.Bounds , NotSet{ 1663 1664 logger.log(Level.FINER, "DTD attributeEntityDef of a DataType"); 1665 org.omg.CORBA.TypeCode _type_code = _data_type.type_code(); 1666 int _kind = _type_code.kind().value(); 1667 String TypeName = xmiHelper.qualifiedName(_data_type); 1668 String enumvalues = ""; 1669 if (_kind == org.omg.CORBA.TCKind._tk_enum) { 1670 for (int i = 0; i < _type_code.member_count(); i++) { 1671 if (enumvalues.length() > 0) 1672 enumvalues = enumvalues + " | "; 1673 enumvalues = enumvalues + _type_code.member_name(i); 1674 } 1675 } else { 1676 if (_kind == org.omg.CORBA.TCKind._tk_boolean) { 1677 enumvalues = "true | false "; 1678 } 1679 } 1680 out.println( 1682 "<!ENTITY % " 1683 + TypeName 1684 + " \"xmi.value (" 1685 + enumvalues 1686 + ") #REQUIRED\">"); 1687 1688 } 1689 1690 public void attributeElementDef(org.omg.mof.Model.MofAttribute _attribute) 1692 throws 1693 org.omg.mof.Reflective.MofError, 1694 org.omg.CORBA.TypeCodePackage.BadKind , 1695 org.omg.CORBA.TypeCodePackage.Bounds , 1696 org.omg.mof.Reflective.NotSet { 1697 1698 logger.log(Level.FINER, "DTD attributeElementDef of an attribute"); 1699 1700 String AttribName = xmiHelper.qualifiedName(_attribute); 1701 String AttribContents; 1702 String AttribAttList = ""; 1703 String TypeName; 1704 boolean _tk_bool_enum = false; 1705 org.omg.mof.Model.Classifier _type = _attribute.type(); 1706 if (_type._is_a(org.omg.mof.Model.DataTypeHelper.id())) { 1707 org.omg.mof.Model.DataType _data_type = 1708 org.omg.mof.Model.DataTypeHelper.narrow(_type); 1709 org.omg.CORBA.TypeCode _type_code = _data_type.type_code(); 1710 int _kind = _type_code.kind().value(); 1711 if ((_kind == org.omg.CORBA.TCKind._tk_boolean) 1712 || (_kind == org.omg.CORBA.TCKind._tk_enum)) { 1713 AttribContents = "EMPTY"; 1714 TypeName = xmiHelper.qualifiedName(_data_type); 1715 AttribAttList = "\n\t\t%" + TypeName + ";"; 1716 _tk_bool_enum = true; 1717 } else { 1718 if ((_kind == org.omg.CORBA.TCKind._tk_string) 1719 || (_kind == org.omg.CORBA.TCKind._tk_wstring) 1720 || (_kind == org.omg.CORBA.TCKind._tk_char) 1721 || (_kind == org.omg.CORBA.TCKind._tk_wchar)) { 1722 AttribContents = "(#PCDATA | XMI.reference)*"; 1723 } else { 1724 if (_kind == org.omg.CORBA.TCKind._tk_struct) { 1725 AttribContents = "(XMI.field | XMI.reference)*"; 1726 } else { 1727 if (_kind == org.omg.CORBA.TCKind._tk_union) { 1728 AttribContents = "(XMI.unionDiscrim | XMI.field)*"; 1729 } else { 1730 if ((_kind == org.omg.CORBA.TCKind._tk_sequence) 1731 || (_kind == org.omg.CORBA.TCKind._tk_array)) { 1732 AttribContents = 1733 "(XMI.octetStream | XMI.seqltem | XMI.reference)*"; 1734 } else { 1735 if (_kind == org.omg.CORBA.TCKind._tk_any) { 1736 AttribContents = "(XMI.any)"; 1737 } else { 1738 if (_kind 1739 == org.omg.CORBA.TCKind._tk_objref) { 1740 AttribContents = "(XMI.reference)"; 1741 } else { 1742 if (_kind 1743 == org 1744 .omg 1745 .CORBA 1746 .TCKind 1747 ._tk_TypeCode) { 1748 AttribContents = 1749 "(XMI.CorbaTypeCode | XMI.reference)"; 1750 } else { 1751 AttribContents = 1752 "(#PCDATA | XMI.reference)*"; 1753 } 1754 } 1755 } 1756 } 1757 } 1758 } 1759 } 1760 } 1761 } else { 1762 org.omg.mof.Model.Class _class = 1764 org.omg.mof.Model.ClassHelper.narrow(_type); 1765 AttribContents = "(" + getClasses(_class, "") + ")"; 1766 } 1767 1768 out.println("<!ELEMENT " + AttribName + " " + AttribContents + ">"); 1770 if (_tk_bool_enum) { 1771 out.println( 1772 "<!ATTLIST " + AttribName + " " + AttribAttList + "\n>"); 1773 } 1774 out.println(); 1775 } 1776 1777 public void referenceElementDef(org.omg.mof.Model.Reference _reference) 1779 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1780 1781 logger.log(Level.FINER, "DTD referenceElementDef of a reference"); 1782 String RefName = xmiHelper.qualifiedName(_reference); 1783 org.omg.mof.Model.Class cls = 1784 org.omg.mof.Model.ClassHelper.narrow(_reference.type()); 1785 String m = getReferenceMultiplicity(_reference); 1786 String RefContents = "(" + getClasses(cls, "") + ")" + m; 1787 1788 out.println("<!ELEMENT " + RefName + " " + RefContents + ">"); 1790 out.println(); 1791 } 1792 1793 public void propertiesEntityDef(org.omg.mof.Model.Class _class) 1795 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1796 logger.log(Level.FINER, "DTD propertiesEntityDef of a class"); 1797 outputPropertiesEntityDef3(_class, "", ""); 1799 } 1800 1801 public void refsEntityDef(org.omg.mof.Model.Class _class) 1803 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1804 1805 logger.log(Level.FINER, "DTD refsEntityDef of a class"); 1806 outputRefsEntityDef3(_class, "", ""); 1808 } 1809 1810 public void compsEntityDef(org.omg.mof.Model.Class _class) 1812 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1813 1814 logger.log(Level.FINER, "DTD compsEntityDef of a class"); 1815 outputCompsEntityDef3(_class, "", ""); 1817 } 1818 1819 public void classElementDef(org.omg.mof.Model.Class _class) 1821 throws org.omg.mof.Reflective.MofError , NotSet{ 1822 1823 logger.log(Level.FINER, "DTD classElementDef of a class"); 1824 1825 String ClassName = xmiHelper.qualifiedName(_class); 1826 String props = ""; 1827 String _key = _class.ref_mof_id(); 1828 1829 if (_entity_props.containsKey(_key)) 1831 props = "%" + ClassName + "Properties" + ";"; 1832 String refs = ""; 1833 1834 if (_entity_refs.containsKey(_key)) 1836 refs = ", " + "%" + ClassName + "Associations" + ";"; 1837 refs = "(" + "XMI.extension" + "*" + refs + ")"; 1838 1839 String comps1 = ""; 1840 if (_entity_comps.containsKey(_key)) 1842 comps1 = "%" + ClassName + "Compositions" + ";"; 1843 1844 String comps2 = getContainedClasses(_class, ""); 1845 String ClassContents = 1846 props + ", " + refs + ", " + comps1 + ", " + comps2; 1847 1848 ClassContents = removeDanglingCommas(ClassContents); 1850 1851 if (ClassContents.length() == 0) 1853 ClassContents = "EMPTY"; 1854 else 1855 ClassContents = "(" + ClassContents + ")" + "?"; 1856 String ClassAttlisttems = 1857 "\n\t\t%XMI.element.att; \n\t\t%XMI.link.att;"; 1858 1859 out.println("<!ELEMENT " + ClassName + " " + ClassContents + ">"); 1861 out.println("<!ATTLIST " + ClassName + " " + ClassAttlisttems + "\n>"); 1862 } 1863 1864 public void compositionDTD(org.omg.mof.Model.Association _composition) 1866 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1867 1868 logger.log(Level.FINER, "DTD compositionDTD of an association"); 1869 comment(_composition.name()); 1871 out.println(); 1872 compositionElementDef(_composition); 1873 } 1874 1875 public void compositionElementDef( 1877 org.omg.mof.Model.Association _composition) 1878 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1879 1880 logger.log(Level.FINER, "DTD compositionElementDef of a composition"); 1881 1882 org.omg.mof.Model.Reference[] _references = 1883 mofHelper.referencesOfAssociation(_composition); 1884 boolean _find = false; 1885 int i = 0; 1886 org.omg.mof.Model.Reference _reference = null; 1887 while ((!_find) && (i < _references.length)) { 1888 _reference = _references[i]; 1889 if (_reference 1890 .exposed_end() 1891 .aggregation() 1892 .equals(org.omg.mof.Model.AggregationKind.composite)) 1893 _find = true; 1894 i++; 1895 } 1896 1897 org.omg.mof.Model.Class Container = 1898 org.omg.mof.Model.ClassHelper.narrow(_reference.container()); 1899 String RoleName = xmiHelper.qualifiedName(_reference); 1900 org.omg.mof.Model.Class Contained = 1901 org.omg.mof.Model.ClassHelper.narrow( 1902 _reference.referenced_end().type()); 1903 String CompContents = getClasses(Contained, ""); 1904 String m = getReferenceMultiplicity(_reference); 1906 CompContents = "(" + CompContents + ")" + m; 1907 1908 out.println("<!ELEMENT " + RoleName + " " + CompContents + ">"); 1910 1911 } 1912 1913 public void packageElementDef(org.omg.mof.Model.Package _package) 1915 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1916 1917 logger.log(Level.FINER, "DTD packageElementDef of package"); 1918 String PkgName = xmiHelper.format1(_package.name()); 1919 String atts = getClassLevelAttributes(_package); 1920 String atts2 = ""; 1921 1922 String classes = getPackageClasses(_package); 1934 String assns = getUnreferencedAssociations(_package); 1935 String pkgs = getContainedPackages(_package); 1936 String PkgContents = "(" + atts + ")" + "(" + atts2 + ")"; 1937 if (assns.length() != 0) 1938 if (pkgs.length() != 0) 1939 PkgContents = 1940 PkgContents 1941 + "(" 1942 + classes 1943 + " | " 1944 + assns 1945 + "|" 1946 + pkgs 1947 + ")*"; 1948 else 1949 PkgContents = 1950 PkgContents + "(" + classes + " | " + assns + ")*"; 1951 else if (pkgs.length() != 0) 1952 PkgContents = PkgContents + "(" + classes + " | " + pkgs + ")*"; 1953 else 1954 PkgContents = PkgContents + "(" + classes + ")*"; 1955 1956 for (int j = 0; j < PkgContents.length() - 1; j++) { 1958 for (int i = 0; i < PkgContents.length() - 1; i++) { 1959 String _v1 = String.valueOf(PkgContents.charAt(i)); 1960 String _v2 = String.valueOf(PkgContents.charAt(i + 1)); 1961 if ((_v1.compareTo("(") == 0) && (_v2.compareTo(")") == 0)) { 1962 PkgContents = 1963 PkgContents.substring(0, i) 1964 + PkgContents.substring(i + 2, PkgContents.length()); 1965 } 1966 } 1967 } 1968 1969 PkgContents = removeDanglingCommas(PkgContents); 1971 1972 if (PkgContents.length() > 0) 1973 PkgContents = "(" + PkgContents + ")"; 1974 else 1975 PkgContents = "EMPTY"; 1976 String PkgAttlistItems = "\n\t\t%XMI.element.att; \n\t\t%XMI.link.att;"; 1977 comment(_package.name()); 1978 out.println(); 1979 out.println(); 1980 out.println("<!ELEMENT " + PkgName + " " + PkgContents + ">"); 1981 out.println("<!ATTLIST " + PkgName + " " + PkgAttlistItems + "\n>"); 1982 } 1983 1984 public void entityDTD(org.omg.mof.Model.Package _package) 1986 throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet { 1987 logger.log(Level.FINER, "DTD entityDTD of a package"); 1988 outputEntityDefs3(_package); 1989 } 1990 1991 public void associationDTD(org.omg.mof.Model.Association _association) 1993 throws org.omg.mof.Reflective.MofError , NotSet{ 1994 1995 logger.log(Level.FINER, "DTD associationDTD of an association"); 1996 org.omg.mof.Model.AssociationEnd[] _association_ends = 1997 mofHelper.associationEndsOfAssociation(_association); 1998 comment(_association.name()); 1999 out.println(); 2000 associationEndDef(_association_ends[0]); 2001 associationEndDef(_association_ends[1]); 2002 associationDef(_association); 2003 } 2004 2005 public void associationEndDef( 2007 org.omg.mof.Model.AssociationEnd _association_end) 2008 throws org.omg.mof.Reflective.MofError , NotSet{ 2009 2010 logger.log(Level.FINER, "DTD associationEndDef of an association end"); 2011 String EndName = xmiHelper.qualifiedName(_association_end); 2012 String EndAtts = "\n\t\t%XMI.link.att;"; 2013 out.println("<!ELEMENT " + EndName + " EMPTY >"); 2014 out.println("<!ATTLIST " + EndName + " " + EndAtts + "\n>"); 2015 2016 } 2017 2018 public void associationDef(org.omg.mof.Model.Association _association) 2020 throws org.omg.mof.Reflective.MofError , NotSet{ 2021 2022 logger.log(Level.FINER, "DTD associationDef of an association"); 2023 String AssnName = xmiHelper.qualifiedName(_association); 2024 String EndAtts = "\n\t\t%XMI.element.att;"; 2025 out.println("<!ELEMENT " + AssnName + " EMPTY >"); 2026 out.println("<!ATTLIST " + AssnName + " " + EndAtts + "\n>"); 2027 } 2028 2029 public String removeDanglingCommas(String _string) { 2031 2032 logger.log(Level.FINER, "DTD removeDanglingCommas"); 2033 String rslt = _string; 2034 if (rslt.matches(" *,.*")) 2035 rslt = rslt.substring(rslt.indexOf(",") + 1); 2036 int i = 0; 2037 int j; 2038 while (i < rslt.length()) { 2039 String _v1 = String.valueOf(rslt.charAt(i)); 2040 if ((_v1.compareTo(",") == 0) && (i < rslt.length() - 1)) { 2041 j = i; 2042 i++; 2043 _v1 = String.valueOf(rslt.charAt(i)); 2044 while ((_v1.compareTo(" ") == 0) && (i < rslt.length() - 1)) { 2045 i++; 2046 _v1 = String.valueOf(rslt.charAt(i)); 2047 } 2048 if (_v1.compareTo(",") == 0) { 2049 rslt = 2050 rslt.substring(0, j + 1) 2051 + rslt.substring(i + 1, rslt.length()); 2052 i = j; 2053 } 2054 } else 2055 i++; 2056 } 2057 rslt = rslt.trim(); 2058 if (rslt.endsWith(",")) 2059 rslt = rslt.substring(0, rslt.length() - 1); 2060 return rslt; 2061 } 2062 2063 public void comment(String _string) { 2065 String _temp = 2066 "<!-- _______________________________________________________________ -->"; 2067 if (_string.compareTo("") == 0) 2068 out.println(_temp); 2069 else { 2070 int i = _string.length(); 2071 _temp = 2072 _temp.substring(0, 31) 2073 + " " 2074 + _string 2075 + " " 2076 + _temp.substring(33 + i, _temp.length()); 2077 out.println(_temp); 2078 } 2079 } 2080 2081 2085 public MOFCommon getMofHelper() { 2086 return mofHelper; 2087 } 2088 2089 2093 public XMICommon getXmiHelper() { 2094 return xmiHelper; 2095 } 2096 2097 2101 public void setMofHelper(MOFCommon mofHelper) { 2102 this.mofHelper = mofHelper; 2103 } 2104 2105 2109 public void setXmiHelper(XMICommon xmiHelper) { 2110 this.xmiHelper = xmiHelper; 2111 } 2112 2113} 2114 | Popular Tags |