This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 25166
Collapse All | Expand All

(-)src/javax/jmi/model/impl/GeneralizableElementImpl.java (-27 / +9 lines)
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 26-32 Link Here
26
 * @author mmatula
26
 * @author mmatula
27
 */
27
 */
28
public abstract class GeneralizableElementImpl extends NamespaceImpl implements GeneralizableElement {
28
public abstract class GeneralizableElementImpl extends NamespaceImpl implements GeneralizableElement {
29
    
29
30
    protected GeneralizableElementImpl(StorableObject storable) {
30
    protected GeneralizableElementImpl(StorableObject storable) {
31
        super(storable);
31
        super(storable);
32
    }
32
    }
Lines 43-49 Link Here
43
                result.add(element);
43
                result.add(element);
44
            }
44
            }
45
        }
45
        }
46
        
46
47
        return result;
47
        return result;
48
    }
48
    }
49
49
Lines 65-92 Link Here
65
    }
65
    }
66
66
67
    public ModelElement lookupElementExtended(String name) throws NameNotFoundException {
67
    public ModelElement lookupElementExtended(String name) throws NameNotFoundException {
68
        Collection contents = extendedNamespace();
68
        ModelElement result = lookupElementExtendedImpl(name);
69
        StorableBaseObject storable = _getDelegate();
69
        if (result == null)
70
        Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name);
70
            throw new NameNotFoundException(name);
71
        
71
        return result;
72
        if (items != null) {
73
            Object result;
74
            for (Iterator it = items.iterator(); it.hasNext();) {
75
                result = it.next();
76
                if (contents.contains(result)) {
77
                    return (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) result);
78
                }
79
            }
80
        } else {
81
            for (Iterator it = contents.iterator(); it.hasNext();) {
82
                ModelElement el = (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) it.next());
83
                if (el.getName().equals(name)) {
84
                    return el;
85
                }
86
            }
87
        }
88
89
        throw new NameNotFoundException(name);
90
    }
72
    }
91
73
92
    public List findElementsByTypeExtended(javax.jmi.model.MofClass ofType, boolean includeSubtypes ) {
74
    public List findElementsByTypeExtended(javax.jmi.model.MofClass ofType, boolean includeSubtypes ) {
Lines 95-101 Link Here
95
        Collection contents = extendedNamespace();
77
        Collection contents = extendedNamespace();
96
78
97
        for (Iterator it = contents.iterator(); it.hasNext();) {
79
        for (Iterator it = contents.iterator(); it.hasNext();) {
98
            element = (RefObject) it.next();
80
            element = (RefObject) BaseObjectHandler.getHandler((StorableObject) it.next());
99
            if (element.refIsInstanceOf(ofType, includeSubtypes)) {
81
            if (element.refIsInstanceOf(ofType, includeSubtypes)) {
100
                result.add(element);
82
                result.add(element);
101
            }
83
            }
(-)src/javax/jmi/model/impl/NamespaceImpl.java (-22 / +38 lines)
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();

Return to bug 25166