KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > xmi > PackageGenerator


1 /**
2  * copyright 2002 2003 Laboratoire d'Informatique Paris 6 (LIP6)
3  *
4  * This file is part of ModFact.
5  *
6  * ModFact is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * at your option) any later version.
10  *
11  * ModFact is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with ModFact; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

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 /**
34  * @author Xavier Blanc
35  *
36  */

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     /**
47      * Set Input
48      */

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     /**
57      * Set Trace
58      */

59     public void setLogger(ModFactLogger log) {
60         logger = log;
61     }
62
63     /**
64      * Generate
65      */

66     public void generate() throws
67             org.omg.mof.Reflective.MofError,
68             org.omg.CORBA.TypeCodePackage.BadKind JavaDoc,
69             org.omg.CORBA.TypeCodePackage.Bounds JavaDoc,
70             org.omg.mof.Reflective.NotSet {
71         generate(input[0]);
72         out.flush();
73     }
74
75
76     // 7.2 Rules Set 1: Simple DTD
77

78     // GetAllInstanceAttributes: tous les attributs d'une classes et ses superclasses confondies 7.2.3
79
public String JavaDoc getAllInstanceAttributes(
80         org.omg.mof.Model.Class cls,
81         String JavaDoc previousCls)
82         throws org.omg.mof.Reflective.MofError , NotSet{
83         logger.log(Level.FINER, "DTD getAllInstanceAttributes of a class");
84         String JavaDoc _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 JavaDoc parentAtts = "";
90             for (int i = 0; i < parent.length; i++) {
91                 String JavaDoc 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 JavaDoc 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     // GetAttributes :les attributs Instance_level ou Classifier_level d'une class
110

111     public String JavaDoc getAttributes(org.omg.mof.Model.Class cls, String JavaDoc type)
112         throws org.omg.mof.Reflective.MofError , NotSet {
113         logger.log(Level.FINER, "DTD getAttrinbutes of a class");
114         String JavaDoc 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 JavaDoc name = xmiHelper.qualifiedName(attributes[i]);
130             String JavaDoc 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 = "*"; /*ou + pour DTD non relaxé */
135             else if ((_lower == 0) && (_upper == 1))
136                 m = "?";
137             else if ((_lower != 1) && (_upper != 1))
138                 m = "*";
139             else
140                 m = "?"; /*ou "" pour DTD non relaxé */
141             if (rslt.length() > 0)
142                 rslt = rslt + ", ";
143             rslt = rslt + name + m;
144         }
145         return rslt;
146     }
147
148     //GetAllReferences : toutes les références d'une classes
149
public String JavaDoc getAllReferences(
150         org.omg.mof.Model.Class cls,
151         String JavaDoc 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 JavaDoc _nclass = cls.name();
155         if (previousCls.indexOf(_nclass) != -1)
156             return "";
157         else {
158             org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes();
159             String JavaDoc parentRefs = "";
160             for (int i = 0; i < parent.length; i++) {
161                 String JavaDoc 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 JavaDoc 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     // GetReferences : toutes les references d'une classe
179
public String JavaDoc 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 JavaDoc 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             //deux ligne rajoutées qui ne sont pas dans l'algorithme, pour que la DTD soit compatible
191
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 JavaDoc name = xmiHelper.qualifiedName(references[i]);
198                     String JavaDoc m = getReferenceMultiplicity(references[i]);
199                     String JavaDoc temp = name + m;
200                     if (refs.length() > 0)
201                         refs = refs + ", ";
202                     refs = refs + temp;
203                 }
204             }
205         }
206         return refs;
207     }
208
209     //GetReferenceMultiplicity : donne la multiplictés d'une référence
210
public String JavaDoc 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 JavaDoc 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 = "*"; /*ou + pour DTD non relaxé */
226         else if ((_lower != 1) && (_upper != 1))
227             m = "*";
228         else
229             m = "?"; /*ou "" pour DTD non relaxé */
230         return m;
231     }
232
233     //GetContainedClasses : donne les classes contenues dans une classe dans le sens du namespace MOF
234
public String JavaDoc getContainedClasses(
235         org.omg.mof.Model.Class cls,
236         String JavaDoc previousCls)
237         throws org.omg.mof.Reflective.MofError , NotSet{
238         logger.log(Level.FINER, "DTD getContainedClasses of a class");
239         String JavaDoc _nclass = cls.name();
240         if (previousCls.indexOf(_nclass) != -1)
241             return "";
242         else {
243             org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes();
244             String JavaDoc parentClasses = "";
245             for (int i = 0; i < parent.length; i++) {
246                 String JavaDoc 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 JavaDoc classes = "";
256             org.omg.mof.Model.ModelElement[] _contents = cls.contents();
257
258             //récupérer le contenu de la classe et voir les éléments de type class
259
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 JavaDoc 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     //GetAllComposedRoles : donne les références qui ont références dont l'ExposedEnd vers une AssociationEnd d'une association
281
public String JavaDoc getAllComposedRoles(
282         org.omg.mof.Model.Class cls,
283         String JavaDoc previousCls)
284         throws org.omg.mof.Reflective.MofError , NotSet{
285         logger.log(Level.FINER, "DTD getAllComposedRoles of a class");
286         String JavaDoc _nclass = cls.name();
287         if (previousCls.indexOf(_nclass) != -1)
288             return "";
289         else {
290             org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes();
291             String JavaDoc parentRoles = "";
292             for (int i = 0; i < parent.length; i++) {
293                 String JavaDoc 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 JavaDoc 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     // GetComposedRoles : donne les références qui ont références dont l'ExposedEnd vers une AssociationEnd d'une association
312
public String JavaDoc 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 JavaDoc 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 JavaDoc name = xmiHelper.qualifiedName(references[i]);
323                 String JavaDoc 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     // GetClasses : donne la classe ainsi que toutes les classe qui dérivent d'elle
333
public String JavaDoc getClasses(org.omg.mof.Model.Class Cls, String JavaDoc 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 _nclass = Cls.name();
337
// if(prevCls.indexOf(_nclass)!= -1) return "";
338
// else{
339
// prevCls = prevCls+" "+_nclass;
340
String JavaDoc 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 = GetClasses(subclass[i], prevCls) ;
344
String JavaDoc 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     // GetClassLevelAttributes: tous les attributs ClassifierLevel dans les classes contenues dans le package
355
public String JavaDoc 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         // le traitement des packages parents et les package conteneur éventiellement
360
java.util.Vector JavaDoc _packages_c_p = new java.util.Vector JavaDoc();
361
362         //le conteneur du package
363
//org.omg.mof.Model.Namespace _container = pkg.container();
364
//if(_container!=null) _packages_c_p.addElement(org.omg.mof.Model.PackageHelper.narrow(_container));
365

366         //les packages dont il hérite
367
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         // début de l'algorithme
375
String JavaDoc 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 JavaDoc atts = "";
382         //récupérer les classes du package
383
org.omg.mof.Model.Class[] classes = mofHelper.classesOfPackage(pkg);
384
385         for (int i = 0; i < classes.length; i++) {
386             String JavaDoc 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     /* GetNestedClassLevelAttributes : donne toutes les attributs non dérivés
401     des classes contenues dans un package ainsi que dans toutes les packages contenues */

402
403     public String JavaDoc 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 JavaDoc rslt = "";
407         //récupérer les classes du package
408
org.omg.mof.Model.Class[] classes = mofHelper.classesOfPackage(pkg);
409
410         for (int i = 0; i < classes.length; i++) {
411             String JavaDoc 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     /*GetPackageClasses: donne toutes les classes contenues dans le pckage courant
424     ainsi que toutes les pckages dont il hérite ou il est contenu */

425     public String JavaDoc 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         // le traitement des packages parents et les package conteneur eventiellement
430
java.util.Vector JavaDoc _packages_c_p = new java.util.Vector JavaDoc();
431
432         //les packages dont il hérite
433
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         //le conteneur du package
441
//org.omg.mof.Model.Namespace _container = pkg.container();
442
//if(_container!=null) _packages_c_p.addElement(org.omg.mof.Model.PackageHelper.narrow(_container));
443

444         // début de l'algorithme
445
String JavaDoc 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 JavaDoc classes = "";
452         //récupérer les classes du package
453
org.omg.mof.Model.Class[] _classes = mofHelper.classesOfPackage(pkg);
454
455         for (int i = 0; i < _classes.length; i++) {
456             String JavaDoc 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     //GetContainedPackages : donne toutes les packages contenues dans le package courant ainsi que les packges contenus dans ses parents
468
public String JavaDoc 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         // début de l'algorithme
472
String JavaDoc parentPkgs = "";
473         //les packages dont il hérite
474
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         // //récupérer les packages contenus dans le package
482
// java.util.Vector _packages = new java.util.Vector();
483
// _packages = mofHelper.PackagesOfPackage(pkg);
484

485         String JavaDoc pkgs = "";
486         // for(int i=0; i< _packages.size() ; i++){
487
// org.omg.mof.Model.Package _sub_package = (org.omg.mof.Model.Package)_packages.elementAt(i);
488
// String Temp = mofHelper.QualifiedName(_sub_package);
489
// if(pkgs.length()>0) pkgs = pkgs+"|" ;
490
// pkgs = pkgs + Temp ;
491
// }
492
if ((parentPkgs.length() > 0) && (pkgs.length() > 0))
493             parentPkgs = pkgs + "|";
494         return parentPkgs + pkgs;
495     }
496
497     /*GetUnreferencedAssociations : donne toutes les associations sans références dans le package et ses packages parents */
498     public String JavaDoc 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         // début de l'algorithme
503
String JavaDoc parentAssns = "";
504
505         //les packages dont il hérite
506
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         //récupérer les associations contenus dans le package
515
Association[] associations = mofHelper.associationsOfPackage(pkg);
516
517         String JavaDoc 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 JavaDoc 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     // 7.3 Rules Set 2: Grouped entities
534

535     //7.3.4.1 OutputEntityDefs2
536
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         //récupérer les classes du package
541
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     //7.3.4.1 OutputPropertiesEntityDef2
553
public void outputPropertiesEntityDef2(
554         org.omg.mof.Model.Class cls,
555         String JavaDoc 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 JavaDoc _nclass = cls.name();
559         if (prevCls.indexOf(_nclass) != -1) {
560             String JavaDoc rslt = "";
561         } else {
562             String JavaDoc PropsEntityName = xmiHelper.qualifiedName(cls) + "Properties";
563             String JavaDoc PropsList = getAttributes(cls, "instance");
564             if (PropsList.length() > 0) {
565                 //pour la partie #8
566
}
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     //7.3.4.1 OutputRefsEntityDef2
578
public void outputRefsEntityDef2(
579         org.omg.mof.Model.Class cls,
580         String JavaDoc 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 JavaDoc _nclass = cls.name();
585         if (prevCls.indexOf(_nclass) != -1) {
586             String JavaDoc rslt = "";
587         } else {
588             String JavaDoc RefsEntityName = xmiHelper.qualifiedName(cls) + "Associations";
589             String JavaDoc RefsList = getReferences(cls);
590             if (RefsList.length() > 0) {
591                 RefsList = "(" + RefsList + ")";
592                 //pour la partie #9
593
}
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     //7.3.4.1 OutputCompsEntityDef2
605
public void outputCompsEntityDef2(
606         org.omg.mof.Model.Class cls,
607         String JavaDoc 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 JavaDoc _nclass = cls.name();
612         if (prevCls.indexOf(_nclass) != -1) {
613             String JavaDoc rslt = "";
614         } else {
615             String JavaDoc CompsEntityName = xmiHelper.qualifiedName(cls) + "Compositions";
616             String JavaDoc CompsList = getComposedRoles(cls);
617             if (CompsList.length() > 0) {
618                 CompsList = "(" + CompsList + ")";
619                 //pour la partie #9
620
}
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     //GetContainedClasses2 : donne les classes contenues dans une classe dans le sens du namespace MOF
632
public String JavaDoc 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 JavaDoc classes = "";
637         org.omg.mof.Model.ModelElement[] _contents = cls.contents();
638
639         //récupérer le contenu de la classe et voir les éléments de type class
640
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 JavaDoc 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     // GetPropertiesEntities2
655
public String JavaDoc getPropertiesEntities2(
656         org.omg.mof.Model.Class cls,
657         String JavaDoc prevCls)
658         throws org.omg.mof.Reflective.MofError , NotSet{
659
660         logger.log(Level.FINER, "DTD getPropertiesEntities2");
661         String JavaDoc _nclass = cls.name();
662         if (prevCls.indexOf(_nclass) != -1)
663             return "";
664         else {
665             String JavaDoc parentProps = "";
666             org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes();
667             ;
668             for (int i = 0; i < parent.length; i++) {
669                 String JavaDoc 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 JavaDoc ClassName = xmiHelper.qualifiedName(cls);
680             String JavaDoc props = "";
681             //ceci est généré si la Properties ENTITY de la partie #8 a été généré
682
if (parentProps.length() > 0)
683                 parentProps = parentProps + ", ";
684             props = "%" + ClassName + "Properties" + ";";
685             prevCls = prevCls + " " + _nclass;
686             return parentProps + props;
687         }
688     }
689
690     // GetRefsEntities2
691
public String JavaDoc getRefsEntities2(org.omg.mof.Model.Class cls, String JavaDoc prevCls)
692         throws org.omg.mof.Reflective.MofError , NotSet{
693
694         logger.log(Level.FINER, "DTD getRefsEntities2 of a class");
695         String JavaDoc _nclass = cls.name();
696         if (prevCls.indexOf(_nclass) != -1)
697             return "";
698         else {
699             String JavaDoc parentRefs = "";
700             org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes();
701             ;
702             for (int i = 0; i < parent.length; i++) {
703                 String JavaDoc 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 JavaDoc ClassName = xmiHelper.qualifiedName(cls);
714             String JavaDoc refs = "";
715             //ceci est généré si la References ENTITY de la partie #9 a été généré
716
if (parentRefs.length() > 0)
717                 parentRefs = parentRefs + ", ";
718             refs = "%" + ClassName + "Associations" + ";";
719             prevCls = prevCls + " " + _nclass;
720             return parentRefs + refs;
721         }
722     }
723
724     // GetCompsEntities2
725
public String JavaDoc getCompsEntities2(
726         org.omg.mof.Model.Class cls,
727         String JavaDoc prevCls)
728         throws org.omg.mof.Reflective.MofError , NotSet{
729
730         logger.log(Level.FINER, "DTD getCompsEntities2");
731         String JavaDoc _nclass = cls.name();
732         if (prevCls.indexOf(_nclass) != -1)
733             return "";
734         else {
735             String JavaDoc parentComps = "";
736             org.omg.mof.Model.GeneralizableElement[] parent = cls.supertypes();
737             ;
738             for (int i = 0; i < parent.length; i++) {
739                 String JavaDoc 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 JavaDoc ClassName = xmiHelper.qualifiedName(cls);
750             String JavaDoc comps = "";
751             //ceci est généré si la References ENTITY de la partie #9 a été généré
752
if (parentComps.length() > 0)
753                 parentComps = parentComps + ", ";
754             comps = "%" + ClassName + "Compositions" + ";";
755             prevCls = prevCls + " " + _nclass;
756             return parentComps + comps;
757         }
758     }
759
760     // 7.4 Rules Set 3: Hierarchical Grouped DTD
761

762     //7.4.4.1
763
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         //récupérer les classes du package
768
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     //7.4.4.2
806
private java.util.Hashtable JavaDoc _entity_props = new java.util.Hashtable JavaDoc();
807     public void outputPropertiesEntityDef3(
808         org.omg.mof.Model.Class cls,
809         String JavaDoc prevCls,
810         String JavaDoc baseCls)
811         throws org.omg.mof.Reflective.MofError, org.omg.mof.Reflective.NotSet {
812
813         String JavaDoc nm = cls.name();
814         logger.log(Level.FINER, "DTD outputPropsertiesEntityDef3 of a class"+ nm);
815         String JavaDoc _key = cls.ref_mof_id();
816         if (_entity_props.containsKey(_key)) {
817         } else {
818             String JavaDoc _nclass = _key;
819             if (prevCls.indexOf(_nclass) != -1) {
820                 String JavaDoc rslt = "";
821             } else {
822                 String JavaDoc PropsEntityName =
823                     xmiHelper.qualifiedName(cls) + "Properties";
824                 String JavaDoc temp = baseCls;
825                 String JavaDoc PropsList = getAllInstanceAttributes3(cls, temp);
826                 if (PropsList.length() > 0) {
827                     PropsList = "(" + PropsList + ")";
828                     //pour la partie #8
829
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                 //générer les entités pour les autres classes
842
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     //7.4.4.3 OutputRefsEntityDef2
853
private java.util.Hashtable JavaDoc _entity_refs = new java.util.Hashtable JavaDoc();
854     public void outputRefsEntityDef3(
855         org.omg.mof.Model.Class cls,
856         String JavaDoc prevCls,
857         String JavaDoc 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 JavaDoc _key = cls.ref_mof_id();
862         if (_entity_refs.containsKey(_key)) {
863         } else {
864             String JavaDoc _nclass = _key;
865             if (prevCls.indexOf(_nclass) != -1) {
866                 String JavaDoc rslt = "";
867             } else {
868                 String JavaDoc RefsEntityName =
869                     xmiHelper.qualifiedName(cls) + "Associations";
870                 String JavaDoc temp = baseCls;
871                 String JavaDoc RefsList = getAllReferences3(cls, temp);
872                 if (RefsList.length() > 0) {
873                     RefsList = "(" + RefsList + ")";
874                     //pour la partie #9
875
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                 //générer les entités pour les autres classes
888
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     //7.4.4.4
899
private java.util.Hashtable JavaDoc _entity_comps = new java.util.Hashtable JavaDoc();
900     public void outputCompsEntityDef3(
901         org.omg.mof.Model.Class cls,
902         String JavaDoc prevCls,
903         String JavaDoc 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 JavaDoc _key = cls.ref_mof_id();
908         if (_entity_comps.containsKey(_key)) {
909         } else {
910             String JavaDoc _nclass = _key;
911             if (prevCls.indexOf(_nclass) != -1) {
912                 String JavaDoc rslt = "";
913             } else {
914                 String JavaDoc CompsEntityName =
915                     xmiHelper.qualifiedName(cls) + "Compositions";
916                 String JavaDoc temp = baseCls;
917                 String JavaDoc CompsList = getAllComposedRoles3(cls, temp);
918                 if (CompsList.length() > 0) {
919                     CompsList = "(" + CompsList + ")";
920                     //pour la partie #10
921
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                 //générer les entités pour les autres classes
934
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     //7.4.4.5
945
public String JavaDoc getAllInstanceAttributes3(
946         org.omg.mof.Model.Class cls,
947         String JavaDoc baseCls)
948         throws org.omg.mof.Reflective.MofError , NotSet{
949
950         logger.log(Level.FINER, "DTD getAllInstanceAttributes3 of a class");
951         String JavaDoc parentEntity = "";
952         String JavaDoc 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 JavaDoc _key = _supertype.ref_mof_id();
958             String JavaDoc _nclass = _key;
959             if (baseCls.indexOf(_nclass) != -1) {
960
961                 // si une entité est générée pour _supertype
962
if (_entity_props.containsKey(_key)) {
963                     parentEntity =
964                         "%" + xmiHelper.qualifiedName(_supertype) + "Properties;";
965                 }
966             } else {
967                 String JavaDoc 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 JavaDoc temp = getAttributes(cls, "instance");
979         if ((temp.length() > 0) && (parentContents.length() > 0))
980             parentContents = parentContents + ", ";
981         return parentContents + temp;
982     }
983
984     //7.4.4.6
985
public String JavaDoc getAllReferences3(
986         org.omg.mof.Model.Class cls,
987         String JavaDoc 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 JavaDoc parentEntity = "";
992         String JavaDoc 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 JavaDoc _key = _supertype.ref_mof_id();
998             String JavaDoc _nclass = _key;
999             if (baseCls.indexOf(_nclass) != -1) {
1000                // si une entité est générée pour _supertype
1001
if (_entity_refs.containsKey(_key)) {
1002                    parentEntity =
1003                        "%"
1004                            + xmiHelper.qualifiedName(_supertype)
1005                            + "Associations;";
1006                }
1007            } else {
1008                String JavaDoc 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 JavaDoc temp = getReferences(cls);
1020        // if (temp.length()>0){
1021
// if(parentContents.length()> 0) parentContents = parentContents + ", " ;
1022
// temp = "("+ temp +")" ;
1023
// }
1024
if ((temp.length() > 0) && (parentContents.length() > 0)) {
1025            parentContents = parentContents + ", ";
1026            temp = "(" + temp + ")";
1027        }
1028        return parentContents + temp;
1029    }
1030
1031    //7.4.4.7
1032
public String JavaDoc getAllComposedRoles3(
1033        org.omg.mof.Model.Class cls,
1034        String JavaDoc baseCls)
1035        throws org.omg.mof.Reflective.MofError , NotSet{
1036
1037        logger.log(Level.FINER, "DTD getAllComposedRoles3 of a class");
1038        String JavaDoc parentEntity = "";
1039        String JavaDoc 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 JavaDoc _key = _supertype.ref_mof_id();
1045            String JavaDoc _nclass = _key;
1046            if (baseCls.indexOf(_nclass) != -1) {
1047                // si une entité est générée pour _supertype
1048
if (_entity_comps.containsKey(_key)) {
1049                    parentEntity =
1050                        "%"
1051                            + xmiHelper.qualifiedName(_supertype)
1052                            + "Compositions;";
1053                }
1054            } else {
1055                String JavaDoc 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 JavaDoc temp = getComposedRoles(cls);
1067        if ((temp.length() > 0) && (parentContents.length() > 0))
1068            parentContents = parentContents + ", ";
1069        return parentContents + temp;
1070    }
1071
1072    //7.4.4.7
1073
public String JavaDoc getParentAttributes3(
1074        org.omg.mof.Model.Class cls,
1075        String JavaDoc baseCls)
1076        throws org.omg.mof.Reflective.MofError , NotSet{
1077
1078        logger.log(Level.FINER, "DTD getParentAttributes3 of a class");
1079        String JavaDoc _nclass = cls.ref_mof_id();
1080        if (baseCls.indexOf(_nclass) != -1) {
1081            return "";
1082        } else {
1083            String JavaDoc 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 JavaDoc temp = getParentAttributes3(_supertype, baseCls);
1089                if ((temp.length() > 0) && (parentContents.length() > 0))
1090                    parentContents = parentContents + ", ";
1091                parentContents = parentContents + temp;
1092            }
1093            String JavaDoc temp = getAttributes(cls, "instance");
1094            if ((temp.length() > 0) && (parentContents.length() > 0))
1095                parentContents = parentContents + ", ";
1096            return parentContents + temp;
1097        }
1098    }
1099
1100    //7.4.4.8
1101
public String JavaDoc getParentReferences3(
1102        org.omg.mof.Model.Class cls,
1103        String JavaDoc 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 JavaDoc _nclass = cls.ref_mof_id();
1108        if (baseCls.indexOf(_nclass) != -1) {
1109            return "";
1110        } else {
1111            String JavaDoc 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 JavaDoc temp = getParentAttributes3(_supertype, baseCls);
1117                if ((temp.length() > 0) && (parentContents.length() > 0))
1118                    parentContents = parentContents + ", ";
1119                parentContents = parentContents + temp;
1120            }
1121            String JavaDoc temp = getReferences(cls);
1122            if ((temp.length() > 0) && (parentContents.length() > 0))
1123                parentContents = parentContents + ", ";
1124            return parentContents + temp;
1125        }
1126    }
1127
1128    //7.4.4.9
1129
public String JavaDoc getParentCompositionRoles3(
1130        org.omg.mof.Model.Class cls,
1131        String JavaDoc baseCls)
1132        throws org.omg.mof.Reflective.MofError , NotSet {
1133
1134        logger.log(Level.FINER, "DTD getParentCompositionRoles3 of a class");
1135        String JavaDoc _nclass = cls.name();
1136        if (baseCls.indexOf(_nclass) != -1) {
1137            return "";
1138        } else {
1139            String JavaDoc 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 JavaDoc temp = getParentCompositionRoles3(_supertype, baseCls);
1145                if ((temp.length() > 0) && (parentContents.length() > 0))
1146                    parentContents = parentContents + ", ";
1147                parentContents = parentContents + temp;
1148            }
1149            String JavaDoc temp = getComposedRoles(cls);
1150            if ((temp.length() > 0) && (parentContents.length() > 0))
1151                parentContents = parentContents + ", ";
1152            return parentContents + temp;
1153        }
1154    }
1155
1156    // Pseudo code pour générer la DTD
1157
// 7.3.3.1 règle 1
1158
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 JavaDoc,
1163            org.omg.CORBA.TypeCodePackage.Bounds JavaDoc {
1164
1165        logger.log(Level.FINE, "DTD generate the DTD");
1166        //Fixed DTD
1167
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        //# 15
1502
entityDTD(_package);
1503        //#2
1504
packageDTD(_package);
1505        logger.log(Level.FINE, "DTD DTD is Generated");
1506    }
1507
1508    //7.3.3.2
1509
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 JavaDoc,
1514            org.omg.CORBA.TypeCodePackage.Bounds JavaDoc {
1515
1516        logger.log(Level.FINER, "DTD packageDTD of a package");
1517        // Packages DTD
1518
// Traitement des attributs classifier level des classes
1519
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                //#4
1529
attributeElementDTD(_attributes[j]);
1530            }
1531        }
1532        comment("");
1533        out.println();
1534
1535        // traitement des associations
1536
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                            //#16
1554
associationDTD(_associations_package[i]);
1555            } else if(_has_compo) {
1556                //#12
1557
compositionDTD(_associations_package[i]);
1558            }
1559        }
1560        comment("");
1561        out.println();
1562
1563        // traitement des classes
1564
comment("The Classes");
1565        out.println();
1566        for (int i = 0; i < _classes_package.length; i++) {
1567            //#3
1568
classDTD(_classes_package[i]);
1569        }
1570
1571        //#14
1572
comment("");
1573        out.println();
1574        packageElementDef(_package);
1575    }
1576
1577    //7.3.3.3
1578
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 JavaDoc,
1583            org.omg.CORBA.TypeCodePackage.BadKind JavaDoc {
1584
1585        logger.log(Level.FINER, "DTD classDTD of a class");
1586
1587        //récupérer les attributs
1588
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            //#4
1596
attributeElementDTD(_attributes[i]);
1597        }
1598
1599        //récupérer les références
1600
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                        //#7
1615
referenceElementDef(_references[i]);
1616                    }
1617                }
1618            }
1619        }
1620
1621        //#11
1622
classElementDef(_class);
1623    }
1624
1625    //7.4.3.4
1626
private java.util.Hashtable JavaDoc _attribute_elementDTD =
1627        new java.util.Hashtable JavaDoc();
1628    public void attributeElementDTD(org.omg.mof.Model.MofAttribute _attribute)
1629        throws
1630            org.omg.mof.Reflective.MofError,
1631            org.omg.CORBA.TypeCodePackage.BadKind JavaDoc,
1632            org.omg.CORBA.TypeCodePackage.Bounds JavaDoc,
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 JavaDoc _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 JavaDoc _key = _type.ref_mof_id();
1645                if (!_attribute_elementDTD.containsKey(_key)) {
1646                    //#5
1647
attributeEntityDef(_data_type);
1648                    _attribute_elementDTD.put(_key, _type);
1649                }
1650            }
1651        }
1652        //#6
1653
attributeElementDef(_attribute);
1654
1655    }
1656
1657    //7.3.3.5
1658
public void attributeEntityDef(org.omg.mof.Model.DataType _data_type)
1659        throws
1660            org.omg.mof.Reflective.MofError,
1661            org.omg.CORBA.TypeCodePackage.BadKind JavaDoc,
1662            org.omg.CORBA.TypeCodePackage.Bounds JavaDoc , NotSet{
1663
1664        logger.log(Level.FINER, "DTD attributeEntityDef of a DataType");
1665        org.omg.CORBA.TypeCode JavaDoc _type_code = _data_type.type_code();
1666        int _kind = _type_code.kind().value();
1667        String JavaDoc TypeName = xmiHelper.qualifiedName(_data_type);
1668        String JavaDoc 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        //générer l'entité du datatype
1681
out.println(
1682            "<!ENTITY % "
1683                + TypeName
1684                + " \"xmi.value ("
1685                + enumvalues
1686                + ") #REQUIRED\">");
1687
1688    }
1689
1690    //7.4.3.6
1691
public void attributeElementDef(org.omg.mof.Model.MofAttribute _attribute)
1692        throws
1693            org.omg.mof.Reflective.MofError,
1694            org.omg.CORBA.TypeCodePackage.BadKind JavaDoc,
1695            org.omg.CORBA.TypeCodePackage.Bounds JavaDoc,
1696            org.omg.mof.Reflective.NotSet {
1697
1698        logger.log(Level.FINER, "DTD attributeElementDef of an attribute");
1699
1700        String JavaDoc AttribName = xmiHelper.qualifiedName(_attribute);
1701        String JavaDoc AttribContents;
1702        String JavaDoc AttribAttList = "";
1703        String JavaDoc 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 JavaDoc _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            // c'est une classe
1763
org.omg.mof.Model.Class _class =
1764                org.omg.mof.Model.ClassHelper.narrow(_type);
1765            AttribContents = "(" + getClasses(_class, "") + ")";
1766        }
1767
1768        //générer les éléments attributs
1769
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    //7.4.3.7
1778
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 JavaDoc RefName = xmiHelper.qualifiedName(_reference);
1783        org.omg.mof.Model.Class cls =
1784            org.omg.mof.Model.ClassHelper.narrow(_reference.type());
1785        String JavaDoc m = getReferenceMultiplicity(_reference);
1786        String JavaDoc RefContents = "(" + getClasses(cls, "") + ")" + m;
1787
1788        //générer les éléments references
1789
out.println("<!ELEMENT " + RefName + " " + RefContents + ">");
1790        out.println();
1791    }
1792
1793    //7.4.3.8
1794
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        //à revoir
1798
outputPropertiesEntityDef3(_class, "", "");
1799    }
1800
1801    //7.4.3.9
1802
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        //
1807
outputRefsEntityDef3(_class, "", "");
1808    }
1809
1810    //7.4.3.10
1811
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        //
1816
outputCompsEntityDef3(_class, "", "");
1817    }
1818
1819    //7.4.3.11
1820
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 JavaDoc ClassName = xmiHelper.qualifiedName(_class);
1826        String JavaDoc props = "";
1827        String JavaDoc _key = _class.ref_mof_id();
1828
1829        //si les Properties Entity sont générés pour cette classe
1830
if (_entity_props.containsKey(_key))
1831            props = "%" + ClassName + "Properties" + ";";
1832        String JavaDoc refs = "";
1833
1834        //si les References Entity sont générés pour cette classe
1835
if (_entity_refs.containsKey(_key))
1836            refs = ", " + "%" + ClassName + "Associations" + ";";
1837        refs = "(" + "XMI.extension" + "*" + refs + ")";
1838
1839        String JavaDoc comps1 = "";
1840        //si les Compositions Entity sont générés pour cette classe
1841
if (_entity_comps.containsKey(_key))
1842            comps1 = "%" + ClassName + "Compositions" + ";";
1843
1844        String JavaDoc comps2 = getContainedClasses(_class, "");
1845        String JavaDoc ClassContents =
1846            props + ", " + refs + ", " + comps1 + ", " + comps2;
1847
1848        //Enlever les virgules succéssives en cas d'élément vide
1849
ClassContents = removeDanglingCommas(ClassContents);
1850
1851        //
1852
if (ClassContents.length() == 0)
1853            ClassContents = "EMPTY";
1854        else
1855            ClassContents = "(" + ClassContents + ")" + "?";
1856        String JavaDoc ClassAttlisttems =
1857            "\n\t\t%XMI.element.att; \n\t\t%XMI.link.att;";
1858
1859        //générer les éléments contenus dans la class
1860
out.println("<!ELEMENT " + ClassName + " " + ClassContents + ">");
1861        out.println("<!ATTLIST " + ClassName + " " + ClassAttlisttems + "\n>");
1862    }
1863
1864    //7.4.3.12
1865
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        //#13
1870
comment(_composition.name());
1871        out.println();
1872        compositionElementDef(_composition);
1873    }
1874
1875    //7.4.3.13
1876
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 JavaDoc 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 JavaDoc CompContents = getClasses(Contained, "");
1904        //la multiplicité rajouter qui n'existe pas dans la norme "m"
1905
String JavaDoc m = getReferenceMultiplicity(_reference);
1906        CompContents = "(" + CompContents + ")" + m;
1907
1908        //générer l'élémént de la composition
1909
out.println("<!ELEMENT " + RoleName + " " + CompContents + ">");
1910
1911    }
1912
1913    //7.4.3.14
1914
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 JavaDoc PkgName = xmiHelper.format1(_package.name());
1919        String JavaDoc atts = getClassLevelAttributes(_package);
1920        String JavaDoc atts2 = "";
1921
1922        // java.util.Vector _sub_packages = new java.util.Vector();
1923
// _sub_packages = mofHelper.PackagesOfPackage(_package);
1924
// for(int i= 0; i< _sub_packages.size(); i++) {
1925
// org.omg.mof.Model.Package _sub_package = (org.omg.mof.Model.Package) _sub_packages.elementAt(i);
1926
// String temp = GetNestedClassLevelAttributes(_sub_package) ;
1927
// if(temp.length()>0) {
1928
// if(atts2.length()>0) atts2 = "(" + atts2 +")" ;
1929
// temp = atts2 + temp ;
1930
// }
1931
// atts2 = atts2 + temp ;
1932
// }
1933
String JavaDoc classes = getPackageClasses(_package);
1934        String JavaDoc assns = getUnreferencedAssociations(_package);
1935        String JavaDoc pkgs = getContainedPackages(_package);
1936        String JavaDoc 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        //enlever les parenthèses succéssives en cas d'élément vide
1957
for (int j = 0; j < PkgContents.length() - 1; j++) {
1958            for (int i = 0; i < PkgContents.length() - 1; i++) {
1959                String JavaDoc _v1 = String.valueOf(PkgContents.charAt(i));
1960                String JavaDoc _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        //enlever les virgules succéssives en cas d'élément vide
1970
PkgContents = removeDanglingCommas(PkgContents);
1971
1972        if (PkgContents.length() > 0)
1973            PkgContents = "(" + PkgContents + ")";
1974        else
1975            PkgContents = "EMPTY";
1976        String JavaDoc 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    //7.4.3.15
1985
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    //7.4.3.16
1992
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    //7.4.3.17
2006
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 JavaDoc EndName = xmiHelper.qualifiedName(_association_end);
2012        String JavaDoc EndAtts = "\n\t\t%XMI.link.att;";
2013        out.println("<!ELEMENT " + EndName + " EMPTY >");
2014        out.println("<!ATTLIST " + EndName + " " + EndAtts + "\n>");
2015
2016    }
2017
2018    //7.4.3.18
2019
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 JavaDoc AssnName = xmiHelper.qualifiedName(_association);
2024        String JavaDoc EndAtts = "\n\t\t%XMI.element.att;";
2025        out.println("<!ELEMENT " + AssnName + " EMPTY >");
2026        out.println("<!ATTLIST " + AssnName + " " + EndAtts + "\n>");
2027    }
2028
2029    //Enlever les virgules succéssives en cas d'élément vide
2030
public String JavaDoc removeDanglingCommas(String JavaDoc _string) {
2031
2032        logger.log(Level.FINER, "DTD removeDanglingCommas");
2033        String JavaDoc 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 JavaDoc _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    //Commentaire
2064
public void comment(String JavaDoc _string) {
2065        String JavaDoc _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    /**
2082     * Returns the mofHelper.
2083     * @return MOFCommon
2084     */

2085    public MOFCommon getMofHelper() {
2086        return mofHelper;
2087    }
2088
2089    /**
2090     * Returns the xmiHelper.
2091     * @return XMICommon
2092     */

2093    public XMICommon getXmiHelper() {
2094        return xmiHelper;
2095    }
2096
2097    /**
2098     * Sets the mofHelper.
2099     * @param mofHelper The mofHelper to set
2100     */

2101    public void setMofHelper(MOFCommon mofHelper) {
2102        this.mofHelper = mofHelper;
2103    }
2104
2105    /**
2106     * Sets the xmiHelper.
2107     * @param xmiHelper The xmiHelper to set
2108     */

2109    public void setXmiHelper(XMICommon xmiHelper) {
2110        this.xmiHelper = xmiHelper;
2111    }
2112
2113}
2114
Popular Tags