KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > io > Import


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.io;
21
22 import java.io.FileInputStream JavaDoc;
23 import java.io.FileNotFoundException JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.io.InputStream JavaDoc;
26 import java.util.Enumeration JavaDoc;
27 import java.util.Hashtable JavaDoc;
28 import java.util.StringTokenizer JavaDoc;
29 import java.util.Vector JavaDoc;
30
31 import javax.xml.parsers.DocumentBuilder JavaDoc;
32 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
33 import javax.xml.parsers.ParserConfigurationException JavaDoc;
34 import org.w3c.dom.Document JavaDoc;
35 import org.w3c.dom.Element JavaDoc;
36 import org.w3c.dom.Node JavaDoc;
37 import org.w3c.dom.NodeList JavaDoc;
38 import org.xml.sax.SAXException JavaDoc;
39
40 import org.omg.CORBA.ORB JavaDoc;
41 import org.omg.CORBA.TypeCode JavaDoc;
42 import org.omg.CORBA.TypeCodePackage.BadKind JavaDoc;
43 import org.omg.mof.Model.*;
44 import org.omg.mof.Reflective.MofError;
45 import org.objectweb.modfact.corba.helper.IDLCommon;
46 import org.objectweb.modfact.corba.logging.Level;
47 import org.objectweb.modfact.corba.logging.ModFactLogger;
48
49 public class Import {
50
51     //Trace
52
private ModFactLogger logger;
53
54     //Déclaration des Helpers
55
private IDLCommon idlHelper;
56
57     //Déclaration des Factory
58
private PackageClass _package_class;
59     private ClassClass _class_class;
60     private MofAttributeClass _attribute_class;
61     private ReferenceClass _reference_class;
62     private AssociationClass _association_class;
63     private AssociationEndClass _association_end_class;
64     private RefersTo _refers_to_class;
65     private Exposes _exposes_class;
66     private DataTypeClass _datatype_class;
67     private ConstantClass _constant_class;
68     private ConstraintClass _constraint_class;
69     private TagClass _tag_class;
70     private OperationClass _operation_class;
71     private ParameterClass _parameter_class;
72     private MofExceptionClass _exception_class;
73     private ImportClass _import_class;
74
75     // Déclaration
76
private ORB JavaDoc _orb;
77     private Element JavaDoc _document;
78
79     // Hashtables pour typer les attributs et les paramètre et rajouter les supertypes
80
private Hashtable JavaDoc _types = new Hashtable JavaDoc();
81     private Hashtable JavaDoc _elementsToType = new Hashtable JavaDoc();
82     private Hashtable JavaDoc _elementsToSupertype = new Hashtable JavaDoc();
83
84     //Hashtables pour les tags
85
private Hashtable JavaDoc _tags = new Hashtable JavaDoc();
86     private Hashtable JavaDoc _Id2element = new Hashtable JavaDoc();
87
88     //Hashtables pour les Exception à lier aux opérations
89
private Hashtable JavaDoc _Id2exception = new Hashtable JavaDoc();
90     private Hashtable JavaDoc _Exception4Operations = new Hashtable JavaDoc();
91
92     //Hashtables pour les imports
93
private Hashtable JavaDoc _Import2Imported = new Hashtable JavaDoc();
94
95     // Hashtables pour les typer les références et les lier aux associationEnd
96
private Hashtable JavaDoc _OtherEnd = new Hashtable JavaDoc();
97     private Hashtable JavaDoc _Id2End = new Hashtable JavaDoc();
98     private Hashtable JavaDoc _referencedEndTable = new Hashtable JavaDoc();
99     private Hashtable JavaDoc _constantValue = new Hashtable JavaDoc();
100     
101     // Hashtable for data types
102
private java.util.Hashtable JavaDoc _dataTypes = new Hashtable JavaDoc(); // Key / TypeCode
103

104     // initialisation
105
public void initiate(_ModelPackage _model_package, org.omg.CORBA.ORB JavaDoc orb)
106         throws MofError {
107
108         //creation des Factory
109
_package_class = _model_package.package_ref();
110         _class_class = _model_package.class_ref();
111         _attribute_class = _model_package.mof_attribute_ref();
112         _reference_class = _model_package.reference_ref();
113         _association_class = _model_package.association_ref();
114         _association_end_class = _model_package.association_end_ref();
115         _refers_to_class = _model_package.refers_to_ref();
116         _exposes_class = _model_package.exposes_ref();
117         _datatype_class = _model_package.data_type_ref();
118         _constant_class = _model_package.constant_ref();
119         _constraint_class = _model_package.constraint_ref();
120         _tag_class = _model_package.tag_ref();
121         _operation_class = _model_package.operation_ref();
122         _parameter_class = _model_package.parameter_ref();
123         _exception_class = _model_package.mof_exception_ref();
124         _import_class = _model_package.import_ref();
125         _orb = orb;
126         initPrimitiveTypes();
127     }
128     
129    /**
130     * Initialize the primitive types (i.e. String, Boolean, Integer, Long, Double, Float).
131     */

132    protected void initPrimitiveTypes() throws org.omg.mof.Reflective.MofError {
133        org.omg.mof.Model.VisibilityKind pvis = org.omg.mof.Model.VisibilityKind.public_vis;
134        org.omg.mof.Model.DataType pt_integer = _datatype_class.create_data_type(
135                             "*long", "", pvis, true, true, false, _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long));
136        org.omg.mof.Model.DataType pt_long = _datatype_class.create_data_type(
137                             "*long long", "", pvis, true, true, false, _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_longlong));
138        org.omg.mof.Model.DataType pt_float = _datatype_class.create_data_type(
139                             "*float", "", pvis, true, true, false, _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_float));
140        org.omg.mof.Model.DataType pt_double = _datatype_class.create_data_type(
141                             "*double", "", pvis, true, true, false, _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_double));
142        org.omg.mof.Model.DataType pt_boolean = _datatype_class.create_data_type(
143                             "*boolean", "", pvis, true, true, false, _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean));
144        org.omg.mof.Model.DataType pt_string = _datatype_class.create_data_type(
145                             "*string", "", pvis, true, true, false, _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string));
146
147        _types.put("Integer", pt_integer);
148        _types.put("Long", pt_long);
149        _types.put("Float", pt_float);
150        _types.put("Double", pt_double);
151        _types.put("Boolean", pt_boolean);
152        _types.put("String", pt_string);
153    }
154
155     //Rem changer Package par ModelElement
156
public org.omg.mof.Model.Package[] parse(String JavaDoc _fichier)
157         throws
158             SAXException JavaDoc,
159             ParserConfigurationException JavaDoc,
160             IOException JavaDoc,
161             BadKind JavaDoc,
162             MofError {
163
164         // Charger le document
165
FileInputStream JavaDoc _xml_input_file = new FileInputStream JavaDoc(_fichier);
166
167         return parse(_xml_input_file);
168     }
169
170     public org.omg.mof.Model.Package[] parse(InputStream JavaDoc _xml_input_file)
171         throws
172             SAXException JavaDoc,
173             ParserConfigurationException JavaDoc,
174             IOException JavaDoc,
175             BadKind JavaDoc,
176             MofError {
177
178         logger.log(Level.FINE, "Begin parsing");
179         // le package
180
Vector JavaDoc packagesV = new Vector JavaDoc();
181
182         DocumentBuilderFactory JavaDoc _factory = DocumentBuilderFactory.newInstance();
183         _factory.setIgnoringComments(true);
184         DocumentBuilder JavaDoc _builder = _factory.newDocumentBuilder();
185
186         // Charger le document
187
Document JavaDoc doc = _builder.parse(_xml_input_file);
188         logger.log(Level.FINE, "Document is valid");
189
190         // Parser le document
191
Element JavaDoc model = doc.getDocumentElement();
192
193         //Enlever les espaces
194
delSpaces(model);
195
196         //récupérer XMI.content
197
Element JavaDoc xmiContent = null;
198         NodeList JavaDoc modelContents = model.getChildNodes();
199         for (int i = 0; i < modelContents.getLength(); i++) {
200             Node JavaDoc node = modelContents.item(i);
201             if (node.getNodeType() == Node.ELEMENT_NODE) {
202                 Element JavaDoc contentElement = (Element JavaDoc) node;
203                 String JavaDoc currentName = contentElement.getNodeName().trim();
204                 if (currentName.endsWith("XMI.content")) {
205                     xmiContent = contentElement;
206                 }
207             }
208         }
209         if (xmiContent == null) {
210             logger.log(Level.FATAL, "There is no XMI.content element !");
211             return null;
212         }
213
214         //récupérer les packages outermost contenus
215
NodeList JavaDoc contents = xmiContent.getChildNodes();
216         for (int i = 0; i < contents.getLength(); i++) {
217             Node JavaDoc node = contents.item(i);
218             if (node.getNodeType() == Node.ELEMENT_NODE) {
219                 Element JavaDoc element = (Element JavaDoc) node;
220                 String JavaDoc name = element.getNodeName().trim();
221
222                 if (name.toLowerCase().endsWith("package")) {
223                     packagesV.addElement(packageTemplate(element, null));
224                 }
225             }
226         }
227         org.omg.mof.Model.Package[] packages =
228             new org.omg.mof.Model.Package[packagesV.size()];
229         for (int i = 0; i < packages.length; i++) {
230             packages[i] = (org.omg.mof.Model.Package) packagesV.elementAt(i);
231         }
232         logger.log(Level.FINE, packagesV.size() + " Package(s) parsed");
233
234         // Deuxième passe pour mettre les types, les tags, les imports et les AssociationsEnds pour les références
235
typing();
236         logger.log(Level.FINE, "typing is done");
237         associationEnds4Reference();
238         logger.log(Level.FINE, "associationEnds4Reference is done");
239         putSupertypes();
240         logger.log(Level.FINE, "putSupertypes is done");
241         taggedElement();
242         logger.log(Level.FINE, "taggedElement is done");
243         importElements();
244         logger.log(Level.FINE, "ImportElements is done");
245         exceptions4Operations();
246         logger.log(Level.FINE, "Exceptions4Operations is done");
247
248         logger.log(Level.FINE, "Parsing is done");
249
250         return packages;
251     }
252
253     // traitement du package
254
public org.omg.mof.Model.Package packageTemplate(
255         Element JavaDoc _package_element,
256         Namespace _container)
257         throws BadKind JavaDoc, MofError {
258         //création par défault du package
259
org.omg.mof.Model.Package _package =
260             _package_class.create_package(
261                 "name",
262                 "",
263                 VisibilityKind.public_vis,
264                 false,
265                 false,
266                 false);
267
268         //Properties
269
String JavaDoc name = getValue(_package_element, "name");
270         logger.log(Level.FINE, " Package " + name + " parsing");
271         if (name.compareTo("") != 0)
272             _package.set_name(name);
273         String JavaDoc annotation = getValue(_package_element, "annotation");
274         if (annotation.compareTo("") != 0)
275             _package.set_annotation(annotation);
276         String JavaDoc visibility = getValue(_package_element, "visibility");
277         if (visibility.endsWith("protected_vis"))
278             _package.set_visibility(VisibilityKind.protected_vis);
279         else if (visibility.endsWith("private_vis"))
280             _package.set_visibility(VisibilityKind.private_vis);
281         String JavaDoc isAbstract = getValue(_package_element, "isAbstract");
282         if (isAbstract.endsWith("true"))
283             _package.set_is_abstract(true);
284         String JavaDoc isLeaf = getValue(_package_element, "isLeaf");
285         if (isLeaf.endsWith("true"))
286             _package.set_is_leaf(true);
287         String JavaDoc isRoot = getValue(_package_element, "isRoot");
288         if (isRoot.endsWith("true"))
289             _package.set_is_root(true);
290
291         //récupérer le contenu du Package
292
NodeList JavaDoc contents = _package_element.getChildNodes();
293         for (int i = 0; i < contents.getLength(); i++) {
294             Node JavaDoc node = contents.item(i);
295             if (node.getNodeType() == Node.ELEMENT_NODE) {
296                 Element JavaDoc contentElement = (Element JavaDoc) node;
297                 String JavaDoc currentName = contentElement.getNodeName().trim();
298                 if (currentName.endsWith("Namespace.contents")) {
299                     NodeList JavaDoc namespaceContents = contentElement.getChildNodes();
300                     for (int j = 0; j < namespaceContents.getLength(); j++) {
301                         if (namespaceContents.item(j).getNodeType()
302                             == Node.ELEMENT_NODE) {
303                             Element JavaDoc _element =
304                                 (Element JavaDoc) namespaceContents.item(j);
305                             String JavaDoc _element_name =
306                                 _element.getNodeName().trim();
307                             if (_element_name.endsWith("DataType"))
308                                 dataTypeTemplate(_element, _package);
309                             else if (_element_name.endsWith("PrimitiveType"))
310                                 primitiveTypeTemplate(_element, _package);
311                             else if (_element_name.endsWith("EnumerationType"))
312                                 enumerationTypeTemplate(_element, _package);
313                             else if (_element_name.endsWith("StructureType"))
314                                 structureTypeTemplate(_element, _package);
315                             else if (_element_name.endsWith("AliasType"))
316                                 aliasTypeTemplate(_element, _package);
317                             else if (_element_name.endsWith("CollectionType"))
318                                 collectionTypeTemplate(_element, _package);
319                             else if (_element_name.endsWith("Association"))
320                                 associationTemplate(_element, _package);
321                             else if (_element_name.endsWith("Class"))
322                                 classTemplate(_element, _package);
323                             else if (_element_name.endsWith("Constant"))
324                                 constantTemplate(_element, _package);
325                             else if (_element_name.endsWith("Tag"))
326                                 tagTemplate(_element, _package);
327                             else if (_element_name.endsWith("Exception"))
328                                 mofExceptionTemplate(_element, _package);
329                             else if (_element_name.endsWith("Import"))
330                                 importTemplate(_element, _package);
331                             else if (_element_name.endsWith("Package"))
332                                 packageTemplate(_element, _package);
333                         }
334                     }
335                 }
336             }
337         }
338
339         // ranger le package dans la table des tags
340
String JavaDoc _key = _package_element.getAttribute("xmi.id").trim();
341         _Id2element.put(_key, _package);
342
343         _package.set_container(_container);
344         if (_container != null)
345             _container.add_contents(_package);
346         return _package;
347     }
348
349     //Traitement des classes
350
public void classTemplate(Element JavaDoc _class_element, Namespace _container)
351         throws MofError {
352         // récupérer l'identificateur
353
String JavaDoc _key = _class_element.getAttribute("xmi.id").trim();
354
355         // création d'une classe par défault
356
org.omg.mof.Model.Class _class =
357             _class_class.create_class(
358                 "name",
359                 "",
360                 VisibilityKind.public_vis,
361                 false,
362                 false,
363                 false,
364                 false);
365
366         //Propriétés de la class
367
String JavaDoc name = getValue(_class_element, "name");
368         logger.log(Level.FINE, " Class " + name + " parsing");
369         if (name.compareTo("") != 0)
370             _class.set_name(name);
371
372         String JavaDoc annotation = getValue(_class_element, "annotation");
373         if (annotation.compareTo("") != 0)
374             _class.set_annotation(annotation);
375
376         String JavaDoc visibility = getValue(_class_element, "visibility");
377         if (visibility.endsWith("protected_vis"))
378             _class.set_visibility(VisibilityKind.protected_vis);
379         else if (visibility.endsWith("private_vis"))
380             _class.set_visibility(VisibilityKind.private_vis);
381
382         String JavaDoc isAbstract = getValue(_class_element, "isAbstract");
383         if (isAbstract.endsWith("true"))
384             _class.set_is_abstract(true);
385
386         String JavaDoc isLeaf = getValue(_class_element, "isLeaf");
387         if (isLeaf.endsWith("true"))
388             _class.set_is_leaf(true);
389
390         String JavaDoc isRoot = getValue(_class_element, "isRoot");
391         if (isRoot.endsWith("true"))
392             _class.set_is_root(true);
393
394         String JavaDoc isSingleton = getValue(_class_element, "isSingleton");
395         if (isSingleton.endsWith("true"))
396             _class.set_is_singleton(true);
397
398         //to recover supertypes for XMI version 1.1
399
String JavaDoc supertypes = _class_element.getAttribute("supertypes");
400         if (supertypes.compareTo("") != 0) {
401             Vector JavaDoc supers = new Vector JavaDoc();
402             StringTokenizer JavaDoc supRefs = new StringTokenizer JavaDoc(supertypes, " ");
403             while (supRefs.hasMoreTokens()) {
404                 String JavaDoc part = supRefs.nextToken();
405                 supers.addElement(part);
406             }
407             _elementsToSupertype.put(_class, supers);
408         }
409
410         NodeList JavaDoc contents = _class_element.getChildNodes();
411         for (int i = 0; i < contents.getLength(); i++) {
412             Node JavaDoc node = contents.item(i);
413             if (node.getNodeType() == Node.ELEMENT_NODE) {
414                 Element JavaDoc contentElement = (Element JavaDoc) node;
415                 String JavaDoc currentName = contentElement.getNodeName().trim();
416
417                 //to recover supertypes for XMI version 1.0
418
if (currentName.endsWith("GeneralizableElement.supertypes")) {
419                     Vector JavaDoc supers = new Vector JavaDoc();
420                     NodeList JavaDoc supertypeNodes = contentElement.getChildNodes();
421                     for (int j = 0; j < supertypeNodes.getLength(); j++) {
422                         if (supertypeNodes.item(j).getNodeType()
423                             == Node.ELEMENT_NODE) {
424                             Element JavaDoc element = (Element JavaDoc) supertypeNodes.item(j);
425                             String JavaDoc _element_name = element.getNodeName().trim();
426                             if (_element_name
427                                 .endsWith("GeneralizableElement")) {
428                                 String JavaDoc _ref =
429                                     element.getAttribute("xmi.idref").trim();
430                                 supers.addElement(_ref);
431                             }
432                         }
433                     }
434                     _elementsToSupertype.put(_class, supers);
435                 } else if (currentName.endsWith("Namespace.contents")) {
436                     NodeList JavaDoc namespaceContents = contentElement.getChildNodes();
437                     for (int j = 0; j < namespaceContents.getLength(); j++) {
438                         if (namespaceContents.item(j).getNodeType()
439                             == Node.ELEMENT_NODE) {
440                             Element JavaDoc element =
441                                 (Element JavaDoc) namespaceContents.item(j);
442                             String JavaDoc _element_name = element.getNodeName().trim();
443                             if (_element_name.endsWith("Attribute"))
444                                 mofAttributeTemplate(element, _class);
445                             else if (_element_name.endsWith("Reference"))
446                                 referenceTemplate(element, _class);
447                             else if (_element_name.endsWith("Operation"))
448                                 operationTemplate(element, _class);
449                             else if (_element_name.endsWith("DataType"))
450                                 dataTypeTemplate(element, _class);
451                             else if (_element_name.endsWith("PrimitiveType"))
452                                 primitiveTypeTemplate(element, _class);
453                             else if (_element_name.endsWith("EnumerationType"))
454                                 enumerationTypeTemplate(element, _class);
455                             else if (_element_name.endsWith("StructureType"))
456                                 structureTypeTemplate(element, _class);
457                             else if (_element_name.endsWith("AliasType"))
458                                 aliasTypeTemplate(element, _class);
459                             else if (_element_name.endsWith("CollectionType"))
460                                 collectionTypeTemplate(element, _class);
461                             else if (_element_name.endsWith("Exception"))
462                                 mofExceptionTemplate(element, _class);
463                             else if (_element_name.endsWith("Constant"))
464                                 constantTemplate(element, _class);
465                         }
466                     }
467
468                 }
469             }
470         }
471         // container et contents
472
_class.set_container(_container);
473         _container.add_contents(_class);
474
475         // ranger la classe dans la tables des types et éventuellement pour les tags
476
_types.put(_key, _class);
477         _Id2element.put(_key, _class);
478     }
479
480     // les attributs d'une classe
481
public void mofAttributeTemplate(
482         Element JavaDoc _attribute_element,
483         org.omg.mof.Model.Class _class)
484         throws MofError {
485         // création d'un attribut par défault
486
MofAttribute _attribute =
487             _attribute_class.create_mof_attribute(
488                 "name",
489                 "",
490                 VisibilityKind.public_vis,
491                 ScopeKind.instance_level,
492                 new MultiplicityType(0, 1, false, false),
493                 true,
494                 false);
495
496         // récupérer les propriétés
497
String JavaDoc name = getValue(_attribute_element, "name");
498         if (name.compareTo("") != 0)
499             _attribute.set_name(name);
500
501         String JavaDoc annotation = getValue(_attribute_element, "annotation");
502         if (annotation.compareTo("") != 0)
503             _attribute.set_annotation(annotation);
504
505         String JavaDoc visibility = getValue(_attribute_element, "visibility");
506         if (visibility.endsWith("protected_vis"))
507             _attribute.set_visibility(VisibilityKind.protected_vis);
508         else if (visibility.endsWith("private_vis"))
509             _attribute.set_visibility(VisibilityKind.private_vis);
510
511         String JavaDoc scope = getValue(_attribute_element, "scope");
512         if (scope.endsWith("classifier_level"))
513             _attribute.set_scope(ScopeKind.classifier_level);
514
515         String JavaDoc isDerived = getValue(_attribute_element, "isDerived");
516         if (isDerived.endsWith("true"))
517             _attribute.set_is_derived(true);
518
519         String JavaDoc changeable = getValue(_attribute_element, "isChangeable");
520         if (changeable.endsWith("false"))
521             _attribute.set_is_changeable(false);
522
523         //mettre à jour la multiplicité de l'attribut
524
_attribute.set_multiplicity(getMultiplicity(_attribute_element));
525
526         // récupérer le type
527
_elementsToType.put(_attribute, getType(_attribute_element));
528
529         _attribute.set_container(_class);
530         _class.add_contents(_attribute);
531     }
532
533     // les références d'une classe
534
public void referenceTemplate(
535         Element JavaDoc _reference_element,
536         org.omg.mof.Model.Class _class)
537         throws MofError {
538         // création d'une référence par défault
539
Reference _reference =
540             _reference_class.create_reference(
541                 "name",
542                 "",
543                 VisibilityKind.public_vis,
544                 ScopeKind.instance_level,
545                 new MultiplicityType(0, 1, false, false),
546                 true);
547
548         // récupérer les valeurs de l'attribut
549
String JavaDoc name = getValue(_reference_element, "name");
550         if (name.compareTo("") != 0)
551             _reference.set_name(name);
552
553         String JavaDoc annotation = getValue(_reference_element, "annotation");
554         if (annotation.compareTo("") != 0)
555             _reference.set_annotation(annotation);
556
557         String JavaDoc visibility = getValue(_reference_element, "visibility");
558         if (visibility.endsWith("protected_vis"))
559             _reference.set_visibility(VisibilityKind.protected_vis);
560         else if (visibility.endsWith("private_vis"))
561             _reference.set_visibility(VisibilityKind.private_vis);
562
563         String JavaDoc scope = getValue(_reference_element, "scope");
564         if (scope.endsWith("classifier_level"))
565             _reference.set_scope(ScopeKind.classifier_level);
566
567         String JavaDoc changeable = getValue(_reference_element, "isChangeable");
568         if (changeable.endsWith("false"))
569             _reference.set_is_changeable(false);
570
571         //mettre à jour la multiplicité de l'attribut
572
_reference.set_multiplicity(getMultiplicity(_reference_element));
573
574         // récupérer le type
575
_elementsToType.put(_reference, getType(_reference_element));
576
577         // récupérer l'associationEnd associée
578
_referencedEndTable.put(
579             _reference,
580             getReferencedEnd(_reference_element));
581
582         _reference.set_container(_class);
583         _class.add_contents(_reference);
584     }
585
586     // les opérations d'une classe
587
public void operationTemplate(
588         Element JavaDoc _operation_element,
589         org.omg.mof.Model.Class _class)
590         throws MofError {
591
592         // création d'un attribut par défault
593
Operation _operation =
594             _operation_class.create_operation(
595                 "name",
596                 "",
597                 VisibilityKind.public_vis,
598                 ScopeKind.instance_level,
599                 true);
600
601         // récupérer les valeurs de l'attribut
602
String JavaDoc name = getValue(_operation_element, "name");
603         if (name.compareTo("") != 0)
604             _operation.set_name(name);
605
606         String JavaDoc annotation = getValue(_operation_element, "annotation");
607         if (annotation.compareTo("") != 0)
608             _operation.set_annotation(annotation);
609
610         String JavaDoc visibility = getValue(_operation_element, "visibility");
611         if (visibility.endsWith("protected_vis"))
612             _operation.set_visibility(VisibilityKind.protected_vis);
613         else if (visibility.endsWith("private_vis"))
614             _operation.set_visibility(VisibilityKind.private_vis);
615
616         String JavaDoc scope = getValue(_operation_element, "scope");
617         if (scope.endsWith("classifier_level"))
618             _operation.set_scope(ScopeKind.classifier_level);
619
620         String JavaDoc isQuery = getValue(_operation_element, "isQuery");
621         if (isQuery.endsWith("true"))
622             _operation.set_is_query(true);
623
624         // Récupérer les exceptions associées
625
NodeList JavaDoc list = _operation_element.getChildNodes();
626         for (int i = 0; i < list.getLength(); i++) {
627             Node JavaDoc node = list.item(i);
628             if (node.getNodeType() == Node.ELEMENT_NODE) {
629                 Element JavaDoc exceptionsBloc = (Element JavaDoc) node;
630                 String JavaDoc currentName = exceptionsBloc.getNodeName().trim();
631                 if (currentName.endsWith("Operation.exceptions")) {
632                     Vector JavaDoc listExceptions = new Vector JavaDoc();
633                     NodeList JavaDoc exceptionsList = exceptionsBloc.getChildNodes();
634                     for (int j = 0; j < exceptionsList.getLength(); j++) {
635                         if (exceptionsList.item(j).getNodeType()
636                             == Node.ELEMENT_NODE) {
637                             Element JavaDoc _element = (Element JavaDoc) exceptionsList.item(i);
638                             String JavaDoc _element_name =
639                                 _element.getNodeName().trim();
640                             if (_element_name.endsWith("Exception")) {
641                                 String JavaDoc ref = _element.getAttribute("xmi.idref");
642                                 listExceptions.addElement(ref);
643                             }
644                         }
645                     }
646                     _Exception4Operations.put(_operation, listExceptions);
647                 }
648             }
649         }
650
651         // récupérer les paramètres
652
NodeList JavaDoc contents = _operation_element.getChildNodes();
653         for (int i = 0; i < contents.getLength(); i++) {
654             Node JavaDoc node = contents.item(i);
655             if (node.getNodeType() == Node.ELEMENT_NODE) {
656                 Element JavaDoc contentElement = (Element JavaDoc) node;
657                 String JavaDoc currentName = contentElement.getNodeName().trim();
658                 if (currentName.endsWith("Namespace.contents")) {
659                     NodeList JavaDoc namespaceContents = contentElement.getChildNodes();
660                     for (int j = 0; j < namespaceContents.getLength(); j++) {
661                         if (namespaceContents.item(j).getNodeType()
662                             == Node.ELEMENT_NODE) {
663
664                             Element JavaDoc _element =
665                                 (Element JavaDoc) namespaceContents.item(j);
666                             String JavaDoc _element_name =
667                                 _element.getNodeName().trim();
668
669                             if (_element_name.endsWith("Parameter"))
670                                 parameterTemplate(_element, _operation);
671                         }
672                     }
673                 }
674             }
675         }
676         _operation.set_container(_class);
677         _class.add_contents(_operation);
678     }
679
680     //traitement des paramètres d'opérations
681
public void parameterTemplate(
682         Element JavaDoc _parameter_element,
683         Namespace _container)
684         throws MofError {
685         // création d'un paramètre par défault
686
Parameter _parameter =
687             _parameter_class.create_parameter(
688                 "name",
689                 "",
690                 new MultiplicityType(1, 1, false, false),
691                 DirectionKind.in_dir);
692
693         // récupérer les valeurs du paramètre
694
String JavaDoc name = getValue(_parameter_element, "name");
695         if (name.compareTo("") != 0)
696             _parameter.set_name(name);
697
698         String JavaDoc annotation = getValue(_parameter_element, "annotation");
699         if (annotation.compareTo("") != 0)
700             _parameter.set_annotation(annotation);
701
702         String JavaDoc direction = getValue(_parameter_element, "direction");
703         if (direction.endsWith("out_dir"))
704             _parameter.set_direction(DirectionKind.out_dir);
705         else if (direction.endsWith("inout_dir"))
706             _parameter.set_direction(DirectionKind.inout_dir);
707         else if (direction.endsWith("return_dir"))
708             _parameter.set_direction(DirectionKind.return_dir);
709
710         //mettre à jour la multiplicité de l'attribut
711
_parameter.set_multiplicity(getMultiplicity(_parameter_element));
712
713         // récupérer le type
714
_elementsToType.put(_parameter, getType(_parameter_element));
715
716         _container.add_contents(_parameter);
717         _parameter.set_container(_container);
718     }
719
720     //traitement des exceptions
721
public void mofExceptionTemplate(
722         Element JavaDoc _exception_element,
723         Namespace _container)
724         throws MofError {
725         // création d'une exception par défault
726
MofException _exception =
727             _exception_class.create_mof_exception(
728                 "name",
729                 "",
730                 VisibilityKind.public_vis,
731                 ScopeKind.instance_level);
732
733         // récupérer les valeurs de l'attribut
734
String JavaDoc name = getValue(_exception_element, "name");
735         if (name.compareTo("") != 0)
736             _exception.set_name(name);
737
738         String JavaDoc annotation = getValue(_exception_element, "annotation");
739         if (annotation.compareTo("") != 0)
740             _exception.set_annotation(annotation);
741
742         String JavaDoc visibility = getValue(_exception_element, "visibility");
743         if (visibility.endsWith("protected_vis"))
744             _exception.set_visibility(VisibilityKind.protected_vis);
745         else if (visibility.endsWith("private_vis"))
746             _exception.set_visibility(VisibilityKind.private_vis);
747
748         String JavaDoc scope = getValue(_exception_element, "scope");
749         if (scope.endsWith("classifier_level"))
750             _exception.set_scope(ScopeKind.classifier_level);
751
752         // récupérer les paramètres
753
NodeList JavaDoc contents = _exception_element.getChildNodes();
754         for (int i = 0; i < contents.getLength(); i++) {
755             Node JavaDoc node = contents.item(i);
756             if (node.getNodeType() == Node.ELEMENT_NODE) {
757                 Element JavaDoc contentElement = (Element JavaDoc) node;
758                 String JavaDoc currentName = contentElement.getNodeName().trim();
759                 if (currentName.endsWith("Namespace.contents")) {
760                     NodeList JavaDoc namespaceContents = contentElement.getChildNodes();
761                     for (int j = 0; j < namespaceContents.getLength(); j++) {
762                         if (namespaceContents.item(j).getNodeType()
763                             == Node.ELEMENT_NODE) {
764
765                             Element JavaDoc _element =
766                                 (Element JavaDoc) namespaceContents.item(j);
767                             String JavaDoc _element_name =
768                                 _element.getNodeName().trim();
769
770                             if (_element_name.endsWith("Parameter"))
771                                 parameterTemplate(_element, _exception);
772                         }
773                     }
774                 }
775             }
776         }
777
778         // Stocker les exception afin de les lier aux opérations
779
String JavaDoc _key = _exception_element.getAttribute("xmi.id").trim();
780         _Id2exception.put(_key, _exception);
781
782         _container.add_contents(_exception);
783         _exception.set_container(_container);
784     }
785
786     //Traitement des associations
787
public void associationTemplate(
788         Element JavaDoc _association_element,
789         Namespace _container)
790         throws MofError {
791
792         // création d'une classe par défault
793
Association _association =
794             _association_class.create_association(
795                 "name",
796                 "",
797                 VisibilityKind.public_vis,
798                 false,
799                 false,
800                 false,
801                 false);
802
803         //Propriétés de la class
804
String JavaDoc name = getValue(_association_element, "name");
805         if (name.compareTo("") != 0)
806             _association.set_name(name);
807
808         String JavaDoc annotation = getValue(_association_element, "annotation");
809         if (annotation.compareTo("") != 0)
810             _association.set_annotation(annotation);
811
812         String JavaDoc visibility = getValue(_association_element, "visibility");
813         if (visibility.endsWith("protected_vis"))
814             _association.set_visibility(VisibilityKind.protected_vis);
815         else if (visibility.endsWith("private_vis"))
816             _association.set_visibility(VisibilityKind.private_vis);
817
818         String JavaDoc isAbstract = getValue(_association_element, "isAbstract");
819         if (isAbstract.endsWith("true"))
820             _association.set_is_abstract(true);
821
822         String JavaDoc isLeaf = getValue(_association_element, "isLeaf");
823         if (isLeaf.endsWith("true"))
824             _association.set_is_leaf(true);
825
826         String JavaDoc isRoot = getValue(_association_element, "isRoot");
827         if (isRoot.endsWith("true"))
828             _association.set_is_root(true);
829
830         String JavaDoc isDerived = getValue(_association_element, "isDerived");
831         if (isRoot.endsWith("true"))
832             _association.set_is_root(true);
833
834         // récupérer les associations ends
835
//Stocker les Id des associationEnds
836
String JavaDoc[] _ends = new String JavaDoc[2];
837         int k = 0;
838         NodeList JavaDoc contents = _association_element.getChildNodes();
839         for (int i = 0; i < contents.getLength(); i++) {
840             Node JavaDoc node = contents.item(i);
841             if (node.getNodeType() == Node.ELEMENT_NODE) {
842                 Element JavaDoc contentElement = (Element JavaDoc) node;
843                 String JavaDoc currentName = contentElement.getNodeName().trim();
844                 if (currentName.endsWith("Namespace.contents")) {
845                     NodeList JavaDoc namespaceContents = contentElement.getChildNodes();
846                     for (int j = 0; j < namespaceContents.getLength(); j++) {
847                         if (namespaceContents.item(j).getNodeType()
848                             == Node.ELEMENT_NODE) {
849                             Element JavaDoc element =
850                                 (Element JavaDoc) namespaceContents.item(j);
851                             String JavaDoc _element_name = element.getNodeName().trim();
852                             if (_element_name.endsWith("AssociationEnd")) {
853                                 associationEndTemplate(element, _association);
854                                 _ends[k] =
855                                     element.getAttribute("xmi.id").trim();
856                                 k++;
857                             }
858                         }
859                     }
860                 }
861             }
862         }
863
864         // container et contents
865
_association.set_container(_container);
866         _container.add_contents(_association);
867
868         // rajouer les association pour otherends
869
_OtherEnd.put(_ends[0], _ends[1]);
870         _OtherEnd.put(_ends[1], _ends[0]);
871
872         //rajouter l'association dans la table des tags
873
String JavaDoc _key = _association_element.getAttribute("xmi.id").trim();
874         _types.put(_key, _association);
875     }
876
877     // les associations ends d'une classe
878
public void associationEndTemplate(
879         Element JavaDoc _end_element,
880         Association _association)
881         throws MofError {
882         // création de l'association end par défault
883
AssociationEnd _association_end =
884             _association_end_class.create_association_end(
885                 "name",
886                 "",
887                 true,
888                 AggregationKind.none,
889                 new MultiplicityType(0, 1, false, false),
890                 true);
891
892         //Propriétés de la class
893
String JavaDoc name = getValue(_end_element, "name");
894         if (name.compareTo("") != 0)
895             _association_end.set_name(name);
896
897         String JavaDoc annotation = getValue(_end_element, "annotation");
898         if (annotation.compareTo("") != 0)
899             _association_end.set_annotation(annotation);
900
901         String JavaDoc aggregation = getValue(_end_element, "aggregation");
902         if (aggregation.endsWith("shared"))
903             _association_end.set_aggregation(AggregationKind.shared);
904         else if (aggregation.endsWith("composite"))
905             _association_end.set_aggregation(AggregationKind.composite);
906
907         String JavaDoc isChangeable = getValue(_end_element, "isChangeable");
908         if (isChangeable.endsWith("false"))
909             _association_end.set_is_changeable(false);
910
911         String JavaDoc isNavigable = getValue(_end_element, "isNavigable");
912         if (isNavigable.endsWith("false"))
913             _association_end.set_is_navigable(false);
914
915         //mettre à jour la multiplicité
916
_association_end.set_multiplicity(getMultiplicity(_end_element));
917
918         // récupérer le type
919
_elementsToType.put(_association_end, getType(_end_element));
920
921         // stocker
922
String JavaDoc _key = _end_element.getAttribute("xmi.id").trim();
923         _Id2End.put(_key, _association_end);
924
925         // contents et container
926
_association_end.set_container(_association);
927         _association.add_contents(_association_end);
928     }
929
930     /**
931      * Datatypes abstract processing
932      */

933     public org.omg.mof.Model.DataType dataTypeAbstractTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
934         // Default DataType creation
935
DataType _datatype =
936             _datatype_class.create_data_type(
937                 "name",
938                 "",
939                 VisibilityKind.public_vis,
940                 false,
941                 false,
942                 false,
943                 _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_any));
944
945         //Propriétés de la class
946
String JavaDoc name = getValue(_datatype_element, "name");
947         if (name.compareTo("") != 0)
948             _datatype.set_name(name);
949
950         String JavaDoc annotation = getValue(_datatype_element, "annotation");
951         if (annotation.compareTo("") != 0)
952             _datatype.set_annotation(annotation);
953
954         String JavaDoc visibility = getValue(_datatype_element, "visibility");
955         if (visibility.endsWith("protected_vis"))
956             _datatype.set_visibility(VisibilityKind.protected_vis);
957         else if (visibility.endsWith("private_vis"))
958             _datatype.set_visibility(VisibilityKind.private_vis);
959
960         String JavaDoc isAbstract = getValue(_datatype_element, "isAbstract");
961         if (isAbstract.endsWith("true"))
962             _datatype.set_is_abstract(true);
963
964         String JavaDoc isLeaf = getValue(_datatype_element, "isLeaf");
965         if (isLeaf.endsWith("true"))
966             _datatype.set_is_leaf(true);
967
968         String JavaDoc isRoot = getValue(_datatype_element, "isRoot");
969         if (isRoot.endsWith("true"))
970             _datatype.set_is_root(true);
971             
972         // récupérer le TypeCode
973
NodeList JavaDoc contents = _datatype_element.getChildNodes();
974         for (int i = 0; i < contents.getLength(); i++) {
975             Node JavaDoc node = contents.item(i);
976             if (node.getNodeType() == Node.ELEMENT_NODE) {
977                 Element JavaDoc contentElement = (Element JavaDoc) node;
978                 String JavaDoc currentName = contentElement.getNodeName().trim();
979                 if (currentName.endsWith("DataType.typeCode")) {
980                     Element JavaDoc typecode = null;
981                     NodeList JavaDoc listCorbaTypecode =
982                         contentElement.getElementsByTagName(
983                             "XMI.CorbaTypeCode");
984                     if (listCorbaTypecode.getLength() != 0) {
985                         Element JavaDoc corbaTypecode =
986                             (Element JavaDoc) listCorbaTypecode.item(0);
987                         NodeList JavaDoc childrens = corbaTypecode.getChildNodes();
988                         int j = 0;
989                         boolean isTypecode = false;
990                         while (j < childrens.getLength() && !isTypecode) {
991                             Node JavaDoc children = childrens.item(j);
992                             if (children.getNodeType() == Node.ELEMENT_NODE) {
993                                 typecode = (Element JavaDoc) children;
994                                 isTypecode = true;
995                             }
996                             j++;
997                         }
998
999                         //calcul du Repository ID
1000
String JavaDoc RepositoryID = getValue(typecode, "xmi.tcId");
1001                        if (RepositoryID == null)
1002                            RepositoryID =
1003                                "IDL:" + idlHelper.format1(_namespace.name());
1004
1005                        // calcul de _type code
1006
TypeCode JavaDoc _type_code =
1007                            xml2TypeCode(typecode, RepositoryID);
1008                        _datatype.set_type_code(_type_code);
1009                    }
1010                }
1011            }
1012        }
1013
1014        // Container and Contents
1015
_datatype.set_container(_namespace);
1016        _namespace.add_contents(_datatype);
1017
1018        // Store the Class into Types tables and eventually for tags
1019
String JavaDoc _key = _datatype_element.getAttribute("xmi.id").trim();
1020        _types.put(_key, _datatype);
1021        _Id2element.put(_key, _datatype);
1022
1023        return _datatype;
1024    }
1025
1026    /**
1027     * Datatypes processing
1028     */

1029    public void dataTypeTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
1030        org.omg.mof.Model.DataType _datatype = dataTypeAbstractTemplate(_datatype_element, _namespace);
1031        _dataTypes.put(_datatype_element.getAttribute("xmi.id"), _datatype.type_code());
1032    }
1033
1034    /**
1035     * PrimitiveType processing
1036     */

1037    public void primitiveTypeTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
1038        if (_datatype_element.hasAttribute("xmi.idref"))
1039            return;
1040        org.omg.mof.Model.DataType _datatype = dataTypeAbstractTemplate(_datatype_element, _namespace);
1041        org.omg.mof.Model.DataType dt = (org.omg.mof.Model.DataType) _types.get(_datatype.name());
1042        if (dt != null) {
1043            org.omg.CORBA.TypeCode JavaDoc typeCode = dt.type_code();
1044            _datatype.set_type_code(typeCode);
1045            _dataTypes.put(_datatype_element.getAttribute("xmi.id"), typeCode);
1046        }
1047    }
1048    
1049    
1050
1051    public void typeElementTypeTemplate (org.w3c.dom.Element JavaDoc _element, org.omg.mof.Model.Namespace _namespace)
1052        throws org.omg.mof.Reflective.MofError {
1053        NodeList JavaDoc namespaceContents = _element.getChildNodes();
1054        for (int j = 0; j < namespaceContents.getLength(); j++) {
1055            if (namespaceContents.item(j).getNodeType() == Node.ELEMENT_NODE) {
1056                Element JavaDoc subElement = (Element JavaDoc) namespaceContents.item(j);
1057                String JavaDoc _sub_element_name = subElement.getNodeName().trim();
1058                if (_sub_element_name.endsWith("Association"))
1059                    associationTemplate(subElement, _namespace);
1060                else if (_sub_element_name.endsWith("StructureType"))
1061                    structureTypeTemplate(subElement, _namespace);
1062                else if (_sub_element_name.endsWith("CollectionType"))
1063                    collectionTypeTemplate(subElement, _namespace);
1064                else if (_sub_element_name.endsWith("AliasType"))
1065                    aliasTypeTemplate(subElement, _namespace);
1066                else if (_sub_element_name.endsWith("EnumerationType"))
1067                    enumerationTypeTemplate(subElement, _namespace);
1068                else if (_sub_element_name.endsWith("PrimitiveType"))
1069                    primitiveTypeTemplate(subElement, _namespace);
1070                else if (_sub_element_name.endsWith("DataType"))
1071                    dataTypeTemplate(subElement, _namespace);
1072            }
1073        }
1074    }
1075    
1076
1077    /**
1078     * AliasType processing
1079     */

1080    public void aliasTypeTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
1081        if (_datatype_element.hasAttribute("xmi.idref"))
1082            return;
1083        org.omg.mof.Model.DataType _datatype = dataTypeAbstractTemplate(_datatype_element, _namespace);
1084        String JavaDoc repID = "IDL:" + this.idlHelper.format1(_namespace.name()) + "/" + _datatype.name() + ":1.0";
1085        org.w3c.dom.NodeList JavaDoc _contents = _datatype_element.getChildNodes();
1086        for (int i = 0; i < _contents.getLength(); i++) {
1087            org.w3c.dom.Element JavaDoc _element = (Element JavaDoc) _contents.item(i);
1088            String JavaDoc _element_name = _element.getNodeName().trim();
1089            if (_element_name.endsWith("TypedElement.type")) {
1090                String JavaDoc idref = new String JavaDoc();
1091                if (_element.hasAttribute("xmi.idref")) {
1092                    idref = _element.getAttribute("xmi.idref");
1093                } else {
1094                    typeElementTypeTemplate(_element, _namespace);
1095                    if (_element.getFirstChild().getNodeType() == Node.ELEMENT_NODE) {
1096                        idref = ((org.w3c.dom.Element JavaDoc)_element.getFirstChild()).getAttribute("xmi.id");
1097                        if (idref == null || idref.length() == 0)
1098                            idref = ((org.w3c.dom.Element JavaDoc)_element.getFirstChild()).getAttribute("xmi.idref");
1099                    }
1100                }
1101                org.omg.CORBA.TypeCode JavaDoc tc = (org.omg.CORBA.TypeCode JavaDoc) _dataTypes.get(idref);
1102                if (tc != null) {
1103                    org.omg.CORBA.TypeCode JavaDoc _typecode = _orb.create_alias_tc(repID, _datatype.name(), tc);
1104                    _datatype.set_type_code(_typecode);
1105                    _dataTypes.put(_datatype_element.getAttribute("xmi.id"), _typecode);
1106                }
1107            }
1108        }
1109    }
1110
1111    /**
1112     * CollectionType processing
1113     */

1114    public void collectionTypeTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
1115        if (_datatype_element.hasAttribute("xmi.idref"))
1116            return;
1117        org.omg.mof.Model.DataType _datatype = dataTypeAbstractTemplate(_datatype_element, _namespace);
1118        String JavaDoc repID = "IDL:" + this.idlHelper.format1(_namespace.name()) + "/" + _datatype.name() + ":1.0";
1119        org.w3c.dom.NodeList JavaDoc _contents = _datatype_element.getChildNodes();
1120        for (int i = 0; i < _contents.getLength(); i++) {
1121            org.w3c.dom.Element JavaDoc _element = (Element JavaDoc) _contents.item(i);
1122            String JavaDoc _element_name = _element.getNodeName().trim();
1123            if (_element_name.endsWith("TypedElement.type")) {
1124                String JavaDoc idref = new String JavaDoc();
1125                if (_element.hasAttribute("xmi.idref")) {
1126                    idref = _element.getAttribute("xmi.idref");
1127                } else {
1128                    typeElementTypeTemplate(_element, _namespace);
1129                    if (_element.getFirstChild().getNodeType() == Node.ELEMENT_NODE) {
1130                        idref = ((org.w3c.dom.Element JavaDoc)_element.getFirstChild()).getAttribute("xmi.id");
1131                        if (idref == null || idref.length() == 0)
1132                            idref = ((org.w3c.dom.Element JavaDoc)_element.getFirstChild()).getAttribute("xmi.idref");
1133                    }
1134                }
1135                org.omg.CORBA.TypeCode JavaDoc tc = (org.omg.CORBA.TypeCode JavaDoc) _dataTypes.get(idref);
1136                if (tc != null) {
1137                    org.omg.CORBA.TypeCode JavaDoc _typecode = _orb.create_sequence_tc(0, tc);
1138                    _datatype.set_type_code(_typecode);
1139                    _dataTypes.put(_datatype_element.getAttribute("xmi.id"), _typecode);
1140                }
1141            }
1142        }
1143    }
1144
1145    /**
1146     * EnumerationType processing
1147     */

1148    public void enumerationTypeTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
1149        if (_datatype_element.hasAttribute("xmi.idref"))
1150            return;
1151        org.omg.mof.Model.DataType _datatype = dataTypeAbstractTemplate(_datatype_element, _namespace);
1152
1153        Vector JavaDoc _members = new Vector JavaDoc();
1154        org.w3c.dom.NodeList JavaDoc _labels = _datatype_element.getChildNodes();
1155        for (int i = 0; i < _labels.getLength(); i++) {
1156            org.w3c.dom.Element JavaDoc _element = (Element JavaDoc) _labels.item(i);
1157            String JavaDoc _element_name = _element.getNodeName().trim();
1158            if (_element_name.endsWith("EnumerationType.labels")) {
1159                _members.addElement(_element.getFirstChild().getNodeValue().trim());
1160            }
1161        }
1162        String JavaDoc[] _enum_members = new String JavaDoc[_members.size()];
1163        for (int i = 0; i < _members.size(); i++)
1164            _enum_members[i] = (String JavaDoc) _members.elementAt(i);
1165        String JavaDoc repID = "IDL:" + this.idlHelper.format1(_namespace.name()) + "/" + _datatype.name() + ":1.0";
1166        org.omg.CORBA.TypeCode JavaDoc typeCode = _orb.create_enum_tc(repID, _datatype.name(), _enum_members);
1167        _datatype.set_type_code(typeCode);
1168        _dataTypes.put(_datatype_element.getAttribute("xmi.id"), typeCode);
1169    }
1170
1171    /**
1172     * StructureType processing
1173     */

1174    public void structureTypeTemplate(org.w3c.dom.Element JavaDoc _datatype_element, org.omg.mof.Model.Namespace _namespace) throws org.omg.mof.Reflective.MofError {
1175        if (_datatype_element.hasAttribute("xmi.idref"))
1176            return;
1177        org.omg.mof.Model.DataType _datatype = dataTypeAbstractTemplate(_datatype_element, _namespace);
1178        org.w3c.dom.NodeList JavaDoc _child = _datatype_element.getChildNodes();
1179        for (int i = 0; i < _child.getLength(); i++) {
1180            org.w3c.dom.Element JavaDoc _current = (Element JavaDoc) _child.item(i);
1181            readStructureTypeContents(_namespace, _datatype, _current);
1182        }
1183    }
1184
1185    public void readStructureFieldType(org.omg.CORBA.StructMember JavaDoc _member, org.w3c.dom.Element JavaDoc _type) throws org.omg.mof.Reflective.MofError {
1186        org.w3c.dom.Element JavaDoc classifier = (Element JavaDoc) _type.getFirstChild();
1187        org.omg.CORBA.TypeCode JavaDoc _field_typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_any);
1188        if (classifier.hasAttribute("xmi.idref")) {
1189            // Link to the reference
1190
if (_dataTypes.containsKey(classifier.getAttribute("xmi.idref"))) {
1191                _field_typecode = (org.omg.CORBA.TypeCode JavaDoc) _dataTypes.get(classifier.getAttribute("xmi.idref"));
1192            }
1193            if (_types.containsKey(classifier.getAttribute("xmi.idref"))) {
1194                org.omg.mof.Model.DataType type = (org.omg.mof.Model.DataType) _types.get(classifier.getAttribute("xmi.idref"));
1195                _field_typecode = type.type_code();
1196            }
1197        } else if (classifier.hasAttribute("href")) {
1198            // Import from the specified file
1199
}
1200        _member.type = _field_typecode;
1201    }
1202
1203    public void readStructureTypeContents(org.omg.mof.Model.Namespace _namespace, org.omg.mof.Model.DataType _datatype, Element JavaDoc element) throws org.omg.mof.Reflective.MofError {
1204        String JavaDoc repID = "IDL:" + idlHelper.format1(_namespace.name()) + "/" + _datatype.name();
1205        Vector JavaDoc _struct_members = new Vector JavaDoc();
1206        org.w3c.dom.NodeList JavaDoc _fields = element.getChildNodes();
1207        for (int i = 0; i < _fields.getLength(); i++) {
1208            org.w3c.dom.Element JavaDoc _element = (Element JavaDoc) _fields.item(i);
1209            String JavaDoc _element_name = _element.getNodeName().trim();
1210            if (_element_name.endsWith("StructureField")) {
1211                org.omg.CORBA.StructMember JavaDoc _member = new org.omg.CORBA.StructMember JavaDoc();
1212                _member.name = _element.getAttribute("name").trim();
1213                org.w3c.dom.NodeList JavaDoc _types = _element.getChildNodes();
1214                for (int j = 0; j < _types.getLength(); j++) {
1215                    org.w3c.dom.Element JavaDoc _type = (Element JavaDoc) _types.item(j);
1216                    String JavaDoc _type_name = _type.getNodeName().trim();
1217                    if (_type_name.endsWith("TypedElement.type")) {
1218                        readStructureFieldType(_member, _type);
1219                    }
1220                }
1221                _struct_members.addElement(_member);
1222            }
1223        }
1224        org.omg.CORBA.StructMember JavaDoc[] _members = new org.omg.CORBA.StructMember JavaDoc[_struct_members.size()];
1225        for (int j = 0; j < _struct_members.size(); j++)
1226            _members[j] = (org.omg.CORBA.StructMember JavaDoc) _struct_members.elementAt(j);
1227        _datatype.set_type_code(_orb.create_struct_tc(repID + ":1.0", _datatype.name(), _members));
1228        _dataTypes.put(element.getAttribute("xmi.id"), _datatype.type_code());
1229    }
1230
1231
1232    //Traitement des constants
1233
public void constantTemplate(
1234        Element JavaDoc _constant_element,
1235        Namespace _namespace)
1236        throws MofError {
1237
1238        // création d'un constant par défault
1239
Constant _constant =
1240            _constant_class.create_constant("name", "", _orb.create_any());
1241        //la valeur
1242
String JavaDoc _id = _constant_element.getAttribute("xmi.id").trim();
1243
1244        // récupérer les propriétés
1245
String JavaDoc name = getValue(_constant_element, "name");
1246        if (name.compareTo("") != 0)
1247            _constant.set_name(name);
1248
1249        String JavaDoc annotation = getValue(_constant_element, "annotation");
1250        if (annotation.compareTo("") != 0)
1251            _constant.set_annotation(annotation);
1252
1253        // récupérer le type
1254
_elementsToType.put(_constant, getType(_constant_element));
1255
1256        // récupérer le type
1257
NodeList JavaDoc contents = _constant_element.getChildNodes();
1258        for (int i = 0; i < contents.getLength(); i++) {
1259            Node JavaDoc node = contents.item(i);
1260            if (node.getNodeType() == Node.ELEMENT_NODE) {
1261                Element JavaDoc contentElement = (Element JavaDoc) node;
1262                String JavaDoc currentName = contentElement.getNodeName().trim();
1263                if (currentName.endsWith("Constant.value")) {
1264                    NodeList JavaDoc elements = contentElement.getChildNodes();
1265                    for (int j = 0; j < elements.getLength(); j++) {
1266                        if (elements.item(j).getNodeType()
1267                            == Node.ELEMENT_NODE) {
1268                            Element JavaDoc element = (Element JavaDoc) elements.item(j);
1269                            String JavaDoc _element_name = element.getNodeName().trim();
1270                            if (_element_name.endsWith("XMI.any")) {
1271                                String JavaDoc value =
1272                                    element.getFirstChild().getNodeValue();
1273                                _constantValue.put(_constant, value);
1274                            }
1275                        }
1276                    }
1277                }
1278            }
1279        }
1280        _constant.set_container(_namespace);
1281        _namespace.add_contents(_constant);
1282    }
1283
1284    // traitement du Tag
1285
public void tagTemplate(Element JavaDoc _tag_element, Namespace _namespace)
1286        throws MofError {
1287
1288        // création d'une classe par défault
1289
org.omg.CORBA.Any JavaDoc[] _any_t = new org.omg.CORBA.Any JavaDoc[1];
1290        org.omg.CORBA.Any JavaDoc _mof_tag = _orb.create_any();
1291        _mof_tag.insert_string("");
1292        _any_t[0] = _mof_tag;
1293        Tag _tag = _tag_class.create_tag("name", "", "", _any_t);
1294
1295        // récupérer les propriétés
1296
String JavaDoc name = getValue(_tag_element, "name");
1297        if (name.compareTo("") != 0)
1298            _tag.set_name(name);
1299
1300        String JavaDoc annotation = getValue(_tag_element, "annotation");
1301        if (annotation.compareTo("") != 0)
1302            _tag.set_annotation(annotation);
1303
1304        String JavaDoc tagId = getValue(_tag_element, "tagId");
1305        _tag.set_tag_id(tagId);
1306
1307        //recover values : XMI version 1.1
1308
String JavaDoc taggedeElements = _tag_element.getAttribute("elements");
1309        if (taggedeElements.compareTo("") != 0) {
1310            Vector JavaDoc _tagged_elements = new Vector JavaDoc();
1311            StringTokenizer JavaDoc supRefs =
1312                new StringTokenizer JavaDoc(taggedeElements, " ");
1313            while (supRefs.hasMoreTokens()) {
1314                String JavaDoc part = supRefs.nextToken();
1315                _tagged_elements.addElement(part);
1316            }
1317            _tags.put(_tag, _tagged_elements);
1318        }
1319
1320        // récupérer les valeurs et les éléments asscociés
1321
NodeList JavaDoc children = _tag_element.getChildNodes();
1322        for (int i = 0; i < children.getLength(); i++) {
1323            Element JavaDoc currentElement = (Element JavaDoc) children.item(i);
1324            String JavaDoc childrenName = currentElement.getNodeName().trim();
1325            if (childrenName.endsWith("Tag.values")) {
1326                NodeList JavaDoc anylist =
1327                    currentElement.getElementsByTagName("XMI.any");
1328                if (anylist.getLength() != 0) {
1329                    Element JavaDoc anyElement = (Element JavaDoc) anylist.item(0);
1330                    String JavaDoc type = anyElement.getAttribute("xmi.type").trim();
1331                    if (type.endsWith("string")) {
1332                        org.omg.CORBA.Any JavaDoc[] any_tc = new org.omg.CORBA.Any JavaDoc[1];
1333                        org.omg.CORBA.Any JavaDoc mof_tag_c = _orb.create_any();
1334
1335                        NodeList JavaDoc temp = anyElement.getChildNodes();
1336                        for (int j = 0; j < temp.getLength(); j++) {
1337                            Node JavaDoc current = temp.item(j);
1338                            if (current.getNodeType() == Node.TEXT_NODE) {
1339                                String JavaDoc tagValue = current.getNodeValue().trim();
1340                                mof_tag_c.insert_string(tagValue);
1341                                any_tc[0] = mof_tag_c;
1342                                _tag.set_values(any_tc);
1343                            }
1344                        }
1345                    }
1346                }
1347            } else
1348                //recover values : XMI version 1.O
1349
if (childrenName.endsWith("elements")) {
1350                    Vector JavaDoc _tagged_elements = new Vector JavaDoc();
1351                    NodeList JavaDoc elements = currentElement.getChildNodes();
1352                    for (int j = 0; j < elements.getLength(); j++) {
1353                        Node JavaDoc node = elements.item(j);
1354                        if (node.getNodeType() == Node.ELEMENT_NODE) {
1355                            Element JavaDoc contentElement = (Element JavaDoc) node;
1356                            String JavaDoc currentName =
1357                                contentElement.getNodeName().trim();
1358                            if (currentName.endsWith("ModelElement")) {
1359                                String JavaDoc _key_element =
1360                                    contentElement
1361                                        .getAttribute("xmi.idref")
1362                                        .trim();
1363                                _tagged_elements.addElement(_key_element);
1364
1365                            }
1366                        }
1367                    }
1368                    _tags.put(_tag, _tagged_elements);
1369                }
1370        }
1371
1372        _tag.set_container(_namespace);
1373        _namespace.add_contents(_tag);
1374    }
1375
1376    /**
1377     * Method importPackage.
1378     * @param _element
1379     */

1380    public void importTemplate(Element JavaDoc _import_element, Namespace _container)
1381        throws MofError {
1382
1383        //créer un objet import par défaut
1384
org.omg.mof.Model.Import _import =
1385            _import_class.create_import(
1386                "name",
1387                "",
1388                VisibilityKind.public_vis,
1389                false);
1390
1391        // récupérer l'identificateur
1392
String JavaDoc _key = _import_element.getAttribute("xmi.id").trim();
1393
1394        //Propriétés de la class
1395
String JavaDoc name = getValue(_import_element, "name");
1396        if (name.compareTo("") != 0)
1397            _import.set_name(name);
1398
1399        String JavaDoc annotation = getValue(_import_element, "annotation");
1400        if (annotation.compareTo("") != 0)
1401            _import.set_annotation(annotation);
1402
1403        String JavaDoc visibility = getValue(_import_element, "visibility");
1404        if (visibility.endsWith("protected_vis"))
1405            _import.set_visibility(VisibilityKind.protected_vis);
1406        else if (visibility.endsWith("private_vis"))
1407            _import.set_visibility(VisibilityKind.private_vis);
1408
1409        String JavaDoc isClustered = getValue(_import_element, "isClustered");
1410        if (isClustered.endsWith("true"))
1411            _import.set_is_clustered(true);
1412
1413        //to recover an imported namesapce : XMI version 1.1
1414
String JavaDoc refImported = _import_element.getAttribute("importedNamespace");
1415        if (refImported.compareTo("") != 0)
1416            _Import2Imported.put(_import, refImported);
1417
1418        //to recover an imported namesapce : XMI version 1.0
1419
NodeList JavaDoc contents = _import_element.getChildNodes();
1420        for (int i = 0; i < contents.getLength(); i++) {
1421            Node JavaDoc node = contents.item(i);
1422            if (node.getNodeType() == Node.ELEMENT_NODE) {
1423                Element JavaDoc contentElement = (Element JavaDoc) node;
1424                String JavaDoc currentName = contentElement.getNodeName().trim();
1425                if (currentName.endsWith("Import.importedNamespace")) {
1426                    NodeList JavaDoc elements = contentElement.getChildNodes();
1427                    for (int j = 0; j < elements.getLength(); j++) {
1428                        if (elements.item(j).getNodeType()
1429                            == Node.ELEMENT_NODE) {
1430                            Element JavaDoc element = (Element JavaDoc) elements.item(j);
1431                            String JavaDoc _element_name = element.getNodeName().trim();
1432                            if (_element_name.endsWith("Namespace")) {
1433
1434                                String JavaDoc ref = element.getAttribute("xmi.idref");
1435                                //mettre à jour les packages importés
1436
_Import2Imported.put(_import, ref);
1437                            }
1438                        }
1439                    }
1440                }
1441            }
1442        }
1443
1444        // container et contents
1445
_import.set_container(_container);
1446        _container.add_contents(_import);
1447
1448    }
1449
1450    // passer de l'XML au Type code CORBA
1451
public org.omg.CORBA.TypeCode JavaDoc xml2TypeCode(
1452        Element JavaDoc _element,
1453        String JavaDoc RepositoryID)
1454        throws org.omg.CORBA.BAD_TYPECODE JavaDoc {
1455        String JavaDoc _element_name = _element.getNodeName().trim();
1456        org.omg.CORBA.TypeCode JavaDoc _typecode = null;
1457        if (_element_name.startsWith("XMI.CorbaTcBoolean"))
1458            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean);
1459        else if (_element_name.startsWith("XMI.CorbaTcOctet"))
1460            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet);
1461        else if (_element_name.startsWith("XMI.CorbaTcChar"))
1462            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_char);
1463        else if (_element_name.startsWith("XMI.CorbaTcWchar"))
1464            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_wchar);
1465        else if (_element_name.startsWith("XMI.CorbaTcShort"))
1466            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_short);
1467        else if (_element_name.startsWith("XMI.CorbaTcUshort"))
1468            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ushort);
1469        else if (_element_name.startsWith("XMI.CorbaTcLong"))
1470            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
1471        else if (_element_name.startsWith("XMI.CorbaTcUlong"))
1472            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong);
1473        else if (_element_name.startsWith("XMI.CorbaTcLongLong"))
1474            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_longlong);
1475        else if (_element_name.startsWith("XMI.CorbaTcULongLong"))
1476            _typecode =
1477                _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_ulonglong);
1478        else if (_element_name.startsWith("XMI.CorbaTcDouble"))
1479            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_double);
1480        else if (_element_name.startsWith("XMI.CorbaTcFloat"))
1481            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_float);
1482        else if (_element_name.startsWith("XMI.CorbaTcTypeCode"))
1483            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_TypeCode);
1484        else if (_element_name.startsWith("XMI.CorbaTcAny"))
1485            _typecode = _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_any);
1486        else if (_element_name.startsWith("XMI.CorbaTcString")) {
1487            String JavaDoc _bound_value = _element.getAttribute("xmi.tcLength").trim();
1488            if (_bound_value.compareTo("") == 0)
1489                _typecode =
1490                    _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
1491            else {
1492                int _bound = Integer.parseInt(_bound_value);
1493                _typecode = _orb.create_string_tc(_bound);
1494            }
1495        } else if (_element_name.startsWith("XMI.CorbaTcWstring")) {
1496            String JavaDoc _bound_value = _element.getAttribute("xmi.tcLength").trim();
1497            if (_bound_value.compareTo("") != 0)
1498                _typecode =
1499                    _orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
1500            else {
1501                int _bound = Integer.parseInt(_bound_value);
1502                _typecode = _orb.create_string_tc(_bound);
1503            }
1504        } else if (_element_name.startsWith("XMI.CorbaTcStruct")) {
1505
1506            // le nom de la structure
1507
String JavaDoc _name = _element.getAttribute("xmi.tcName").trim();
1508            String JavaDoc RepID = RepositoryID + "/" + _name + ":1.0";
1509
1510            // réupérer les membres de la structure
1511
NodeList JavaDoc _fields = _element.getChildNodes();
1512            Vector JavaDoc _struct_members = new Vector JavaDoc();
1513            for (int i = 0; i < _fields.getLength(); i++) {
1514                Element JavaDoc _field = (Element JavaDoc) _fields.item(i);
1515                String JavaDoc _tag = _field.getNodeName();
1516                if (_tag.endsWith("CorbaTcField")) {
1517                    Element JavaDoc _type_field =
1518                        (Element JavaDoc) _field.getElementsByTagName(
1519                            "XMI.CorbaTypeCode").item(
1520                            0);
1521                    // construire les membres de la structure
1522
org.omg.CORBA.StructMember JavaDoc _member =
1523                        new org.omg.CORBA.StructMember JavaDoc();
1524                    // nom
1525
String JavaDoc _field_name =
1526                        _field.getAttribute("xmi.tcName").trim();
1527                    _member.name = _field_name;
1528                    // le type
1529
Element JavaDoc _type_element =
1530                        (Element JavaDoc) _field.getElementsByTagName(
1531                            "XMI.CorbaTypeCode").item(
1532                            0);
1533                    Element JavaDoc _typecode_element =
1534                        (Element JavaDoc) _type_element.getFirstChild();
1535                    org.omg.CORBA.TypeCode JavaDoc _field_typecode =
1536                        xml2TypeCode(
1537                            _typecode_element,
1538                            RepID.substring(0, RepID.lastIndexOf(":")));
1539                    _member.type = _field_typecode;
1540                    //
1541
_struct_members.addElement(_member);
1542                }
1543            } //
1544
org.omg.CORBA.StructMember JavaDoc[] _members =
1545                new org.omg.CORBA.StructMember JavaDoc[_struct_members.size()];
1546            for (int j = 0; j < _struct_members.size(); j++)
1547                _members[j] =
1548                    (org.omg.CORBA.StructMember JavaDoc) _struct_members.elementAt(j);
1549            _typecode = _orb.create_struct_tc(RepID, _name, _members);
1550        } else if (_element_name.startsWith("XMI.CorbaTcSequence")) {
1551            //longueur de la sequence
1552
String JavaDoc _bound_value = _element.getAttribute("xmi.tcLength").trim();
1553            int _bound = 0;
1554            if (_bound_value.compareTo("") != 0)
1555                _bound = Integer.parseInt(_bound_value);
1556            //recupérer le type de la sequence
1557
Element JavaDoc _type_code =
1558                (Element JavaDoc) _element.getElementsByTagName(
1559                    "XMI.CorbaTypeCode").item(
1560                    0);
1561            Element JavaDoc _sequence_element = (Element JavaDoc) _type_code.getFirstChild();
1562            // récupérer le type code de la séquence
1563
org.omg.CORBA.TypeCode JavaDoc _sequence_type =
1564                xml2TypeCode(_sequence_element, "");
1565            _typecode = _orb.create_sequence_tc(_bound, _sequence_type);
1566        } else if (_element_name.startsWith("XMI.CorbaTcEnum")) {
1567
1568            // le nom de l'énumération
1569
String JavaDoc _name = _element.getAttribute("xmi.tcName").trim();
1570            String JavaDoc RepID = RepositoryID + "/" + _name + ":1.0";
1571            // calculer les membres de l'énumération
1572
Vector JavaDoc members = new Vector JavaDoc();
1573            NodeList JavaDoc enumLabel =
1574                _element.getElementsByTagName("XMI.CorbaTcEnumLabel");
1575            for (int j = 0; j < enumLabel.getLength(); j++) {
1576                Element JavaDoc memeber = (Element JavaDoc) enumLabel.item(j);
1577                String JavaDoc value = memeber.getAttribute("xmi.tcName").trim();
1578                members.addElement(value);
1579            }
1580            String JavaDoc[] enumMembers = new String JavaDoc[members.size()];
1581            for (int i = 0; i < members.size(); i++)
1582                enumMembers[i] = (String JavaDoc) members.elementAt(i);
1583            _typecode = _orb.create_enum_tc(RepID, _name, enumMembers);
1584        } else if (_element_name.startsWith("XMI.CorbaTcAlias")) {
1585            // le nom de l'énumération
1586
String JavaDoc _name = _element.getAttribute("xmi.tcName").trim();
1587            String JavaDoc RepID = RepositoryID + "/" + _name + ":1.0";
1588            //recupérer le type de l'alias
1589
Element JavaDoc _type_code =
1590                (Element JavaDoc) _element.getElementsByTagName(
1591                    "XMI.CorbaTypeCode").item(
1592                    0);
1593            Element JavaDoc _alias_element = (Element JavaDoc) _type_code.getFirstChild();
1594            // récupérer le type code d'origine
1595
org.omg.CORBA.TypeCode JavaDoc _original_type =
1596                xml2TypeCode(
1597                    _alias_element,
1598                    RepID.substring(0, RepID.lastIndexOf(":")));
1599            _typecode = _orb.create_alias_tc(RepID, _name, _original_type);
1600        }
1601        return _typecode;
1602    }
1603
1604    // typer les paramètres et les attributs et les constant
1605
public void typing() throws BadKind JavaDoc, MofError {
1606        Enumeration JavaDoc _keys = _elementsToType.keys();
1607        while (_keys.hasMoreElements()) {
1608            TypedElement _typed_element = (TypedElement) _keys.nextElement();
1609
1610            // trouver la clé dans la deuxième table
1611
String JavaDoc _key = ((String JavaDoc) _elementsToType.get(_typed_element)).trim();
1612
1613            // trouve le classifier
1614
Classifier _classifier = (Classifier) _types.get(_key);
1615
1616            // typer
1617
_typed_element.set_type(_classifier);
1618
1619            // affecter la valeur des constant
1620
if (_typed_element._is_a(ConstantHelper.id())) {
1621                Constant _constant = ConstantHelper.narrow(_typed_element);
1622                String JavaDoc _value = (String JavaDoc) _constantValue.get(_constant);
1623                putConstantValue(_constant, _value);
1624
1625            }
1626        }
1627    }
1628
1629    //mettre les valeurs des constants
1630
public void putConstantValue(Constant _constant, String JavaDoc _value)
1631        throws BadKind JavaDoc, MofError {
1632
1633        Classifier _classifier = _constant.type();
1634
1635        if (_classifier._is_a(DataTypeHelper.id())) {
1636            DataType _datatype = DataTypeHelper.narrow(_classifier);
1637            org.omg.CORBA.TypeCode JavaDoc _typecode = _datatype.type_code();
1638            org.omg.CORBA.Any JavaDoc _any = _orb.create_any();
1639            switch (_typecode.kind().value()) {
1640                case org.omg.CORBA.TCKind._tk_boolean :
1641                    _any.insert_boolean(Boolean.valueOf(_value).booleanValue());
1642                    break;
1643                case org.omg.CORBA.TCKind._tk_octet :
1644
1645                    _any.insert_octet(Byte.valueOf(_value).byteValue());
1646                    break;
1647                case org.omg.CORBA.TCKind._tk_char :
1648                    _any.insert_char(_value.charAt(0));
1649                    break;
1650                case org.omg.CORBA.TCKind._tk_wchar :
1651                    _any.insert_wchar(_value.charAt(0));
1652                    break;
1653
1654                case org.omg.CORBA.TCKind._tk_short :
1655                    _any.insert_short(Short.valueOf(_value).shortValue());
1656                    break;
1657
1658                case org.omg.CORBA.TCKind._tk_ushort :
1659                    _any.insert_ushort(Short.valueOf(_value).shortValue());
1660                    break;
1661
1662                case org.omg.CORBA.TCKind._tk_long :
1663                    _any.insert_long(Integer.valueOf(_value).intValue());
1664                    break;
1665
1666                case org.omg.CORBA.TCKind._tk_ulong :
1667                    _any.insert_ulong(Integer.valueOf(_value).intValue());
1668                    break;
1669
1670                case org.omg.CORBA.TCKind._tk_longlong :
1671                    _any.insert_longlong(Long.valueOf(_value).longValue());
1672                    break;
1673
1674                case org.omg.CORBA.TCKind._tk_ulonglong :
1675                    _any.insert_ulonglong(Long.valueOf(_value).longValue());
1676                    break;
1677
1678                case org.omg.CORBA.TCKind._tk_double :
1679                    _any.insert_double(Double.valueOf(_value).doubleValue());
1680                    break;
1681
1682                case org.omg.CORBA.TCKind._tk_float :
1683                    _any.insert_float(Float.valueOf(_value).floatValue());
1684                    break;
1685
1686                case org.omg.CORBA.TCKind._tk_string :
1687                    _any.insert_string(_value.trim());
1688                    break;
1689
1690                case org.omg.CORBA.TCKind._tk_wstring :
1691                    _any.insert_wstring(_value.trim());
1692                    break;
1693
1694                default :
1695                    throw new BadKind JavaDoc();
1696            }
1697            _constant.set_value(_any);
1698        }
1699    }
1700
1701    /**
1702     * Mettre les supertypes à la fin
1703     */

1704    private void putSupertypes() throws MofError {
1705        Enumeration JavaDoc _keys = _elementsToSupertype.keys();
1706        while (_keys.hasMoreElements()) {
1707            org.omg.mof.Model.Class _class =
1708                (org.omg.mof.Model.Class) _keys.nextElement();
1709            // trouver la clé dans la deuxième table
1710
Vector JavaDoc _supertypes = ((Vector JavaDoc) _elementsToSupertype.get(_class));
1711            for (int i = 0; i < _supertypes.size(); i++) {
1712                String JavaDoc _key = ((String JavaDoc) _supertypes.elementAt(i)).trim();
1713                org.omg.mof.Model.Class _super =
1714                    (org.omg.mof.Model.Class) _types.get(_key);
1715                _class.add_supertypes(_super);
1716            }
1717        }
1718    }
1719
1720    /**
1721    *affecter les tags aux éléments
1722    * */

1723    public void taggedElement() throws MofError {
1724        Enumeration JavaDoc _keys = _tags.keys();
1725        while (_keys.hasMoreElements()) {
1726            Tag _tag = (Tag) _keys.nextElement();
1727            // trouver la clé dans la deuxième table
1728
Vector JavaDoc _tagged_elements = (Vector JavaDoc) _tags.get(_tag);
1729            for (int i = 0; i < _tagged_elements.size(); i++) {
1730                String JavaDoc _key = ((String JavaDoc) _tagged_elements.elementAt(i)).trim();
1731                ModelElement _element = (ModelElement) _Id2element.get(_key);
1732                _tag.add_elements(_element);
1733            }
1734        }
1735    }
1736
1737    /**
1738     * typage des référence et les lier aux associationsEnds corrrespondantes
1739     */

1740    public void associationEnds4Reference() throws MofError {
1741        Enumeration JavaDoc _keys = _referencedEndTable.keys();
1742
1743        while (_keys.hasMoreElements()) {
1744            Reference _reference = (Reference) _keys.nextElement();
1745            String JavaDoc _refend_id = (String JavaDoc) _referencedEndTable.get(_reference);
1746            AssociationEnd _ref_end = (AssociationEnd) _Id2End.get(_refend_id);
1747            _reference.set_type(_ref_end.type());
1748            _reference.set_referenced_end(_ref_end);
1749
1750            // Mettre exposedEnd
1751
String JavaDoc _expend_id = (String JavaDoc) _OtherEnd.get(_refend_id);
1752            AssociationEnd _exp_end = (AssociationEnd) _Id2End.get(_expend_id);
1753            _reference.set_exposed_end(_exp_end);
1754        }
1755    }
1756
1757    /**
1758     * suprimer les noeuds qui contiennent du text vide
1759     */

1760    public void delSpaces(Node JavaDoc _node)
1761        throws
1762            SAXException JavaDoc,
1763            ParserConfigurationException JavaDoc,
1764            FileNotFoundException JavaDoc,
1765            IOException JavaDoc {
1766
1767        NodeList JavaDoc _fils = _node.getChildNodes();
1768        int i = 0;
1769        while (i < _fils.getLength()) {
1770            Node JavaDoc _temp = _fils.item(i);
1771            if (_temp.getNodeType() == 3) {
1772                String JavaDoc _temp1 = _temp.getNodeValue();
1773                if (_temp1.trim().compareTo("") == 0)
1774                    _node.removeChild(_temp);
1775                else
1776                    i++;
1777            } else {
1778                delSpaces(_temp);
1779                i++;
1780            }
1781        }
1782    }
1783
1784    /**
1785     * Affecter les exceptions pour les opérations
1786     */

1787    public void exceptions4Operations() throws MofError {
1788        Enumeration JavaDoc _keys = _Exception4Operations.keys();
1789        while (_keys.hasMoreElements()) {
1790            Operation _operation = (Operation) _keys.nextElement();
1791            // trouver la clé dans la deuxième table
1792
Vector JavaDoc _exceptions = (Vector JavaDoc) _Exception4Operations.get(_operation);
1793            for (int i = 0; i < _exceptions.size(); i++) {
1794                String JavaDoc _idException =
1795                    ((String JavaDoc) _exceptions.elementAt(i)).trim();
1796                MofException _exception =
1797                    (MofException) _Id2exception.get(_idException);
1798                _operation.add_exceptions(_exception);
1799                //_exception.set_scope(_operation.scope());
1800

1801            }
1802        }
1803    }
1804
1805    /**
1806     * Method importElements.
1807     */

1808    private void importElements() throws MofError {
1809        for (Enumeration JavaDoc keys = _Import2Imported.keys();
1810            keys.hasMoreElements();
1811            ) {
1812            org.omg.mof.Model.Import importElement =
1813                (org.omg.mof.Model.Import) keys.nextElement();
1814
1815            //récupérer les éléments importés
1816
String JavaDoc refOfImported = (String JavaDoc) _Import2Imported.get(importElement);
1817
1818            //récupérer le package importateur
1819
Namespace _namespace = (Namespace) _Id2element.get(refOfImported);
1820
1821            //mettre à jour la référence
1822
importElement.set_imported_namespace(_namespace);
1823        }
1824    }
1825
1826    /**
1827     * Sets the idlHelper.
1828     * @param idlHelper The idlHelper to set
1829     */

1830    public void setIdlHelper(IDLCommon idlHelper) {
1831        this.idlHelper = idlHelper;
1832    }
1833
1834    /**
1835     * Get value of a property of an element even if it is encoded as an attribute or as a child element
1836     * Start by attribute
1837     */

1838    public String JavaDoc getValue(Element JavaDoc elt, String JavaDoc propertyName) {
1839        String JavaDoc res = "";
1840        //XMI 1.1
1841
res = elt.getAttribute(propertyName);
1842
1843        //XMI 1.0
1844
if ((res == null) || (res.compareTo("") == 0)) {
1845            NodeList JavaDoc children = elt.getChildNodes();
1846            for (int i = 0; i < children.getLength(); i++) {
1847                Node JavaDoc current = children.item(i);
1848                if (current.getNodeType() == Node.ELEMENT_NODE) {
1849                    Element JavaDoc currentElement = (Element JavaDoc) current;
1850                    if (currentElement
1851                        .getNodeName()
1852                        .toLowerCase()
1853                        .endsWith(propertyName.toLowerCase())) {
1854                        res = currentElement.getAttribute("xmi.value");
1855                        if ((res == null) || (res.compareTo("") == 0)) {
1856                            Node JavaDoc temp = currentElement.getFirstChild();
1857                            if (temp != null)
1858                                res = temp.getNodeValue().trim();
1859                        }
1860                    }
1861                }
1862            }
1863        }
1864
1865        return res;
1866    }
1867
1868    /**
1869     * Get value of type
1870     */

1871    public String JavaDoc getType(Element JavaDoc elt) {
1872
1873        //XMI 1.1
1874
String JavaDoc type = elt.getAttribute("type");
1875        if (type.compareTo("") != 0)
1876            return type;
1877        //XMI 1.0
1878
NodeList JavaDoc contents = elt.getChildNodes();
1879        for (int i = 0; i < contents.getLength(); i++) {
1880            Node JavaDoc node = contents.item(i);
1881            if (node.getNodeType() == Node.ELEMENT_NODE) {
1882                Element JavaDoc contentElement = (Element JavaDoc) node;
1883                String JavaDoc currentName = contentElement.getNodeName().trim();
1884                if (currentName.endsWith("TypedElement.type")) {
1885
1886                    NodeList JavaDoc children = contentElement.getChildNodes();
1887
1888                    for (int j = 0; j < children.getLength(); j++) {
1889                        Node JavaDoc current = children.item(j);
1890                        if (current.getNodeType() == Node.ELEMENT_NODE) {
1891                            Element JavaDoc currentElement = (Element JavaDoc) current;
1892                            String JavaDoc classifierType =
1893                                currentElement.getNodeName().trim();
1894
1895                            if (classifierType.endsWith("Classifier")
1896                                || classifierType.endsWith("Class")
1897                                || classifierType.endsWith("Association")
1898                                || classifierType.endsWith("DataType"))
1899                                type =
1900                                    currentElement
1901                                        .getAttribute("xmi.idref")
1902                                        .trim();
1903
1904                        }
1905                    }
1906                }
1907            }
1908        }
1909
1910        return type;
1911    }
1912
1913    /**
1914     * Get value of referencedEnd for Reference
1915     */

1916    public String JavaDoc getReferencedEnd(Element JavaDoc elt) {
1917
1918        //XMI 1.1
1919
String JavaDoc ref = elt.getAttribute("referencedEnd").trim();
1920        if (ref.compareTo("") != 0)
1921            return ref;
1922
1923        //XMI 1.0
1924
NodeList JavaDoc contents = elt.getChildNodes();
1925        for (int i = 0; i < contents.getLength(); i++) {
1926            Node JavaDoc node = contents.item(i);
1927            if (node.getNodeType() == Node.ELEMENT_NODE) {
1928                Element JavaDoc contentElement = (Element JavaDoc) node;
1929                String JavaDoc currentName = contentElement.getNodeName().trim();
1930                if (currentName.endsWith("Reference.referencedEnd")) {
1931
1932                    NodeList JavaDoc children = contentElement.getChildNodes();
1933
1934                    for (int j = 0; j < children.getLength(); j++) {
1935                        Node JavaDoc current = children.item(j);
1936                        if (current.getNodeType() == Node.ELEMENT_NODE) {
1937                            Element JavaDoc currentElement = (Element JavaDoc) current;
1938                            String JavaDoc referencedEndName =
1939                                currentElement.getNodeName().trim();
1940
1941                            if (referencedEndName.endsWith("AssociationEnd"))
1942                                ref =
1943                                    currentElement
1944                                        .getAttribute("xmi.idref")
1945                                        .trim();
1946                        }
1947                    }
1948                }
1949            }
1950        }
1951
1952        return ref;
1953    }
1954
1955    /**
1956     * Get value of a Multiplicity
1957     */

1958    public MultiplicityType getMultiplicity(Element JavaDoc elt) {
1959
1960        NodeList JavaDoc contents = elt.getChildNodes();
1961        for (int i = 0; i < contents.getLength(); i++) {
1962            Node JavaDoc node = contents.item(i);
1963            if (node.getNodeType() == Node.ELEMENT_NODE) {
1964                Element JavaDoc contentElement = (Element JavaDoc) node;
1965                String JavaDoc currentName = contentElement.getNodeName().trim();
1966                if (currentName.endsWith("multiplicity")) {
1967                    NodeList JavaDoc list = contentElement.getChildNodes();
1968                    for (int j = 0; j < list.getLength(); j++) {
1969                        if (list.item(j).getNodeType() == Node.ELEMENT_NODE) {
1970                            Element JavaDoc element = (Element JavaDoc) list.item(j);
1971                            String JavaDoc _element_name = element.getNodeName().trim();
1972
1973                            //XMI version 1.1
1974
if (_element_name.endsWith("MultiplicityType"))
1975                                return new MultiplicityType(
1976                                    Integer.parseInt(
1977                                        element.getAttribute("lower").trim()),
1978                                    Integer.parseInt(
1979                                        element.getAttribute("upper").trim()),
1980                                    Boolean.getBoolean(
1981                                        element
1982                                            .getAttribute("is_ordered")
1983                                            .trim()),
1984                                    Boolean.getBoolean(
1985                                        element
1986                                            .getAttribute("is_unique")
1987                                            .trim()));
1988
1989                            //XMI 1.0
1990
boolean is_unique = false, is_ordered = false;
1991                            int lower = 0, upper = -1;
1992                            NodeList JavaDoc properties =
1993                                contentElement.getChildNodes();
1994                            for (int k = 0; k < properties.getLength(); k++) {
1995                                if (properties.item(k).getNodeType()
1996                                    == Node.ELEMENT_NODE) {
1997                                    Element JavaDoc item = (Element JavaDoc) properties.item(k);
1998                                    String JavaDoc value =
1999                                        item
2000                                            .getFirstChild()
2001                                            .getNodeValue()
2002                                            .trim();
2003                                    if (k == 0) {
2004                                        lower = Integer.parseInt(value);
2005                                    } else if (k == 1) {
2006                                        upper = Integer.parseInt(value);
2007                                    } else if (k == 2) {
2008                                        if (value.endsWith("true"))
2009                                            is_ordered = true;
2010                                    } else if (k == 3) {
2011                                        if (value.endsWith("true"))
2012                                            is_unique = true;
2013                                    }
2014                                }
2015                            }
2016                            return new MultiplicityType(
2017                                lower,
2018                                upper,
2019                                is_ordered,
2020                                is_unique);
2021                        }
2022                    }
2023                }
2024            }
2025        }
2026        return null;
2027    }
2028
2029    /**
2030     * Sets the logger.
2031     * @param logger The logger to set
2032     */

2033    public void setLogger(ModFactLogger logger) {
2034        this.logger = logger;
2035    }
2036
2037}
Popular Tags