KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > mdr > storagemodel > BootReader


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.mdr.storagemodel;
20
21 import org.netbeans.mdr.NBMDRepositoryImpl;
22 import org.netbeans.mdr.handlers.EnumResolver;
23 import org.netbeans.mdr.handlers.StructImpl;
24 import org.netbeans.mdr.persistence.MOFID;
25 import org.netbeans.mdr.persistence.StorageException;
26 import org.netbeans.mdr.util.*;
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Node JavaDoc;
29 import org.w3c.dom.NodeList JavaDoc;
30 import org.xml.sax.EntityResolver JavaDoc;
31 import org.xml.sax.InputSource JavaDoc;
32 import org.xml.sax.SAXException JavaDoc;
33 import javax.xml.parsers.DocumentBuilder JavaDoc;
34 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
35 import javax.xml.parsers.ParserConfigurationException JavaDoc;
36 import java.io.IOException JavaDoc;
37 import java.io.StringReader JavaDoc;
38 import java.net.URL JavaDoc;
39 import java.util.*;
40
41 /** Special XmiReader used for reading MOF model
42  * when the repository is empty (during the bootsequence).
43  *
44  * @author Petr Hrebejk, Pavel Buzek, Martin Matula
45  * @version 0.2
46  */

47 public class BootReader extends Object JavaDoc {
48     /** package prefix for JMI interfaces */
49     private static final String JavaDoc JMI_PACKAGE_PREFIX = "javax.jmi.model.";
50
51     /** MDRStorage which has to be booted */
52     private final MdrStorage mdrStorage;
53     /** URL of XMI document to be read */
54     private final URL JavaDoc docURL;
55     /** object descriptors by fully qualified name */
56     private final Hashtable odByName = new Hashtable(100);
57     /** object descriptors by XMI.ID */
58     private final Hashtable odByXmiId = new Hashtable(100);
59     /** TypeAlias XMI.ID -> XMI.ID of type it is pointing to */
60     private final Hashtable aliases = new Hashtable(10);
61     /** data types that are going to be excluded - instances of PrimitiveType which are not contained in PrimitiveTypes package */
62     private final List JavaDoc excludeTypes = new ArrayList(3);
63     /** object MofIds by fully qualified name */
64     private final Hashtable objectsByName = new Hashtable(100);
65     /** class proxy MofIds by fully qualified name of metaobject */
66     private final Hashtable proxyIdByName = new Hashtable(11);
67     
68     /** class proxy objects by MofIds */
69     private final Hashtable proxyById = new Hashtable();
70     /** List of descriptor objects : class - superclass */
71     private final ArrayList superclassByClass = new ArrayList();
72     /** class proxy objects by XmiIds */
73     private final Hashtable proxyIdByXmiId = new Hashtable();
74     /** forward proxies references */
75     private final HashSet proxyReferences = new HashSet();
76     /** association ends by other ends (FQNs) */
77     private final HashMap otherEnds = new HashMap();
78
79     /** parsed XMI document */
80     private Document JavaDoc document = null;
81     /** reference to Contains association */
82     private StorableAssociation containsAssociation = null;
83
84     private static class DummyER implements EntityResolver JavaDoc {
85         private static EntityResolver JavaDoc instance = new DummyER();
86
87         public static EntityResolver JavaDoc getInstance() {
88             return instance;
89         }
90
91         public InputSource JavaDoc resolveEntity(String JavaDoc publicID, String JavaDoc systemID) {
92             Logger.getDefault().log("resolving reference: " + publicID + ", " + systemID);
93             return new InputSource JavaDoc(new StringReader JavaDoc(""));
94         }
95     }
96
97     /** Creates new BootReader
98      * @param storage reference to instance of <CODE>MdrStorage</CODE> class
99      * @param docURL URL of XMI document to read (the document should contain metamodel of MOF)
100      */

101     public BootReader(MdrStorage storage, URL JavaDoc docURL) {
102         mdrStorage = storage;
103         this.docURL = docURL;
104     }
105
106     /** Parses the XMI document.
107      * @param docURL URL of the XMI document to be parsed
108      * @throws IOException
109      * @throws SAXException
110      * @throws ParserConfigurationException
111      * @return parsed XMI document
112      */

113     protected Document JavaDoc parse(URL JavaDoc docURL) throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
114         Document JavaDoc result = null;
115         DocumentBuilderFactory JavaDoc bfact = DocumentBuilderFactory.newInstance();
116     bfact.setValidating(false);
117         DocumentBuilder JavaDoc docBuilder = bfact.newDocumentBuilder();
118     docBuilder.setEntityResolver(DummyER.getInstance());
119         InputSource JavaDoc is = new InputSource JavaDoc(docURL.toString());
120         result = docBuilder.parse(is);
121         return result;
122     }
123
124     /** Reads the XMI document that was passed to the costructor
125      * into the MdrStorage which was passed to the constructor.
126      * @return outermost containers in the imported model
127      * @throws IOException
128      * @throws SAXException
129      */

130     public Collection read() throws IOException JavaDoc, SAXException JavaDoc {
131         try {
132             document = parse( docURL );
133             Node JavaDoc xmiContent = document.getElementsByTagName(XmiConstants.XMI_CONTENT).item(0);
134             createProxies(xmiContent);
135             Collection result = createInstances(xmiContent);
136             rebuildMetas();
137             initSuperClasses();
138             return result;
139         } catch (ParserConfigurationException JavaDoc e) {
140             Logger.getDefault().log("Unable to parse document. "+e.getMessage() );
141             return null;
142         }
143     }
144     
145     private void initSuperClasses() {
146         Object JavaDoc sc;
147         Class JavaDoc iface[] = new Class JavaDoc[1];
148         for (Iterator it = proxyById.values().iterator(); it.hasNext();) {
149             sc = it.next();
150             if (sc instanceof StorableClass) {
151                 try {
152                     iface[0] = null;
153                     ((StorableClass) sc).initClassSuperclass(iface);
154                     iface[0] = null;
155                     ((StorableClass) sc).initInstanceSuperclass(iface);
156                 } catch (Exception JavaDoc e) {
157                     throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
158                 }
159             }
160         }
161     }
162
163     /** Goes through the whole XMI document and creates all needed proxies
164      * (for all packages, classes and associations in the document).
165      * @param xmiContent XMI.content node of the XMI document
166      */

167     private void createProxies(Node JavaDoc xmiContent) {
168         NodeList JavaDoc childNodes = xmiContent.getChildNodes();
169
170         for (int i = 0; i < childNodes.getLength(); i++) {
171             Node JavaDoc packageNode = childNodes.item(i);
172             if (XmiUtils.isTextNode(packageNode)) continue;
173             if (XmiUtils.getXmiAttrValueAsString(packageNode, MOFConstants.MODEL_MODEL_ELEMENT_NAME).equals(MOFConstants.MODEL)) {
174                 String JavaDoc logicalMOFName = ""; // NOI18N
175
createProxiesInPackage(null, new MOFID (bootSequenceNumber(logicalMOFName),logicalMOFName), packageNode);
176             }
177         }
178     }
179     
180     /** Goes through the whole XMI document and creates all instances contained in the document.
181      * @param xmiContent XMI.content node of the XMI document
182      * @return outermost containers in the model
183      */

184     private Collection createInstances(Node JavaDoc xmiContent) {
185         XmiUtils.XmiNodeIterator classes = new XmiUtils.XmiNodeIterator(xmiContent);
186         Collection result = createInstances(classes, null, "", null);
187         resolveSuperClasses();
188         resolveReferences();
189         setValues();
190         return result;
191     }
192
193     /** Sets metaobjects for all read objects to reference the correct model element instances.
194      */

195     private void rebuildMetas() {
196         try {
197             StorablePackage sp = mdrStorage.getContextOutermostPackage(NBMDRepositoryImpl.BOOT_MOF);
198             sp.replaceValues(objectsByName);
199
200             StorableClass sc;
201             StorableObject so;
202             StorableAssociation sa;
203             
204             // replace class proxy metas
205
for (Iterator classes = sp.getAllClasses().iterator(); classes.hasNext();) {
206                 sc = (StorableClass) classes.next();
207                 sc.replaceValues(objectsByName);
208                 // replace instance metas
209
for (Iterator instances = sc.allObjects(false).iterator(); instances.hasNext();) {
210                     so = (StorableObject) instances.next();
211                     so.replaceValues(objectsByName);
212                 }
213             }
214
215             for (Iterator associations = sp.getAllAssociations().iterator(); associations.hasNext();) {
216                 sa = (StorableAssociation) associations.next();
217                 sa.replaceValues(objectsByName);
218             }
219             
220             mdrStorage.rebuildMetas(NBMDRepositoryImpl.BOOT_MOF, objectsByName);
221             mdrStorage.setProperty(MdrStorage.MOF_TOP_PACKAGE, sp.getMofId());
222         } catch (Exception JavaDoc e) {
223             throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
224         }
225     }
226     
227     /**
228      * @param immediatePackage
229      * @param fullPackageName
230      * @param packageNode
231      * @return */

232     private StorablePackage createProxiesInPackage(StorablePackage immediatePackage, MOFID fullPackageName, Node JavaDoc packageNode) {
233         // Find all non abstract classes and associations
234
String JavaDoc stringifiedFullPackageName = fullPackageName.getStorageID ();
235         String JavaDoc packagePrefix = stringifiedFullPackageName.length() > 0 ? stringifiedFullPackageName + "." : "";
236         String JavaDoc elementName = XmiUtils.getXmiAttrValueAsString(packageNode, MdrStorage.MODEL_MODEL_ELEMENT_NAME);
237         String JavaDoc logicalMOFName = packagePrefix + elementName;
238         MOFID packageName = new MOFID (bootSequenceNumber(logicalMOFName), logicalMOFName);
239
240         StorablePackage currentPackage = createPackage(immediatePackage, packageName, elementName);
241
242         Node JavaDoc contents = XmiUtils.getChildNode(packageNode, MdrStorage.MODEL_NAMESPACE_CONTENTS);
243         XmiUtils.XmiNodeIterator ni = new XmiUtils.XmiNodeIterator(contents);
244         
245         MOFID name = null;
246         String JavaDoc nodeName = null;
247         List JavaDoc attrDescs = null;
248         List JavaDoc clAttrDescs = null;
249         Node JavaDoc classContents = null;
250         XmiUtils.XmiNodeIterator features = null;
251         String JavaDoc storableXmiId = null;
252         StorableClass sc = null;
253
254         for (; ni.hasNext();) {
255             Node JavaDoc nonAbstract = ni.next();
256             elementName = XmiUtils.getXmiAttrValueAsString(nonAbstract, MdrStorage.MODEL_MODEL_ELEMENT_NAME);
257             logicalMOFName = packageName.getStorageID() + "." + elementName;
258             name = new MOFID (bootSequenceNumber(logicalMOFName), logicalMOFName);
259             nodeName = XmiUtils.resolveFullName(nonAbstract);
260
261             if (nodeName.equals(MdrStorage.MODEL_CLASS)) {
262                 //prepare attribute descriptor for createClass - StorableClass construcor
263
attrDescs = new ArrayList();
264                 clAttrDescs = new ArrayList();
265                 boolean classDerived = false;
266                 boolean instanceDerived = false;
267                 boolean isSingleton = "true".equalsIgnoreCase(XmiUtils.getXmiAttrValueAsString(nonAbstract, MdrStorage.MODEL_CLASS_IS_SINGLETON));
268                 boolean isAbstract = "true".equalsIgnoreCase(XmiUtils.getXmiAttrValueAsString(nonAbstract, MdrStorage.MODEL_GENERALIZABLE_ELEMENT_IS_ABSTRACT));
269
270                 classContents = XmiUtils.getChildNode(nonAbstract, MdrStorage.MODEL_NAMESPACE_CONTENTS);
271                 if (classContents != null) {
272                     features = new XmiUtils.XmiNodeIterator(classContents); //collect all attributes
273

274                     if (features != null) {
275                         Node JavaDoc featureNode = null;
276                         String JavaDoc attName = null;
277                         boolean isDerived = false;
278                         for (; features.hasNext();) {
279                             featureNode = features.next();
280                             if (XmiUtils.resolveFullName(featureNode).equals(MdrStorage.MODEL_ATTRIBUTE)) {
281                                 attName = XmiUtils.getXmiAttrValueAsString(featureNode, MdrStorage.MODEL_MODEL_ELEMENT_NAME);
282                                 isDerived = "true".equalsIgnoreCase(XmiUtils.getXmiAttrValueAsString(featureNode, MdrStorage.MODEL_ATTRIBUTE_IS_DERIVED));
283                                 boolean classifier = MOFConstants.SCOPE_CLASSIFIER.equals(XmiUtils.getXmiAttrValueAsString(featureNode, MOFConstants.MODEL_FEATURE_SCOPE));
284                                 if (!isDerived && attName != null) {
285                                     Node JavaDoc multiplicity = XmiUtils.getChildNode(featureNode, MdrStorage.MODEL_STRUCTURAL_FEATURE_MULTIPLICITY);
286                                     Node JavaDoc fields = XmiUtils.getChildNode(multiplicity, MdrStorage.MODEL_MULTIPLICITY_TYPE);
287                                     int maxSize;
288                                     String JavaDoc upper;
289                                     if (fields == null) {
290                                         // this is for the case when structure fields are represented using xmi.field tags in the XMI
291
XmiUtils.XmiNodeIterator fieldVals = new XmiUtils.XmiNodeIterator(multiplicity, XmiConstants.XMI_FIELD);
292                                         fieldVals.next(); // skip lower
293
upper = fieldVals.next().getFirstChild().getNodeValue();
294                                     } else {
295                                         // this is for the case when structure fields are represented the same way as MOF attributes in the XMI
296
upper = XmiUtils.getXmiAttrValueAsString(fields, MdrStorage.MODEL_MULTIPLICITY_TYPE_UPPER);
297                                     }
298                                     try {
299                                         maxSize = Integer.parseInt(upper);
300                                     } catch (NumberFormatException JavaDoc e) {
301                                         throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
302                                     }
303                                     logicalMOFName = name.getStorageID() + "." + attName;
304                                     StorableClass.AttributeDescriptor desc = new StorableClass.AttributeDescriptor(mdrStorage, new MOFID (bootSequenceNumber(logicalMOFName), logicalMOFName), attName, Object JavaDoc.class, 0, maxSize, false, true, true, null);
305                                     if (classifier) {
306                                         clAttrDescs.add(desc);
307                                     } else {
308                                         attrDescs.add(desc);
309                                     }
310                                 }
311                             } else if (XmiUtils.resolveFullName(featureNode).equals(MdrStorage.MODEL_OPERATION)) {
312                                 isDerived = true;
313                             } else {
314                                 isDerived = false;
315                             }
316                             
317                             if (isDerived) {
318                                 if ("classifier_level".equalsIgnoreCase(XmiUtils.getXmiAttrValueAsString(featureNode, MdrStorage.MODEL_FEATURE_SCOPE))) {
319                                     classDerived = true;
320                                 } else {
321                                     instanceDerived = true;
322                                 }
323                             }
324                         }
325                     }
326                 }
327                 sc = createClass(currentPackage, name, elementName, attrDescs, clAttrDescs, classDerived, instanceDerived, isSingleton, isAbstract);
328                 storableXmiId = XmiUtils.getAttributeValueAsString(nonAbstract, XmiConstants.XMI_ID);
329                 if ((sc != null) && (storableXmiId != null)) {
330                     proxyIdByXmiId.put(storableXmiId, sc.getMofId()); //prepare for later use - CLASSES are enough
331
} else {
332                     Logger.getDefault().log( "Unable to set proxy by XmiId: "+nonAbstract.getNodeName() );
333                 }
334
335             } else if (nodeName.equals(MdrStorage.MODEL_ASSOCIATION)) {
336                 // find the two ends
337
Node JavaDoc asocContents = XmiUtils.getChildNode(nonAbstract, MdrStorage.MODEL_NAMESPACE_CONTENTS);
338                 XmiUtils.XmiNodeIterator asocEnds = new XmiUtils.XmiNodeIterator(asocContents, MdrStorage.MODEL_ASSOCIATION_END);
339                 // the first end
340
Node JavaDoc asocEndA = asocEnds.next ();
341                 String JavaDoc endAName = XmiUtils.getXmiAttrValueAsString(asocEndA, MdrStorage.MODEL_MODEL_ELEMENT_NAME);
342                 // read multiplicity
343
Node JavaDoc multiplicityA = XmiUtils.getChildNode(asocEndA, MdrStorage.MODEL_ASSOCIATION_END_MULTIPLICITY);
344                 Node JavaDoc fieldsA = XmiUtils.getChildNode(multiplicityA, MdrStorage.MODEL_MULTIPLICITY_TYPE);
345                 String JavaDoc lowerA;
346                 String JavaDoc upperA;
347                 String JavaDoc orderedA;
348                 String JavaDoc uniqueA;
349                 if (fieldsA == null) {
350                     // this is for the case when structure fields are represented using xmi.field tags in the XMI
351
XmiUtils.XmiNodeIterator fields = new XmiUtils.XmiNodeIterator(multiplicityA, XmiConstants.XMI_FIELD);
352                     lowerA = fields.next().getFirstChild().getNodeValue();
353                     upperA = fields.next().getFirstChild().getNodeValue();
354                     orderedA = fields.next().getFirstChild().getNodeValue();
355                     uniqueA = fields.next().getFirstChild().getNodeValue();
356                 } else {
357                     // this is for the case when structure fields are represented the same way as MOF attributes in the XMI
358
lowerA = XmiUtils.getXmiAttrValueAsString(fieldsA, MdrStorage.MODEL_MULTIPLICITY_TYPE_LOWER);
359                     upperA = XmiUtils.getXmiAttrValueAsString(fieldsA, MdrStorage.MODEL_MULTIPLICITY_TYPE_UPPER);
360                     orderedA = XmiUtils.getXmiAttrValueAsString(fieldsA, MdrStorage.MODEL_MULTIPLICITY_TYPE_IS_ORDERED);
361                     uniqueA = XmiUtils.getXmiAttrValueAsString(fieldsA, MdrStorage.MODEL_MULTIPLICITY_TYPE_IS_UNIQUE);
362                 }
363                 boolean aggrA = !XmiUtils.getXmiAttrValueAsString(asocEndA, MdrStorage.MODEL_ASSOCIATION_END_AGGREGATION).equals("none");
364
365                 // the second end
366
Node JavaDoc asocEndB = asocEnds.next();
367                 String JavaDoc endBName = XmiUtils.getXmiAttrValueAsString (asocEndB, MdrStorage.MODEL_MODEL_ELEMENT_NAME);
368                 // read multiplicity
369
Node JavaDoc multiplicityB = XmiUtils.getChildNode(asocEndB, MdrStorage.MODEL_ASSOCIATION_END_MULTIPLICITY);
370                 Node JavaDoc fieldsB = XmiUtils.getChildNode(multiplicityB, MdrStorage.MODEL_MULTIPLICITY_TYPE);
371                 String JavaDoc lowerB;
372                 String JavaDoc upperB;
373                 String JavaDoc orderedB;
374                 String JavaDoc uniqueB;
375                 if (fieldsB == null) {
376                     // this is for the case when structure fields are represented using xmi.field tags in the XMI
377
XmiUtils.XmiNodeIterator fields = new XmiUtils.XmiNodeIterator(multiplicityB, XmiConstants.XMI_FIELD);
378                     lowerB = fields.next().getFirstChild().getNodeValue();
379                     upperB = fields.next().getFirstChild().getNodeValue();
380                     orderedB = fields.next().getFirstChild().getNodeValue();
381                     uniqueB = fields.next().getFirstChild().getNodeValue();
382                 } else {
383                     // this is for the case when structure fields are represented the same way as MOF attributes in the XMI
384
lowerB = XmiUtils.getXmiAttrValueAsString(fieldsB, MdrStorage.MODEL_MULTIPLICITY_TYPE_LOWER);
385                     upperB = XmiUtils.getXmiAttrValueAsString(fieldsB, MdrStorage.MODEL_MULTIPLICITY_TYPE_UPPER);
386                     orderedB = XmiUtils.getXmiAttrValueAsString(fieldsB, MdrStorage.MODEL_MULTIPLICITY_TYPE_IS_ORDERED);
387                     uniqueB = XmiUtils.getXmiAttrValueAsString(fieldsB, MdrStorage.MODEL_MULTIPLICITY_TYPE_IS_UNIQUE);
388                 }
389                 boolean aggrB = !XmiUtils.getXmiAttrValueAsString(asocEndB, MdrStorage.MODEL_ASSOCIATION_END_AGGREGATION).equals("none");
390
391                 StorableAssociation storableAssociation;
392                 try {
393                     storableAssociation = createAssociation(currentPackage, name, elementName, endAName, endBName, Integer.parseInt(lowerA), Integer.parseInt(upperA), Integer.parseInt(lowerB), Integer.parseInt(upperB), orderedA.equals("true"), orderedB.equals("true"), uniqueA.equals("true"), uniqueB.equals("true"), aggrA, aggrB);
394                 } catch (NumberFormatException JavaDoc e) {
395                     throw new DebugException("Wrong format of multiplicity");
396                 }
397                 String JavaDoc endALogicalName = name.getStorageID() + "." + endAName;
398                 String JavaDoc endBLogicalName = name.getStorageID() + "." + endBName;
399                 long asn = bootSequenceNumber (endALogicalName);
400                 long bsn = bootSequenceNumber (endBLogicalName);
401                 otherEnds.put(new MOFID (asn, endALogicalName), new MOFID (bsn, endBLogicalName));
402                 otherEnds.put(new MOFID (bsn, endBLogicalName), new MOFID (asn, endALogicalName));
403
404                 if (name.getStorageID().equals(MdrStorage.MODEL_CONTAINS)) {
405                     containsAssociation = storableAssociation;
406                 }
407             } else if (nodeName.equals(MdrStorage.MODEL_PACKAGE)) {
408                 createProxiesInPackage(currentPackage, packageName, nonAbstract);
409             } else if (nodeName.equals(MdrStorage.MODEL_PRIMITIVE_TYPE)) {
410                 if (!name.getStorageID().startsWith(MdrStorage.DATATYPES + ".")) {
411                     String JavaDoc xmiId = XmiUtils.getAttributeValueAsString(nonAbstract, XmiConstants.XMI_ID);
412                     excludeTypes.add(xmiId);
413                 }
414             } else if (nodeName.equals(MdrStorage.MODEL_ALIAS_TYPE)) {
415                 String JavaDoc xmiId = XmiUtils.getAttributeValueAsString(nonAbstract, XmiConstants.XMI_ID);
416                 aliases.put(xmiId, XmiUtils.getXmiRefValue(nonAbstract, MdrStorage.MODEL_TYPED_ELEMENT_TYPE).get(0));
417             }
418         }
419         return currentPackage;
420     }
421     
422 /**
423  * @param items
424  * @param containerMofId
425  * @param namePrefix
426  * @param parent
427  * @return */

428     private Collection createInstances(XmiUtils.XmiNodeIterator items, MOFID containerMofId, String JavaDoc namePrefix, ObjectDescriptor parent) {
429         ArrayList instances = new ArrayList();
430         for (;items.hasNext();) {
431             Node JavaDoc classNode = items.next();
432
433             if (XmiUtils.isTextNode(classNode)) continue;
434
435             // collect data needed for object creation
436
String JavaDoc logicalMOFName = namePrefix + XmiUtils.getXmiAttrValueAsString(classNode, MdrStorage.MODEL_MODEL_ELEMENT_NAME);
437             MOFID name = new MOFID (bootSequenceNumber(logicalMOFName), logicalMOFName);
438             
439             String JavaDoc xmiId = XmiUtils.getAttributeValueAsString(classNode, XmiConstants.XMI_ID);
440             logicalMOFName = XmiUtils.resolveFullName (classNode);
441             MOFID mofClassName = new MOFID (bootSequenceNumber(logicalMOFName), logicalMOFName);
442             MOFID mofPackageName = getPackageName (mofClassName);
443             MOFID classProxy = (MOFID) proxyIdByName.get(mofClassName);
444             MOFID packageProxy = (MOFID) proxyIdByName.get(mofPackageName);
445             String JavaDoc dataType = null;
446
447             if (xmiId != null && excludeTypes.contains(resolveTypeId(xmiId))) continue;
448             
449             if (mofClassName.getStorageID().equals(MdrStorage.MODEL_ATTRIBUTE) || mofClassName.getStorageID().equals(MdrStorage.MODEL_STRUCTURE_FIELD)) {
450                 dataType = resolveTypeId((String JavaDoc) XmiUtils.getXmiRefValue(classNode, MdrStorage.MODEL_TYPED_ELEMENT_TYPE).get(0));
451                 if (excludeTypes.contains(dataType)) continue;
452             }
453             
454             // create new object
455
StorableObject instance = createObject(mofClassName, packageProxy, classProxy);
456             instances.add(instance);
457
458             // register object to helper hashtables
459
objectsByName.put(name, instance.getMofId());
460             ObjectDescriptor od = new ObjectDescriptor(classNode, instance, name);
461             if (odByName.put(name, od) != null) {
462                 Logger.getDefault().log("duplicate for: " + name);
463             }
464             if (xmiId != null) {
465                 odByXmiId.put(xmiId, od);
466             }
467
468             // if the object is contained in other object update contains reference
469
if (containerMofId != null) {
470                 try {
471                     containsAssociation.addLink(containerMofId, instance.getMofId());
472                 } catch (StorageException e) {
473                     throw new DebugException("Storage exception: " + e);
474                 }
475             }
476             
477             // in special cases deeper investigation is needed
478
if (mofClassName.getStorageID().equals(MdrStorage.MODEL_ATTRIBUTE)) {
479                 if (XmiUtils.getXmiAttrValueAsString(classNode, MdrStorage.MODEL_ATTRIBUTE_IS_DERIVED).equals("false")) {
480                     String JavaDoc upper = XmiUtils.getXmiAttrValueAsString(XmiUtils.getChildNode(XmiUtils.getChildNode(classNode, MdrStorage.MODEL_STRUCTURAL_FEATURE_MULTIPLICITY), MdrStorage.MODEL_MULTIPLICITY_TYPE), MdrStorage.MODEL_MULTIPLICITY_TYPE_UPPER);
481                     if (upper == null) {
482                         XmiUtils.XmiNodeIterator fields = new XmiUtils.XmiNodeIterator(XmiUtils.getChildNode(classNode, MdrStorage.MODEL_STRUCTURAL_FEATURE_MULTIPLICITY), XmiConstants.XMI_FIELD);
483                         fields.next();
484                         upper = fields.next().getFirstChild().getNodeValue();
485                     }
486                     parent.addFeature(new Feature(name, Feature.ATTRIBUTE, dataType, null, !upper.equals("1")));
487                 }
488             } else if (mofClassName.getStorageID().equals(MdrStorage.MODEL_STRUCTURE_FIELD)) {
489                 parent.addFeature(new Feature(name, Feature.FIELD, dataType, null, false));
490             } else if (mofClassName.getStorageID().equals(MdrStorage.MODEL_REFERENCE)) {
491                 String JavaDoc referencedEnd = (String JavaDoc) XmiUtils.getXmiRefValue(classNode, MdrStorage.MODEL_REFERENCE_REFERENCED_END).get(0);
492                 parent.addFeature(new Feature(name, Feature.REFERENCE, null, referencedEnd, true));
493 // MOFID proxyId = (MOFID) proxyIdByName.get(parent.getName ());
494
proxyReferences.add(parent); // -- add forward reference - ObjectDescriptor
495
} else if (mofClassName.getStorageID().equals(MdrStorage.MODEL_CLASS)) {
496                 List JavaDoc superTypes = XmiUtils.getXmiRefValue(classNode, MdrStorage.MODEL_GENERALIZABLE_ELEMENT_SUPERTYPES);
497                 for (Iterator st = superTypes.iterator(); st.hasNext();) {
498                     String JavaDoc superTypeXmiId = (String JavaDoc) st.next();
499                     od.addSupertype(superTypeXmiId);
500                     MOFID superProxyId = (MOFID) proxyIdByXmiId.get(superTypeXmiId);
501                     if (superProxyId != null) { //is superTypeXmiId proxyClass
502
superclassByClass.add(new SuperClassDescriptor((MOFID) proxyIdByXmiId.get(xmiId), superProxyId)); //add desciptor
503
} else {
504                         throw new DebugException("Unable to get MofId for proxy woth XmiId : " + superTypeXmiId);
505                     }
506                 }
507             }
508
509             // read components
510
Node JavaDoc classContents = XmiUtils.getChildNode(classNode, MdrStorage.MODEL_NAMESPACE_CONTENTS);
511             if (classContents != null) {
512                 XmiUtils.XmiNodeIterator subnodes = new XmiUtils.XmiNodeIterator(classContents);
513                 createInstances(subnodes, instance.getMofId(), name.getStorageID () + ".", od);
514             }
515         }
516         return instances;
517     }
518
519     private void setValues() {
520         ObjectDescriptor od;
521         for (Iterator it = odByName.values().iterator(); it.hasNext();) {
522             od = (ObjectDescriptor) it.next();
523             readFeatureValues(od, (ObjectDescriptor) odByName.get(od.getStorable().getMetaObjectId()));
524             /*
525             try {
526                 Logger.getDefault().log("- name: " + od.getStorable().getAttribute("name"));
527                 if (od.getStorable().getAttribute("name") == null) {
528                     Logger.getDefault().log("null:" + XmiUtils.getXmiAttrValueAsString(od.getNode(), MOFConstants.MODEL_MODEL_ELEMENT_NAME));
529                 }
530             } catch (Exception e) {
531             }
532              */

533         }
534     }
535     
536 /**
537  * @param object
538  * @param od */

539     private void readFeatureValues(ObjectDescriptor object, ObjectDescriptor od) {
540         Feature feature;
541         for (Iterator it = od.getFeatures().iterator(); it.hasNext();) {
542             feature = (Feature) it.next();
543             try {
544                 switch (feature.getType()) {
545                     case Feature.ATTRIBUTE:
546                         Object JavaDoc attrValue = getXmiAttrValue(object.getNode(), feature);
547                         String JavaDoc featureName = getObjectName (feature.getName());
548                         object.getStorable().setAttribute(featureName, attrValue);
549                         break;
550                     case Feature.REFERENCE:
551                         if (!feature.getName().getStorageID().equals(MdrStorage.MODEL_NAMESPACE_CONTENTS)) {
552                             List JavaDoc value = XmiUtils.getXmiRefValue(object.getNode(), feature.getName().getStorageID());
553                             for (Iterator refs = value.iterator(); refs.hasNext();) {
554 // try {
555
String JavaDoc ref = (String JavaDoc) refs.next();
556                                 object.getStorable().addReference(getObjectName(feature.getName()), ((ObjectDescriptor) odByXmiId.get(ref)).getStorable().getMofId());
557 // } catch (StorageBadRequestException e) {
558
// }
559
}
560                             break;
561                         }
562                 }
563             } catch (StorageException e) {
564                 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
565             }
566         }
567         
568         for (Iterator it = od.getSupertypes().iterator(); it.hasNext();) {
569             readFeatureValues(object, (ObjectDescriptor) odByXmiId.get(it.next()));
570         }
571     }
572     
573 /**
574  * @param node
575  * @param feature
576  * @return */

577     private Object JavaDoc getXmiAttrValue(Node JavaDoc node, Feature feature) {
578         ObjectDescriptor dataType = feature.getDataType();
579         MOFID metaType = dataType.getStorable().getMetaObjectId();
580         Object JavaDoc value = null;
581         
582         if (metaType.getStorageID().equals(MdrStorage.MODEL_STRUCTURE_TYPE)) {
583             Map fields = new HashMap();
584             Feature field;
585             
586             Node JavaDoc attrNode = XmiUtils.getChildNode(node, feature.getName().getStorageID());
587             Node JavaDoc structNode = XmiUtils.getChildNode(attrNode, dataType.getName().getStorageID());
588             
589             if (structNode == null) {
590                 // this is for the case when values for structure fields are stored in xmi.field tags
591
XmiUtils.XmiNodeIterator fieldNodes = new XmiUtils.XmiNodeIterator(attrNode, XmiConstants.XMI_FIELD);
592                 for (Iterator it = dataType.getFeatures().iterator(); it.hasNext();) {
593                     Node JavaDoc fieldNode = fieldNodes.next();
594                     field = (Feature) it.next();
595                     fields.put(getObjectName(field.getName()), decodeStringValue(fieldNode.getFirstChild().getNodeValue(), field.getDataType().getStorable().getMetaObjectId(), field.getDataType()));
596                 }
597             } else {
598                 // this is for the case when values for structure fields are stored in a same way as values for attributes
599
for (Iterator it = dataType.getFeatures().iterator(); it.hasNext();) {
600                     field = (Feature) it.next();
601                     fields.put(getObjectName(field.getName()), getXmiAttrValue(structNode, field));
602                 }
603             }
604             
605             try {
606                 value = StructImpl.newInstance(Class.forName(JMI_PACKAGE_PREFIX + getObjectName(dataType.getName())), new ArrayList(fields.keySet()), fields, parseDots(dataType.getName()));
607             } catch (ClassNotFoundException JavaDoc e) {
608                 throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
609             }
610         } else {
611             if (feature.isMultivalued()) {
612                 List JavaDoc vals = XmiUtils.getXmiMultiValueAsString(node, feature.getName().getStorageID());
613                 List JavaDoc x = new ArrayList(vals.size());
614                 for (Iterator it = vals.iterator(); it.hasNext(); ) {
615                     x.add(decodeStringValue((String JavaDoc)it.next(), metaType, dataType));
616                 }
617                 value = x;
618             } else {
619                 value = decodeStringValue(XmiUtils.getXmiAttrValueAsString(node, feature.getName().getStorageID()), metaType, dataType);
620 // Logger.getDefault().log("multivalued: " + feature.getName() + ", " + value);
621
}
622         }
623         
624         return value;
625     }
626     
627     private Object JavaDoc decodeStringValue(String JavaDoc stringValue, MOFID metaType, ObjectDescriptor dataType) {
628         Object JavaDoc value = null;
629         
630         if (metaType.getStorageID().equals(MdrStorage.MODEL_ENUMERATION_TYPE)) {
631             value = EnumResolver.resolveEnum(JMI_PACKAGE_PREFIX + getObjectName (dataType.getName()), stringValue);
632         } else if (metaType.getStorageID().equals(MdrStorage.MODEL_PRIMITIVE_TYPE)) {
633             String JavaDoc typeName = dataType.getName().getStorageID();
634             if (typeName.equals(MdrStorage.DATATYPES_STRING)) {
635                 value = stringValue;
636             } else if (typeName.equals(MdrStorage.DATATYPES_BOOLEAN)) {
637                 value = Boolean.valueOf(stringValue);
638             } else if (typeName.equals(MdrStorage.DATATYPES_INTEGER)) {
639                 value = new Integer JavaDoc(stringValue);
640             } else if (typeName.equals(MdrStorage.DATATYPES_DOUBLE)) {
641                 value = new Double JavaDoc(stringValue);
642             } else if (typeName.equals(MdrStorage.DATATYPES_FLOAT)) {
643                 value = new Float JavaDoc(stringValue);
644             } else if (typeName.equals(MdrStorage.DATATYPES_LONG)) {
645                 value = new Long JavaDoc(stringValue);
646             } else {
647                 Logger.getDefault().log("unrecognized type: " + typeName);
648             }
649         } else {
650             Logger.getDefault().log("unrecognized metatype: " + metaType);
651         }
652         
653         return value;
654     }
655     
656 /**
657  * @param xmiId
658  * @return */

659     private String JavaDoc resolveTypeId(String JavaDoc xmiId) {
660         String JavaDoc result = xmiId;
661         String JavaDoc temp;
662         
663         while ((temp = (String JavaDoc) aliases.get(result)) != null) {
664             result = temp;
665         }
666         
667         return result;
668     }
669
670 /**
671  * @param immediatePackage
672  * @param metaObjectId
673  * @return */

674     private StorablePackage createPackage(StorablePackage immediatePackage, MOFID metaObjectId, String JavaDoc metaObjectName) {
675         try {
676             StorablePackage sp = new StorablePackage(mdrStorage, immediatePackage == null ? null : immediatePackage.getMofId(), metaObjectId, NBMDRepositoryImpl.BOOT_MOF, new HashMap());
677             MdrStorage storage = mdrStorage;
678             storage.addBootObject(sp.getMofId());
679             proxyIdByName.put(metaObjectId, sp.getMofId());
680             if (immediatePackage != null) {
681                 immediatePackage.addPackage(metaObjectName, sp.getMofId());
682             }
683             return sp;
684         } catch ( StorageException e ) {
685             throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
686         }
687     }
688
689 /**
690  * @param immediatePackage
691  * @param metaMofId
692  * @return */

693     private StorableClass createClass(StorablePackage immediatePackage, MOFID metaMofId,
694         String JavaDoc metaObjectName, List JavaDoc attrDescs, List JavaDoc clAttrDescs, boolean classDerived, boolean instanceDerived,
695         boolean isSingleton, boolean isAbstract) {
696         
697         try {
698             StorableClass sc = new StorableClass(mdrStorage, immediatePackage.getMofId(),
699                 metaMofId, attrDescs, clAttrDescs, new HashMap(), classDerived, instanceDerived,
700                 isSingleton, isAbstract
701             );
702             MdrStorage storage = mdrStorage;
703             storage.addBootClass(sc.getMofId());
704             proxyIdByName.put(metaMofId, sc.getMofId());
705
706             //Inserted 040601 by MaS - Start
707
proxyById.put( sc.getMofId(), sc );
708             //Inserted 040601 by MaS - End
709

710             immediatePackage.addClass(metaObjectName, sc.getMofId());
711             return sc;
712         } catch (StorageException e) {
713             throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
714         }
715     }
716
717 /**
718  * @param immediatePackage
719  * @param metaMofId
720  * @param endA
721  * @param endB
722  * @param minA
723  * @param minB
724  * @param orderedA
725  * @param orderedB
726  * @param uniqueA
727  * @param uniqueB
728  * @param aggrA
729  * @param aggrB
730  * @return */

731     private StorableAssociation createAssociation(StorablePackage immediatePackage,MOFID metaMofId,String JavaDoc metaObjectName, String JavaDoc endA,String JavaDoc endB,int minA, int maxA, int minB, int maxB,boolean orderedA,boolean orderedB,boolean uniqueA,boolean uniqueB,boolean aggrA, boolean aggrB) {
732         try {
733             String JavaDoc endALogicalName = metaMofId.getStorageID () + "." + endA;
734             String JavaDoc endBLogicalName = metaMofId.getStorageID() + "." + endB;
735             
736             StorableAssociation sa = new StorableAssociation(
737                 mdrStorage, immediatePackage.getMofId(), metaMofId, endA, new MOFID (bootSequenceNumber(endALogicalName), endALogicalName),
738                 endB, new MOFID(bootSequenceNumber(endBLogicalName), endBLogicalName), Object JavaDoc.class, Object JavaDoc.class, minA, maxA, minB, maxB,
739                 orderedA, orderedB, uniqueA, uniqueB, aggrA, aggrB, false, false
740             );
741             MdrStorage storage = mdrStorage;
742             storage.addBootAssociation(sa.getMofId());
743             proxyIdByName.put(metaMofId, sa.getMofId());
744
745             //Inserted 040601 by MaS - Start
746
proxyById.put( sa.getMofId(), sa );
747             //Inserted 040601 by MaS - End
748

749
750             immediatePackage.addAssociation(metaObjectName, sa.getMofId());
751             return sa;
752         } catch (StorageException e) {
753             throw new DebugException("Storage exception: " + e);
754         }
755     }
756
757 /**
758  * @param metaObject
759  * @param immediatePackage
760  * @param classProxy
761  * @return */

762     private StorableObject createObject(MOFID metaObject, MOFID immediatePackage, MOFID classProxy) {
763         try {
764             StorableObject so = new StorableObject(mdrStorage, immediatePackage, metaObject, classProxy);
765             MdrStorage storage = mdrStorage;
766             storage.addBootObject(so.getMofId());
767             return so;
768         } catch (StorageException e) {
769             throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
770         }
771     }
772     
773 /**
774  * @param mofid
775  * @return */

776     private List JavaDoc parseDots(MOFID mofid) {
777         List JavaDoc value = new ArrayList();
778         if (!(mofid instanceof MOFID))
779             throw new IllegalArgumentException JavaDoc ();
780         String JavaDoc attr = mofid.getStorageID();
781         int pos;
782         while ((pos = attr.indexOf('.')) > -1) {
783             if (pos > 0) {
784                 value.add(attr.substring(0, pos));
785             }
786             attr = attr.substring(pos + 1);
787         }
788         value.add(attr);
789         return value;
790     }
791
792 //Inserted 040601 by MaS - Start
793
/** Resolves and sets forward references for StorableClass */
794     private void resolveReferences() {
795         ObjectDescriptor od = null;
796         Feature feature = null;
797         Object JavaDoc sc = null;
798         for (Iterator it = proxyReferences.iterator(); it.hasNext(); ) {
799             od = (ObjectDescriptor) it.next();
800             sc = proxyById.get(proxyIdByName.get(od.getName()));
801             if (sc instanceof StorableClass) {
802                 for (Iterator features = od.getFeatures().iterator(); features.hasNext(); ) {
803                     feature = (Feature) features.next();
804                     if (feature.getType() == feature.REFERENCE) {
805                         MOFID endName = (MOFID) otherEnds.get(feature.getAssocEndName());
806 // Logger.getDefault().log("registering reference: " + feature.getName() + " for end: " + endName);
807
((StorableClass)sc).addReferenceDescriptor(feature.getName(), getObjectName(feature.getName()), (MOFID) proxyIdByName.get(feature.getAssocName()), getObjectName(endName));
808                     }
809                 }
810             }
811         }
812     }
813
814 /** Resolves and sets superClasses for StorableClass */
815     private void resolveSuperClasses() {
816         MOFID classId = null;
817         ArrayList superclasses = new ArrayList();
818         ArrayList resolved = new ArrayList();
819         SuperClassDescriptor scd = null;
820         Object JavaDoc sc = null;
821         for (Iterator it = superclassByClass.iterator(); it.hasNext(); ) {
822             superclasses.clear();
823             scd = (SuperClassDescriptor)it.next();
824             classId = scd.getClassId();
825             sc = proxyById.get( classId );
826             if ((!(resolved.contains( classId ))) && (sc instanceof StorableClass) ) {
827                 resolved.add( classId );
828                 superclasses.addAll( getAllSuperClasses( classId ) );
829                 StorableClass storable = (StorableClass) sc;
830                 for (Iterator foundSuperClasses = superclasses.iterator(); foundSuperClasses.hasNext(); ) {
831                     storable.addSuperclass( (MOFID)foundSuperClasses.next() );
832                 }
833             }
834         }
835     }
836
837 /** Returns all super classes - recursion
838  ** @param classId
839  */

840     private List JavaDoc getAllSuperClasses(MOFID classId) {
841         ArrayList result = new ArrayList();
842         MOFID superClassId = null;
843         List JavaDoc superClassIds = new ArrayList();
844         superClassIds.addAll( getSuperClassByClass(classId) );
845         
846         for (Iterator it = superClassIds.iterator(); it.hasNext(); ) {
847             superClassId = (MOFID)it.next();
848             if ( (superClassId != null) && (!result.contains( superClassId ) ) ) {
849                 result.add( superClassId );
850                 result.addAll( getAllSuperClasses( superClassId ) );
851             }
852         }
853         return result;
854     }
855
856 /** Returns super classes for classId form SuperClassDescriptors list
857  ** @param classId
858  */

859     private List JavaDoc getSuperClassByClass(MOFID classId) {
860         ArrayList result = new ArrayList();
861         SuperClassDescriptor scd = null;
862         if (classId != null) {
863             for (Iterator it = superclassByClass.iterator(); it.hasNext(); ) {
864                 scd = (SuperClassDescriptor)it.next();
865                 if (classId.equals( scd.getClassId() ) ) {
866                     result.add( scd.getSuperClassId() );
867                 }
868             }
869         }
870         return result;
871     }
872     
873     
874     private MOFID getPackageName (MOFID bootMOFID) {
875         String JavaDoc storageId = bootMOFID.getStorageID ();
876         String JavaDoc logicalMOFName = storageId.substring(0, storageId.lastIndexOf('.'));
877         return new MOFID (bootSequenceNumber (logicalMOFName), logicalMOFName);
878     }
879         
880     private static String JavaDoc getObjectName (MOFID bootMOFID) {
881         String JavaDoc storageId = bootMOFID.getStorageID();
882         return storageId.substring(storageId.lastIndexOf('.') + 1);
883     }
884     
885     private long bootSequenceNumber (String JavaDoc logicalMOFName) {
886         return logicalMOFName.hashCode ();
887     }
888
889 /** SuperClasDescriptor
890  * used when collecting superclasses for proxies
891  */

892     private class SuperClassDescriptor {
893         private MOFID classId = null;
894         private MOFID superClassId = null;
895         public SuperClassDescriptor(MOFID classId, MOFID superClassId) {
896             this.classId = classId;
897             this.superClassId = superClassId;
898         }
899         public MOFID getClassId() {
900             return classId;
901         }
902         public MOFID getSuperClassId() {
903             return superClassId;
904         }
905     }
906 //Inserted 040601 by MaS - End
907

908     private class ObjectDescriptor {
909         private final Node JavaDoc node;
910         private final StorableObject storable;
911         private final MOFID name;
912         private MOFID parentName;
913         private List JavaDoc features = null;
914         private List JavaDoc supertypes = null;
915         
916         public ObjectDescriptor(Node JavaDoc node, StorableObject storable, MOFID name) {
917             this.node = node;
918             this.storable = storable;
919             this.name = name;
920         }
921         
922 /**
923  * @return */

924         public MOFID getName() {
925             return name;
926         }
927         
928 /**
929  * @return */

930         public MOFID getParentName() {
931             if (parentName == null) {
932                 String JavaDoc sname = name.getStorageID();
933                 String JavaDoc logicalMOFName = sname.substring(0, sname.lastIndexOf('.'));
934                 parentName = new MOFID (bootSequenceNumber(logicalMOFName), logicalMOFName);
935             }
936             return parentName;
937         }
938         
939 /**
940  * @return */

941         public Node JavaDoc getNode() {
942             return node;
943         }
944         
945 /**
946  * @return */

947         public StorableObject getStorable() {
948             return storable;
949         }
950         
951 /**
952  * @return */

953         public List JavaDoc getSupertypes() {
954             if (supertypes == null) {
955                 supertypes = new ArrayList();
956             }
957             
958             return supertypes;
959         }
960         
961 /**
962  * @return */

963         public List JavaDoc getFeatures() {
964             if (features == null) {
965                 features = new ArrayList();
966             }
967             return features;
968         }
969         
970 /**
971  * @param supertypeXmiId */

972         public void addSupertype(String JavaDoc supertypeXmiId) {
973             getSupertypes().add(supertypeXmiId);
974         }
975         
976 /**
977  * @param feature */

978         public void addFeature(Feature feature) {
979             getFeatures().add(feature);
980         }
981     }
982
983     private class Feature {
984         public static final int ATTRIBUTE = 0;
985         public static final int REFERENCE = 1;
986         public static final int FIELD = 2;
987
988         private final MOFID fullName;
989         private final int type;
990         private final String JavaDoc dataTypeXmiId;
991         private final String JavaDoc assocEndXmiId;
992         private final boolean multivalued;
993
994         private ObjectDescriptor dataType = null;
995         private MOFID assocName = null;
996         private MOFID assocEndName = null;
997
998         private void resolveNames() {
999             ObjectDescriptor od = (ObjectDescriptor) odByXmiId.get(assocEndXmiId);
1000            assocEndName = od.getName();
1001            assocName = od.getParentName();
1002        }
1003
1004        public Feature(MOFID fullName, int type, String JavaDoc dataTypeXmiId, String JavaDoc assocEndXmiId, boolean multivalued) {
1005            this.fullName = fullName;
1006            this.type = type;
1007            this.dataTypeXmiId = dataTypeXmiId;
1008            this.assocEndXmiId = assocEndXmiId;
1009            this.multivalued = multivalued;
1010        }
1011
1012/**
1013 * @return */

1014        public MOFID getName() {
1015            return fullName;
1016        }
1017
1018/**
1019 * @return */

1020        
1021        
1022        public MOFID getAssocName() {
1023            if (assocName == null) {
1024                resolveNames();
1025            }
1026            return assocName;
1027        }
1028/*
1029**
1030* @return */

1031        public MOFID getAssocEndName() {
1032            if (assocEndName == null) {
1033                resolveNames();
1034            }
1035            return assocEndName;
1036        }
1037
1038/**
1039 * @return */

1040        public ObjectDescriptor getDataType() {
1041            if (dataType == null) {
1042                dataType = (ObjectDescriptor) odByXmiId.get(dataTypeXmiId);
1043            }
1044            return dataType;
1045        }
1046        
1047/**
1048 * @return */

1049        public boolean isMultivalued() {
1050            return multivalued;
1051        }
1052
1053/**
1054 * @return */

1055        public int getType() {
1056            return type;
1057        }
1058    }
1059
1060}
1061
Popular Tags