Index: src/javax/jmi/model/impl/GeneralizableElementImpl.java =================================================================== RCS file: /cvs/mdr/src/javax/jmi/model/impl/GeneralizableElementImpl.java,v retrieving revision 1.3 diff -u -r1.3 GeneralizableElementImpl.java --- src/javax/jmi/model/impl/GeneralizableElementImpl.java 12 Jun 2002 14:18:11 -0000 1.3 +++ src/javax/jmi/model/impl/GeneralizableElementImpl.java 26 Jun 2002 06:44:40 -0000 @@ -1,11 +1,11 @@ /* * Sun Public License Notice - * + * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ - * + * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. @@ -26,7 +26,7 @@ * @author mmatula */ public abstract class GeneralizableElementImpl extends NamespaceImpl implements GeneralizableElement { - + protected GeneralizableElementImpl(StorableObject storable) { super(storable); } @@ -43,7 +43,7 @@ result.add(element); } } - + return result; } @@ -65,28 +65,10 @@ } public ModelElement lookupElementExtended(String name) throws NameNotFoundException { - Collection contents = extendedNamespace(); - StorableBaseObject storable = _getDelegate(); - Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name); - - if (items != null) { - Object result; - for (Iterator it = items.iterator(); it.hasNext();) { - result = it.next(); - if (contents.contains(result)) { - return (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) result); - } - } - } else { - for (Iterator it = contents.iterator(); it.hasNext();) { - ModelElement el = (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) it.next()); - if (el.getName().equals(name)) { - return el; - } - } - } - - throw new NameNotFoundException(name); + ModelElement result = lookupElementExtendedImpl(name); + if (result == null) + throw new NameNotFoundException(name); + return result; } public List findElementsByTypeExtended(javax.jmi.model.MofClass ofType, boolean includeSubtypes ) { @@ -95,7 +77,7 @@ Collection contents = extendedNamespace(); for (Iterator it = contents.iterator(); it.hasNext();) { - element = (RefObject) it.next(); + element = (RefObject) BaseObjectHandler.getHandler((StorableObject) it.next()); if (element.refIsInstanceOf(ofType, includeSubtypes)) { result.add(element); } Index: src/javax/jmi/model/impl/NamespaceImpl.java =================================================================== RCS file: /cvs/mdr/src/javax/jmi/model/impl/NamespaceImpl.java,v retrieving revision 1.4 diff -u -r1.4 NamespaceImpl.java --- src/javax/jmi/model/impl/NamespaceImpl.java 17 Jun 2002 16:18:24 -0000 1.4 +++ src/javax/jmi/model/impl/NamespaceImpl.java 26 Jun 2002 06:44:40 -0000 @@ -1,11 +1,11 @@ /* * Sun Public License Notice - * + * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ - * + * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. @@ -31,21 +31,21 @@ protected NamespaceImpl(StorableObject storable) { super(storable); } - + private static final HashMap contains = new HashMap(); private static StorableAssociation resolveContains(StorableFeatured storable) throws StorageException { StorableAssociation result = (StorableAssociation) contains.get(storable.getOutermostPackageId()); - + if (result == null) { result = storable.getClassProxy().getReferenceDescriptor(MOFConstants.SH_MODEL_MODEL_ELEMENT_CONTAINER).getAssociation(); contains.put(storable.getOutermostPackageId(), result); } - + return result; } - protected Collection extendedNamespace() { + protected Collection/**/ extendedNamespace() { /* if ((result = (Collection) namespaces.get(self.refMofId())) != null) { return result; } @@ -86,15 +86,41 @@ throw new DebugException(); } } - + + protected ModelElement lookupElementExtendedImpl(String name) { + Collection contents = extendedNamespace(); + StorableBaseObject storable = _getDelegate(); + Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name); + + if (items != null) { + Object result; + for (Iterator it = items.iterator(); it.hasNext();) { + result = it.next(); + if (contents.contains(result)) { + return (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) result); + } + } + } else { + for (Iterator it = contents.iterator(); it.hasNext();) { + ModelElement el = (ModelElement) BaseObjectHandler.getHandler((StorableBaseObject) it.next()); + if (el.getName().equals(name)) { + return el; + } + } + } + + return null; + } + + // --- operations public ModelElement lookupElement(String name) throws NameNotFoundException { StorableFeatured storable = (StorableFeatured) _getDelegate(); Collection contents; - + Collection items = storable.getMdrStorage().getObjectsFromAdditionalIndex(storable.getOutermostPackageId(), "ModelElement.name", name); - + if (items != null) { try { StorableAssociation assoc = resolveContains(storable); @@ -129,7 +155,7 @@ if (qualifiedName.size() < 1) { throw new DebugException("No qualified name provided."); } - + ModelElement element; Iterator qnIterator = qualifiedName.iterator(); String name = (String) qnIterator.next(); @@ -157,18 +183,8 @@ } public boolean nameIsValid(String proposedName) { - Collection extNamespace = extendedNamespace(); - ModelElement element; - - for (Iterator it = extNamespace.iterator(); it.hasNext();) { - element = (ModelElement) it.next(); - if (element.getName().equals(proposedName)) { - return false; - } - } - - return true; - } + return lookupElementExtendedImpl(proposedName) == null; + } public List findElementsByType(javax.jmi.model.MofClass ofType, boolean includeSubtypes ) { ArrayList result = new ArrayList();