You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2009/06/19 11:16:22 UTC

svn commit: r786421 - /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/tree/TreeUtils.java

Author: ebourg
Date: Fri Jun 19 09:16:17 2009
New Revision: 786421

URL: http://svn.apache.org/viewvc?rev=786421&view=rev
Log:
Replaced StringBuffer with StringBuilder

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/tree/TreeUtils.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/tree/TreeUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/tree/TreeUtils.java?rev=786421&r1=786420&r2=786421&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/tree/TreeUtils.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/tree/TreeUtils.java Fri Jun 19 09:16:17 2009
@@ -18,7 +18,6 @@
 package org.apache.commons.configuration2.tree;
 
 import java.io.PrintStream;
-import java.util.Iterator;
 
 /**
  * Utility methods.
@@ -44,34 +43,35 @@
 
     private static void printTree(PrintStream stream, String indent, ConfigurationNode result)
     {
-        StringBuffer buffer = new StringBuffer(indent).append("<").append(result.getName());
-        Iterator iter = result.getAttributes().iterator();
-        while (iter.hasNext())
+        StringBuilder buffer = new StringBuilder(indent).append("<").append(result.getName());
+        for (ConfigurationNode node : result.getAttributes())
         {
-            ConfigurationNode node = (ConfigurationNode) iter.next();
             buffer.append(" ").append(node.getName()).append("='").append(node.getValue()).append("'");
         }
         buffer.append(">");
         stream.print(buffer.toString());
+        
         if (result.getValue() != null)
         {
             stream.print(result.getValue());
         }
+        
         boolean newline = false;
         if (result.getChildrenCount() > 0)
         {
             stream.print("\n");
-            iter = result.getChildren().iterator();
-            while (iter.hasNext())
+            for (ConfigurationNode node : result.getChildren())
             {
-                printTree(stream, indent + "  ", (ConfigurationNode) iter.next());
+                printTree(stream, indent + "  ", node);
             }
             newline = true;
         }
+        
         if (newline)
         {
             stream.print(indent);
         }
+        
         stream.println("</" + result.getName() + ">");
     }
 }