svn commit: r13569 - trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-09-17 18:36:08-0700
New Revision: 13569

Modified:
   trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java

Log:
Use StringBuffer for efficiency

Modified: trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java?view=diff&rev=13569&p1=trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java&p2=trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java&r1=13568&r2=13569
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java	(original)
+++ trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java	2007-09-17 18:36:08-0700
@@ -27,7 +27,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -178,12 +177,7 @@
      */
     public void addPerspective(ExplorerPerspective perspective) {
         perspectives.add(perspective);
-        Iterator listenerIt = perspectiveListeners.iterator();
-        while (listenerIt.hasNext()) {
-
-            PerspectiveManagerListener listener =
-                (PerspectiveManagerListener) listenerIt.next();
-
+        for (PerspectiveManagerListener listener : perspectiveListeners) {
             listener.addPerspective(perspective);
         }
     }
@@ -573,35 +567,19 @@
     @Override
     public String toString() {
 
-        String p = "";
-
-        Iterator perspectivesIt = getPerspectives().iterator();
-        while (perspectivesIt.hasNext()) {
-
-            ExplorerPerspective perspective =
-                (ExplorerPerspective) perspectivesIt.next();
+        StringBuffer p = new StringBuffer();
 
+        for (ExplorerPerspective perspective : getPerspectives()) {
             String name = perspective.toString();
-
-            p += name + ",";
-
-            Object[] rulesArray = perspective.getRulesArray();
-
-            for (int x = 0; x < rulesArray.length; x++) {
-
-                PerspectiveRule rule = (PerspectiveRule) rulesArray[x];
-                p += rule.getClass().getName();
-
-                if (x < rulesArray.length - 1) {
-                    p += ",";
-                }
-            }
-
-            if (perspectivesIt.hasNext()) {
-                p += ";";
+            p.append(name).append(",");
+            for (PerspectiveRule rule : perspective.getList()) {
+                p.append(rule.getClass().getName()).append(",");
             }
+            p.deleteCharAt(p.length() - 1);
+            p.append(";");
         }
-
-        return p;
+        
+        p.deleteCharAt(p.length() - 1);
+        return p.toString();
     }
 }
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.