svn commit: r16176 - trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-11-25 21:02:06-0800
New Revision: 16176

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java

Log:
Wrong version committed.  Here's the functionality equivalent (but incorrect) version from the refactoring

Modified: trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java?view=diff&rev=16176&p1=trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java&p2=trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java&r1=16175&r2=16176
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java	2008-11-25 21:02:06-0800
@@ -317,7 +317,10 @@
         Object root = Model.getFacade().getModel(obj);
         Object stereo;
 
-        stereo = findStereotype(obj, null, name);
+        stereo = findStereotypeContained(obj, root, name);
+        // TODO: The following rather than the above is probably the correct
+        // way to search
+//        stereo = findStereotype(obj, null, name);
         if (stereo != null) {
             return stereo;
         }
@@ -340,7 +343,8 @@
     }
 
     /**
-     * Search for a stereotype with the name given in name.
+     * Search for a stereotype with the name given in a namespace and its
+     * containing namespaces.
      * 
      * @param obj The model element to be suitable for.
      * @param namespace The namespace to start search at. If null, the namespace
@@ -354,16 +358,22 @@
         Object ns = namespace;
         if (ns == null) {
             ns = Model.getFacade().getNamespace(obj);
+            if (ns == null) {
+                return null;
+            }
         }
+
         
         Collection ownedElements = 
             Model.getFacade().getOwnedElements(ns);
         for (Object element : ownedElements) {
-            if (Model.getFacade().isAStereotype(element) &&
-                    name.equals(Model.getFacade().getName(element))) {
+            if (Model.getFacade().isAStereotype(element)
+                    && name.equals(Model.getFacade().getName(element))) {
                 return element;
             }
         }
+        
+        // If not found, try the parent namespace
         ns = Model.getFacade().getNamespace(ns);
         if (namespace != null) {
             return findStereotype(obj, ns, name);
@@ -407,16 +417,9 @@
 
         Collection ownedElements = Model.getFacade().getOwnedElements(root);
 
-        if (ownedElements == null) {
-            return null;
-        }
-
         // Loop through each element in the namespace, recursing.
-
-        Iterator iter = ownedElements.iterator();
-
-        while (iter.hasNext()) {
-            stereo = findStereotypeContained(obj, iter.next(), name);
+        for (Object ownedElement : ownedElements) {
+            stereo = findStereotypeContained(obj, ownedElement, name);
             if (stereo != null) {
                 return stereo;
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.