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 2009/06/17 19:03:34 UTC

svn commit: r785726 - /maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java

Author: bentmann
Date: Wed Jun 17 17:03:34 2009
New Revision: 785726

URL: http://svn.apache.org/viewvc?rev=785726&view=rev
Log:
o Allowed plugin to dump plugin configuration

Modified:
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java

Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java?rev=785726&r1=785725&r2=785726&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java Wed Jun 17 17:03:34 2009
@@ -27,6 +27,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
@@ -43,6 +44,8 @@
 
     private static final Object[] NO_ARGS = {};
 
+    private static final Class[] NO_PARAMS = {};
+
     /**
      * Serializes the specified object into the given properties, using the provided key. The object may be a scalar
      * value like a string or some array/collection/map or a bean.
@@ -108,7 +111,50 @@
                     store( props, key + "." + index, elem, visited );
                 }
             }
-            else if ( obj != null )
+            else if ( obj.getClass().getName().endsWith( "Xpp3Dom" ) )
+            {
+                Class type = obj.getClass();
+                try
+                {
+                    Method getValue = type.getMethod( "getValue", NO_PARAMS );
+                    String value = (String) getValue.invoke( obj, NO_ARGS );
+
+                    if ( value != null )
+                    {
+                        props.put( key + ".value", value );
+                    }
+
+                    Method getName = type.getMethod( "getName", NO_PARAMS );
+
+                    Method getChildren = type.getMethod( "getChildren", NO_PARAMS );
+                    Object[] children = (Object[]) getChildren.invoke( obj, NO_ARGS );
+
+                    props.put( key + ".children", Integer.toString( children.length ) );
+
+                    Map indices = new HashMap();
+                    for ( int i = 0; i < children.length; i++ )
+                    {
+                        Object child = children[i];
+
+                        String name = (String) getName.invoke( child, NO_ARGS );
+
+                        Integer index = (Integer) indices.get( name );
+                        if ( index == null )
+                        {
+                            index = new Integer( 0 );
+                        }
+
+                        store( props, key + ".children." + name + "." + index, child, visited );
+
+                        indices.put( name, new Integer( index.intValue() + 1 ) );
+                    }
+                }
+                catch ( Exception e )
+                {
+                    // can't happen
+                }
+            }
+            else
             {
                 Class type = obj.getClass();
                 Method[] methods = type.getMethods();