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:10:39 UTC
svn commit: r720042 -
/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
Author: bentmann
Date: Sun Nov 23 13:10:39 2008
New Revision: 720042
URL: http://svn.apache.org/viewvc?rev=720042&view=rev
Log:
[MNG-3544] Beautify debug output for mojo parameters of type array
Modified:
maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
Modified: maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java?rev=720042&r1=720041&r2=720042&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java (original)
+++ maven/components/branches/maven-2.0.x/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java Sun Nov 23 13:10:39 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;
+ }
+
}