You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/11/23 22:17:35 UTC

svn commit: r720045 - in /maven/components/trunk: ./ maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java

Author: bentmann
Date: Sun Nov 23 13:17:34 2008
New Revision: 720045

URL: http://svn.apache.org/viewvc?rev=720045&view=rev
Log:
[MNG-3544] Beautify debug output for mojo parameters of type array

o Merged r720042 from maven-2.0.x

Modified:
    maven/components/trunk/   (props changed)
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java

Propchange: maven/components/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 23 13:17:34 2008
@@ -1,3 +1,3 @@
 /maven/components/branches/maven-2.0.10-RC:680477
-/maven/components/branches/maven-2.0.x:679206
+/maven/components/branches/maven-2.0.x:679206,720042
 /maven/components/trunk:688587-696625,696644-699681

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java?rev=720045&r1=720044&r2=720045&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java Sun Nov 23 13:17:34 2008
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.lang.reflect.Array;
+
 import org.codehaus.plexus.component.configurator.ConfigurationListener;
 import org.codehaus.plexus.logging.Logger;
 
@@ -42,7 +44,7 @@
     {
         if ( logger.isDebugEnabled() )
         {
-            logger.debug( "  (s) " + fieldName + " = " + value );
+            logger.debug( "  (s) " + fieldName + " = " + toString( value ) );
         }
     }
 
@@ -50,7 +52,40 @@
     {
         if ( logger.isDebugEnabled() )
         {
-            logger.debug( "  (f) " + fieldName + " = " + value );
+            logger.debug( "  (f) " + fieldName + " = " + toString( value ) );
         }
     }
+
+    /**
+     * Creates a human-friendly string represenation of the specified object.
+     * 
+     * @param obj The object to create a string representation for, may be <code>null</code>.
+     * @return The string representation, never <code>null</code>.
+     */
+    private String toString( Object obj )
+    {
+        String str;
+        if ( obj != null && obj.getClass().isArray() )
+        {
+            int n = Array.getLength( obj );
+            StringBuffer buf = new StringBuffer( 256 );
+            buf.append( '[' );
+            for ( int i = 0; i < n; i++ )
+            {
+                if ( i > 0 )
+                {
+                    buf.append( ", " );
+                }
+                buf.append( String.valueOf( Array.get( obj, i ) ) );
+            }
+            buf.append( ']' );
+            str = buf.toString();
+        }
+        else
+        {
+            str = String.valueOf( obj );
+        }
+        return str;
+    }
+
 }