Lines 1-11
Link Here
|
1 |
/* |
1 |
/* |
2 |
* Sun Public License Notice |
2 |
* Sun Public License Notice |
3 |
* |
3 |
* |
4 |
* The contents of this file are subject to the Sun Public License |
4 |
* The contents of this file are subject to the Sun Public License |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
6 |
* compliance with the License. A copy of the License is available at |
6 |
* compliance with the License. A copy of the License is available at |
7 |
* http://www.sun.com/ |
7 |
* http://www.sun.com/ |
8 |
* |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
Lines 31-51
Link Here
|
31 |
protected NamespaceImpl(StorableObject storable) { |
31 |
protected NamespaceImpl(StorableObject storable) { |
32 |
super(storable); |
32 |
super(storable); |
33 |
} |
33 |
} |
34 |
|
34 |
|
35 |
private static final HashMap contains = new HashMap(); |
35 |
private static final HashMap contains = new HashMap(); |
36 |
|
36 |
|
37 |
private static StorableAssociation resolveContains(StorableFeatured storable) throws StorageException { |
37 |
private static StorableAssociation resolveContains(StorableFeatured storable) throws StorageException { |
38 |
StorableAssociation result = (StorableAssociation) contains.get(storable.getOutermostPackageId()); |
38 |
StorableAssociation result = (StorableAssociation) contains.get(storable.getOutermostPackageId()); |
39 |
|
39 |
|
40 |
if (result == null) { |
40 |
if (result == null) { |
41 |
result = storable.getClassProxy().getReferenceDescriptor(MOFConstants.SH_MODEL_MODEL_ELEMENT_CONTAINER).getAssociation(); |
41 |
result = storable.getClassProxy().getReferenceDescriptor(MOFConstants.SH_MODEL_MODEL_ELEMENT_CONTAINER).getAssociation(); |
42 |
contains.put(storable.getOutermostPackageId(), result); |
42 |
contains.put(storable.getOutermostPackageId(), result); |
43 |
} |
43 |
} |
44 |
|
44 |
|
45 |
return result; |
45 |
return result; |
46 |
} |
46 |
} |
47 |
|
47 |
|
48 |
protected Collection extendedNamespace() { |
48 |
protected Collection/*<StorableFeatured>*/ extendedNamespace() { |
49 |
/* if ((result = (Collection) namespaces.get(self.refMofId())) != null) { |
49 |
/* if ((result = (Collection) namespaces.get(self.refMofId())) != null) { |
50 |
return result; |
50 |
return result; |
51 |
} |
51 |
} |
Lines 86-100
Link Here
|
86 |
throw new DebugException(); |
86 |
throw new DebugException(); |
87 |
} |
87 |
} |
88 |
} |
88 |
} |
89 |
|
89 |
|
|
|
90 |
protected ModelElement lookupElementExtendedImpl(String name) { |
91 |
Collection contents = extendedNamespace(); |
92 |
StorableBaseObject storable = _getDelegate(); |
93 |
Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name); |
94 |
|
95 |
if (items != null) { |
96 |
Object result; |
97 |
for (Iterator it = items.iterator(); it.hasNext();) { |
98 |
result = it.next(); |
99 |
if (contents.contains(result)) { |
100 |
return (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) result); |
101 |
} |
102 |
} |
103 |
} else { |
104 |
for (Iterator it = contents.iterator(); it.hasNext();) { |
105 |
ModelElement el = (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) it.next()); |
106 |
if (el.getName().equals(name)) { |
107 |
return el; |
108 |
} |
109 |
} |
110 |
} |
111 |
|
112 |
return null; |
113 |
} |
114 |
|
115 |
|
90 |
// --- operations |
116 |
// --- operations |
91 |
|
117 |
|
92 |
public ModelElement lookupElement(String name) throws NameNotFoundException { |
118 |
public ModelElement lookupElement(String name) throws NameNotFoundException { |
93 |
StorableFeatured storable = (StorableFeatured) _getDelegate(); |
119 |
StorableFeatured storable = (StorableFeatured) _getDelegate(); |
94 |
Collection contents; |
120 |
Collection contents; |
95 |
|
121 |
|
96 |
Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name); |
122 |
Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name); |
97 |
|
123 |
|
98 |
if (items != null) { |
124 |
if (items != null) { |
99 |
try { |
125 |
try { |
100 |
StorableAssociation assoc = resolveContains(storable); |
126 |
StorableAssociation assoc = resolveContains(storable); |
Lines 129-135
Link Here
|
129 |
if (qualifiedName.size() < 1) { |
155 |
if (qualifiedName.size() < 1) { |
130 |
throw new DebugException("No qualified name provided."); |
156 |
throw new DebugException("No qualified name provided."); |
131 |
} |
157 |
} |
132 |
|
158 |
|
133 |
ModelElement element; |
159 |
ModelElement element; |
134 |
Iterator qnIterator = qualifiedName.iterator(); |
160 |
Iterator qnIterator = qualifiedName.iterator(); |
135 |
String name = (String) qnIterator.next(); |
161 |
String name = (String) qnIterator.next(); |
Lines 157-174
Link Here
|
157 |
} |
183 |
} |
158 |
|
184 |
|
159 |
public boolean nameIsValid(String proposedName) { |
185 |
public boolean nameIsValid(String proposedName) { |
160 |
Collection extNamespace = extendedNamespace(); |
186 |
return lookupElementExtendedImpl(proposedName) == null; |
161 |
ModelElement element; |
187 |
} |
162 |
|
|
|
163 |
for (Iterator it = extNamespace.iterator(); it.hasNext();) { |
164 |
element = (ModelElement) it.next(); |
165 |
if (element.getName().equals(proposedName)) { |
166 |
return false; |
167 |
} |
168 |
} |
169 |
|
170 |
return true; |
171 |
} |
172 |
|
188 |
|
173 |
public List findElementsByType(javax.jmi.model.MofClass ofType, boolean includeSubtypes ) { |
189 |
public List findElementsByType(javax.jmi.model.MofClass ofType, boolean includeSubtypes ) { |
174 |
ArrayList result = new ArrayList(); |
190 |
ArrayList result = new ArrayList(); |