You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/04/20 21:32:10 UTC

svn commit: r1588831 [5/11] - in /commons/proper/configuration/trunk: ./ src/main/java/org/apache/commons/configuration/ src/main/java/org/apache/commons/configuration/beanutils/ src/main/java/org/apache/commons/configuration/builder/combined/ src/main...

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/XMLBeanDeclaration.java Sun Apr 20 19:32:08 2014
@@ -19,17 +19,16 @@ package org.apache.commons.configuration
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
+import org.apache.commons.configuration.BaseHierarchicalConfiguration;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.SubnodeConfiguration;
 import org.apache.commons.configuration.ex.ConfigurationRuntimeException;
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
-import org.apache.commons.configuration.tree.ConfigurationNode;
-import org.apache.commons.configuration.tree.DefaultConfigurationNode;
+import org.apache.commons.configuration.tree.NodeHandler;
 
 /**
  * <p>
@@ -112,9 +111,6 @@ import org.apache.commons.configuration.
  * </p>
  *
  * @since 1.3
- * @author <a
- * href="http://commons.apache.org/configuration/team-list.html">Commons
- * Configuration team</a>
  * @version $Id$
  */
 public class XMLBeanDeclaration implements BeanDeclaration
@@ -154,10 +150,10 @@ public class XMLBeanDeclaration implemen
     private static final String ATTR_CTOR_TYPE = RESERVED_PREFIX + "type";
 
     /** Stores the associated configuration. */
-    private final SubnodeConfiguration configuration;
+    private final HierarchicalConfiguration<?> configuration;
 
     /** Stores the configuration node that contains the bean declaration. */
-    private final ConfigurationNode node;
+    private final NodeData<?> node;
 
     /** The name of the default bean class. */
     private final String defaultBeanClassName;
@@ -174,7 +170,7 @@ public class XMLBeanDeclaration implemen
      * @throws IllegalArgumentException if required information is missing to
      *         construct the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key)
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String key)
     {
         this(config, key, false);
     }
@@ -191,7 +187,7 @@ public class XMLBeanDeclaration implemen
      * @throws IllegalArgumentException if required information is missing to
      *         construct the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key,
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String key,
             boolean optional)
     {
         this(config, key, optional, null);
@@ -220,7 +216,7 @@ public class XMLBeanDeclaration implemen
      *         construct the bean declaration
      * @since 2.0
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config, String key,
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config, String key,
             boolean optional, String defBeanClsName)
     {
         if (config == null)
@@ -229,24 +225,21 @@ public class XMLBeanDeclaration implemen
                     "Configuration must not be null!");
         }
 
-        SubnodeConfiguration tmpconfiguration = null;
-        ConfigurationNode tmpnode = null;
+        HierarchicalConfiguration<?> tmpconfiguration;
         try
         {
             tmpconfiguration = config.configurationAt(key);
-            tmpnode = tmpconfiguration.getRootNode();
         }
-        catch (IllegalArgumentException iex)
+        catch (ConfigurationRuntimeException iex)
         {
             // If we reach this block, the key does not have exactly one value
             if (!optional || config.getMaxIndex(key) > 0)
             {
                 throw iex;
             }
-            tmpconfiguration = config.configurationAt(null);
-            tmpnode = new DefaultConfigurationNode();
+            tmpconfiguration = new BaseHierarchicalConfiguration();
         }
-        this.node = tmpnode;
+        this.node = createNodeDataFromConfiguration(tmpconfiguration);
         this.configuration = tmpconfiguration;
         defaultBeanClassName = defBeanClsName;
         initSubnodeConfiguration(getConfiguration());
@@ -259,7 +252,7 @@ public class XMLBeanDeclaration implemen
      *
      * @param config the configuration with the bean declaration
      */
-    public XMLBeanDeclaration(HierarchicalConfiguration config)
+    public <T> XMLBeanDeclaration(HierarchicalConfiguration<T> config)
     {
         this(config, (String) null);
     }
@@ -267,24 +260,14 @@ public class XMLBeanDeclaration implemen
     /**
      * Creates a new instance of {@code XMLBeanDeclaration} and
      * initializes it with the configuration node that contains the bean
-     * declaration.
+     * declaration. This constructor is used internally.
      *
      * @param config the configuration
      * @param node the node with the bean declaration.
      */
-    public XMLBeanDeclaration(SubnodeConfiguration config,
-            ConfigurationNode node)
+    XMLBeanDeclaration(HierarchicalConfiguration<?> config,
+            NodeData<?> node)
     {
-        if (config == null)
-        {
-            throw new IllegalArgumentException(
-                    "Configuration must not be null!");
-        }
-        if (node == null)
-        {
-            throw new IllegalArgumentException("Node must not be null!");
-        }
-
         this.node = node;
         configuration = config;
         defaultBeanClassName = null;
@@ -296,7 +279,7 @@ public class XMLBeanDeclaration implemen
      *
      * @return the associated configuration
      */
-    public SubnodeConfiguration getConfiguration()
+    public HierarchicalConfiguration<?> getConfiguration()
     {
         return configuration;
     }
@@ -315,16 +298,6 @@ public class XMLBeanDeclaration implemen
     }
 
     /**
-     * Returns the node that contains the bean declaration.
-     *
-     * @return the configuration node this bean declaration is based on
-     */
-    public ConfigurationNode getNode()
-    {
-        return node;
-    }
-
-    /**
      * Returns the name of the bean factory. This information is fetched from
      * the {@code config-factory} attribute.
      *
@@ -333,7 +306,7 @@ public class XMLBeanDeclaration implemen
     @Override
     public String getBeanFactoryName()
     {
-        return getConfiguration().getString(ATTR_BEAN_FACTORY);
+        return getConfiguration().getString(ATTR_BEAN_FACTORY, null);
     }
 
     /**
@@ -370,11 +343,11 @@ public class XMLBeanDeclaration implemen
     public Map<String, Object> getBeanProperties()
     {
         Map<String, Object> props = new HashMap<String, Object>();
-        for (ConfigurationNode attr : getNode().getAttributes())
+        for (String key : getAttributeNames())
         {
-            if (!isReservedNode(attr))
+            if (!isReservedAttributeName(key))
             {
-                props.put(attr.getName(), interpolate(attr .getValue()));
+                props.put(key, interpolate(getNode().getAttribute(key)));
             }
         }
 
@@ -392,13 +365,13 @@ public class XMLBeanDeclaration implemen
     public Map<String, Object> getNestedBeanDeclarations()
     {
         Map<String, Object> nested = new HashMap<String, Object>();
-        for (ConfigurationNode child : getNode().getChildren())
+        for (NodeData<?> child : getNode().getChildren())
         {
-            if (!isReservedNode(child))
+            if (!isReservedChildName(child.nodeName()))
             {
-                if (nested.containsKey(child.getName()))
+                if (nested.containsKey(child.nodeName()))
                 {
-                    Object obj = nested.get(child.getName());
+                    Object obj = nested.get(child.nodeName());
                     List<BeanDeclaration> list;
                     if (obj instanceof List)
                     {
@@ -411,13 +384,13 @@ public class XMLBeanDeclaration implemen
                     {
                         list = new ArrayList<BeanDeclaration>();
                         list.add((BeanDeclaration) obj);
-                        nested.put(child.getName(), list);
+                        nested.put(child.nodeName(), list);
                     }
                     list.add(createBeanDeclaration(child));
                 }
                 else
                 {
-                    nested.put(child.getName(), createBeanDeclaration(child));
+                    nested.put(child.nodeName(), createBeanDeclaration(child));
                 }
             }
         }
@@ -436,7 +409,7 @@ public class XMLBeanDeclaration implemen
     public Collection<ConstructorArg> getConstructorArgs()
     {
         Collection<ConstructorArg> args = new LinkedList<ConstructorArg>();
-        for (ConfigurationNode child : getNode().getChildren(ELEM_CTOR_ARG))
+        for (NodeData<?> child : getNode().getChildren(ELEM_CTOR_ARG))
         {
             args.add(createConstructorArg(child));
         }
@@ -455,23 +428,75 @@ public class XMLBeanDeclaration implemen
     protected Object interpolate(Object value)
     {
         ConfigurationInterpolator interpolator =
-                getConfiguration().getParent().getInterpolator();
+                getConfiguration().getInterpolator();
         return (interpolator != null) ? interpolator.interpolate(value) : value;
     }
 
     /**
-     * Checks if the specified node is reserved and thus should be ignored. This
-     * method is called when the maps for the bean's properties and complex
-     * properties are collected. It checks whether the name of the given node
-     * starts with the reserved prefix.
-     *
-     * @param nd the node to be checked
-     * @return a flag whether this node is reserved (and does not point to a
-     *         property)
+     * Checks if the specified child node name is reserved and thus should be
+     * ignored. This method is called when processing child nodes of this bean
+     * declaration. It is then possible to ignore some nodes with a specific
+     * meaning. This implementation delegates to {@link #isReservedName(String)}
+     * .
+     *
+     * @param name the name of the child node to be checked
+     * @return a flag whether this name is reserved
+     * @since 2.0
      */
-    protected boolean isReservedNode(ConfigurationNode nd)
+    protected boolean isReservedChildName(String name)
     {
-        return nd.getName() == null || nd.getName().startsWith(RESERVED_PREFIX);
+        return isReservedName(name);
+    }
+
+    /**
+     * Checks if the specified attribute name is reserved and thus does not
+     * point to a property of the bean to be created. This method is called when
+     * processing the attributes of this bean declaration. It is then possible
+     * to ignore some attributes with a specific meaning. This implementation
+     * delegates to {@link #isReservedName(String)}.
+     *
+     * @param name the name of the attribute to be checked
+     * @return a flag whether this name is reserved
+     * @since 2.0
+     */
+    protected boolean isReservedAttributeName(String name)
+    {
+        return isReservedName(name);
+    }
+
+    /**
+     * Checks if the specified name of a node or attribute is reserved and thus
+     * should be ignored. This method is called per default by the methods for
+     * checking attribute and child node names. It checks whether the passed in
+     * name starts with the reserved prefix.
+     *
+     * @param name the name to be checked
+     * @return a flag whether this name is reserved
+     */
+    protected boolean isReservedName(String name)
+    {
+        return name == null || name.startsWith(RESERVED_PREFIX);
+    }
+
+    /**
+     * Returns a set with the names of the attributes of the configuration node
+     * holding the data of this bean declaration.
+     *
+     * @return the attribute names of the underlying configuration node
+     */
+    protected Set<String> getAttributeNames()
+    {
+        return getNode().getAttributes();
+    }
+
+    /**
+     * Returns the data about the associated node.
+     *
+     * @return the node with the bean declaration
+     */
+    NodeData<?> getNode()
+    {
+        return node;
     }
 
     /**
@@ -486,39 +511,29 @@ public class XMLBeanDeclaration implemen
      * @param node the child node, for which a {@code BeanDeclaration} is
      *        to be created
      * @return the {@code BeanDeclaration} for this child node
-     * @since 1.6
      */
-    protected BeanDeclaration createBeanDeclaration(ConfigurationNode node)
+    BeanDeclaration createBeanDeclaration(NodeData<?> node)
     {
-        List<SubnodeConfiguration> list = getConfiguration().configurationsAt(node.getName());
-        if (list.size() == 1)
+        for (HierarchicalConfiguration<?> config : getConfiguration()
+                .configurationsAt(node.nodeName()))
         {
-            return new XMLBeanDeclaration(list.get(0), node);
-        }
-        else
-        {
-            Iterator<SubnodeConfiguration> iter = list.iterator();
-            while (iter.hasNext())
+            if (node.matchesConfigRootNode(config))
             {
-                SubnodeConfiguration config = iter.next();
-                if (config.getRootNode().equals(node))
-                {
-                    return new XMLBeanDeclaration(config, node);
-                }
+                return new XMLBeanDeclaration(config, node);
             }
-            throw new ConfigurationRuntimeException("Unable to match node for " + node.getName());
         }
+        throw new ConfigurationRuntimeException("Unable to match node for "
+                + node.nodeName());
     }
 
     /**
-     * Initializes the internally managed subnode configuration. This method
+     * Initializes the internally managed sub configuration. This method
      * will set some default values for some properties.
      *
      * @param conf the configuration to initialize
      */
-    private void initSubnodeConfiguration(SubnodeConfiguration conf)
+    private void initSubnodeConfiguration(HierarchicalConfiguration<?> conf)
     {
-        conf.setThrowExceptionOnMissing(false);
         conf.setExpressionEngine(null);
     }
 
@@ -529,7 +544,7 @@ public class XMLBeanDeclaration implemen
      * @param child the configuration node
      * @return the corresponding {@code ConstructorArg} object
      */
-    private ConstructorArg createConstructorArg(ConfigurationNode child)
+    private ConstructorArg createConstructorArg(NodeData<?> child)
     {
         String type = getAttribute(child, ATTR_CTOR_TYPE);
         if (isBeanDeclarationArgument(child))
@@ -546,16 +561,16 @@ public class XMLBeanDeclaration implemen
 
     /**
      * Helper method for obtaining an attribute of a configuration node.
+     * This method also takes interpolation into account.
      *
      * @param nd the node
      * @param attr the name of the attribute
      * @return the string value of this attribute (can be <b>null</b>)
      */
-    private String getAttribute(ConfigurationNode nd, String attr)
+    private String getAttribute(NodeData<?> nd, String attr)
     {
-        List<ConfigurationNode> attributes = nd.getAttributes(attr);
-        return attributes.isEmpty() ? null : String
-                .valueOf(interpolate(attributes.get(0).getValue()));
+        Object value = nd.getAttribute(attr);
+        return (value == null) ? null : String.valueOf(interpolate(value));
     }
 
     /**
@@ -565,8 +580,134 @@ public class XMLBeanDeclaration implemen
      * @param nd the configuration node in question
      * @return a flag whether this constructor argument is a bean declaration
      */
-    private static boolean isBeanDeclarationArgument(ConfigurationNode nd)
+    private static boolean isBeanDeclarationArgument(NodeData<?> nd)
+    {
+        return !nd.getAttributes().contains(ATTR_BEAN_CLASS_NAME);
+    }
+
+    /**
+     * Creates a {@code NodeData} object from the root node of the given
+     * configuration.
+     *
+     * @param config the configuration
+     * @param <T> the type of the nodes
+     * @return the {@code NodeData} object
+     */
+    private static <T> NodeData<T> createNodeDataFromConfiguration(
+            HierarchicalConfiguration<T> config)
     {
-        return nd.getAttributes(ATTR_BEAN_CLASS_NAME).isEmpty();
+        NodeHandler<T> handler = config.getNodeModel().getNodeHandler();
+        return new NodeData<T>(handler.getRootNode(), handler);
+    }
+
+    /**
+     * An internally used helper class which wraps the node with the bean
+     * declaration and the corresponding node handler.
+     *
+     * @param <T> the type of the node
+     */
+    static class NodeData<T>
+    {
+        /** The wrapped node. */
+        private final T node;
+
+        /** The node handler for interacting with this node. */
+        private final NodeHandler<T> handler;
+
+        /**
+         * Creates a new instance of {@code NodeData}.
+         *
+         * @param nd the node
+         * @param hndlr the handler
+         */
+        public NodeData(T nd, NodeHandler<T> hndlr)
+        {
+            node = nd;
+            handler = hndlr;
+        }
+
+        /**
+         * Returns the name of the wrapped node.
+         *
+         * @return the node name
+         */
+        public String nodeName()
+        {
+            return handler.nodeName(node);
+        }
+
+        /**
+         * Returns a list with the children of the wrapped node, again wrapped
+         * into {@code NodeData} objects.
+         *
+         * @return a list with the children
+         */
+        public List<NodeData<T>> getChildren()
+        {
+            return wrapInNodeData(handler.getChildren(node));
+        }
+
+        /**
+         * Returns a list with the children of the wrapped node with the given
+         * name, again wrapped into {@code NodeData} objects.
+         *
+         * @param name the name of the desired child nodes
+         * @return a list with the children with this name
+         */
+        public List<NodeData<T>> getChildren(String name)
+        {
+            return wrapInNodeData(handler.getChildren(node, name));
+        }
+
+        /**
+         * Returns a set with the names of the attributes of the wrapped node.
+         *
+         * @return the attribute names of this node
+         */
+        public Set<String> getAttributes()
+        {
+            return handler.getAttributes(node);
+        }
+
+        /**
+         * Returns the value of the attribute with the given name of the wrapped
+         * node.
+         *
+         * @param key the key of the attribute
+         * @return the value of this attribute
+         */
+        public Object getAttribute(String key)
+        {
+            return handler.getAttributeValue(node, key);
+        }
+
+        /**
+         * Returns a flag whether the wrapped node is the root node of the
+         * passed in configuration.
+         *
+         * @param config the configuration
+         * @return a flag whether this node is the configuration's root node
+         */
+        public boolean matchesConfigRootNode(HierarchicalConfiguration<?> config)
+        {
+            return config.getNodeModel().getNodeHandler().getRootNode()
+                    .equals(node);
+        }
+
+        /**
+         * Wraps the passed in list of nodes in {@code NodeData} objects.
+         *
+         * @param nodes the list with nodes
+         * @return the wrapped nodes
+         */
+        private List<NodeData<T>> wrapInNodeData(List<T> nodes)
+        {
+            List<NodeData<T>> result = new ArrayList<NodeData<T>>(nodes.size());
+            for (T node : nodes)
+            {
+                result.add(new NodeData<T>(node, handler));
+            }
+            return result;
+        }
     }
 }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderParametersImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderParametersImpl.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderParametersImpl.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderParametersImpl.java Sun Apr 20 19:32:08 2014
@@ -58,7 +58,7 @@ public class CombinedBuilderParametersIm
             + CombinedBuilderParametersImpl.class.getName();
 
     /** The definition configuration builder. */
-    private ConfigurationBuilder<? extends HierarchicalConfiguration> definitionBuilder;
+    private ConfigurationBuilder<? extends HierarchicalConfiguration<?>> definitionBuilder;
 
     /** A parameters object for the definition configuration builder. */
     private BuilderParameters definitionBuilderParameters;
@@ -86,7 +86,7 @@ public class CombinedBuilderParametersIm
 
     /**
      * Looks up an instance of this class in the specified parameters map. This
-     * is equivalent to {@code fromParameters(params, false};}
+     * is equivalent to {@code fromParameters(params, false);}
      *
      * @param params the map with parameters (must not be <b>null</b>
      * @return the instance obtained from the map or <b>null</b>
@@ -129,7 +129,7 @@ public class CombinedBuilderParametersIm
      *
      * @return the definition {@code ConfigurationBuilder}
      */
-    public ConfigurationBuilder<? extends HierarchicalConfiguration> getDefinitionBuilder()
+    public ConfigurationBuilder<? extends HierarchicalConfiguration<?>> getDefinitionBuilder()
     {
         return definitionBuilder;
     }
@@ -144,7 +144,7 @@ public class CombinedBuilderParametersIm
      */
     @Override
     public CombinedBuilderParametersImpl setDefinitionBuilder(
-            ConfigurationBuilder<? extends HierarchicalConfiguration> builder)
+            ConfigurationBuilder<? extends HierarchicalConfiguration<?>> builder)
     {
         definitionBuilder = builder;
         return this;

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderProperties.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderProperties.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedBuilderProperties.java Sun Apr 20 19:32:08 2014
@@ -48,7 +48,7 @@ public interface CombinedBuilderProperti
      * @return a reference to this object for method chaining
      */
     T setDefinitionBuilder(
-            ConfigurationBuilder<? extends HierarchicalConfiguration> builder);
+            ConfigurationBuilder<? extends HierarchicalConfiguration<?>> builder);
 
     /**
      * Registers the given {@code ConfigurationBuilderProvider} for the

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedConfigurationBuilder.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedConfigurationBuilder.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/CombinedConfigurationBuilder.java Sun Apr 20 19:32:08 2014
@@ -31,7 +31,6 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationLookup;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.configuration.SubnodeConfiguration;
 import org.apache.commons.configuration.SystemConfiguration;
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.commons.configuration.beanutils.BeanDeclaration;
@@ -490,10 +489,10 @@ public class CombinedConfigurationBuilde
     private static final Map<String, ConfigurationBuilderProvider> DEFAULT_PROVIDERS_MAP;
 
     /** The builder for the definition configuration. */
-    private ConfigurationBuilder<? extends HierarchicalConfiguration> definitionBuilder;
+    private ConfigurationBuilder<? extends HierarchicalConfiguration<?>> definitionBuilder;
 
     /** Stores temporarily the configuration with the builder definitions. */
-    private HierarchicalConfiguration definitionConfiguration;
+    private HierarchicalConfiguration<?> definitionConfiguration;
 
     /** The object with data about configuration sources. */
     private ConfigurationSourceData sourceData;
@@ -552,7 +551,7 @@ public class CombinedConfigurationBuilde
      * @return the builder for the definition configuration
      * @throws ConfigurationException if an error occurs
      */
-    public synchronized ConfigurationBuilder<? extends HierarchicalConfiguration> getDefinitionBuilder()
+    public synchronized ConfigurationBuilder<? extends HierarchicalConfiguration<?>> getDefinitionBuilder()
             throws ConfigurationException
     {
         if (definitionBuilder == null)
@@ -665,14 +664,14 @@ public class CombinedConfigurationBuilde
      * @return the builder for the definition configuration
      * @throws ConfigurationException if an error occurs
      */
-    protected ConfigurationBuilder<? extends HierarchicalConfiguration> setupDefinitionBuilder(
+    protected ConfigurationBuilder<? extends HierarchicalConfiguration<?>> setupDefinitionBuilder(
             Map<String, Object> params) throws ConfigurationException
     {
         CombinedBuilderParametersImpl cbParams =
                 CombinedBuilderParametersImpl.fromParameters(params);
         if (cbParams != null)
         {
-            ConfigurationBuilder<? extends HierarchicalConfiguration> defBuilder =
+            ConfigurationBuilder<? extends HierarchicalConfiguration<?>> defBuilder =
                     cbParams.getDefinitionBuilder();
             if (defBuilder != null)
             {
@@ -708,7 +707,7 @@ public class CombinedConfigurationBuilde
      * @param builderParams the parameters object for the builder
      * @return the standard builder for the definition configuration
      */
-    protected ConfigurationBuilder<? extends HierarchicalConfiguration> createXMLDefinitionBuilder(
+    protected ConfigurationBuilder<? extends HierarchicalConfiguration<?>> createXMLDefinitionBuilder(
             BuilderParameters builderParams)
     {
         return new FileBasedConfigurationBuilder<XMLConfiguration>(
@@ -728,7 +727,7 @@ public class CombinedConfigurationBuilde
      * @return the definition configuration
      * @throws ConfigurationException if an error occurs
      */
-    protected HierarchicalConfiguration getDefinitionConfiguration()
+    protected HierarchicalConfiguration<?> getDefinitionConfiguration()
             throws ConfigurationException
     {
         if (definitionConfiguration == null)
@@ -785,7 +784,7 @@ public class CombinedConfigurationBuilde
         super.initResultInstance(result);
 
         currentConfiguration = result;
-        HierarchicalConfiguration config = getDefinitionConfiguration();
+        HierarchicalConfiguration<?> config = getDefinitionConfiguration();
         if (config.getMaxIndex(KEY_COMBINER) < 0)
         {
             // No combiner defined => set default
@@ -850,13 +849,14 @@ public class CombinedConfigurationBuilde
      * @throws ConfigurationException if an error occurs
      */
     protected void registerConfiguredLookups(
-            HierarchicalConfiguration defConfig, Configuration resultConfig)
+            HierarchicalConfiguration<?> defConfig, Configuration resultConfig)
             throws ConfigurationException
     {
         Map<String, Lookup> lookups = new HashMap<String, Lookup>();
-        List<SubnodeConfiguration> nodes =
+
+        List<? extends HierarchicalConfiguration<?>> nodes =
                 defConfig.configurationsAt(KEY_CONFIGURATION_LOOKUPS);
-        for (SubnodeConfiguration config : nodes)
+        for (HierarchicalConfiguration<?> config : nodes)
         {
             XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
             String key = config.getString(KEY_LOOKUP_KEY);
@@ -885,7 +885,7 @@ public class CombinedConfigurationBuilde
      * @return the default {@code FileSystem} (may be <b>null</b>)
      * @throws ConfigurationException if an error occurs
      */
-    protected FileSystem initFileSystem(HierarchicalConfiguration config)
+    protected FileSystem initFileSystem(HierarchicalConfiguration<?> config)
             throws ConfigurationException
     {
         if (config.getMaxIndex(FILE_SYSTEM) == 0)
@@ -907,7 +907,7 @@ public class CombinedConfigurationBuilde
      *        <b>null</b>)
      * @throws ConfigurationException if an error occurs.
      */
-    protected void initSystemProperties(HierarchicalConfiguration config,
+    protected void initSystemProperties(HierarchicalConfiguration<?> config,
             String basePath) throws ConfigurationException
     {
         String fileName = config.getString(KEY_SYSTEM_PROPS);
@@ -934,7 +934,7 @@ public class CombinedConfigurationBuilde
      *        parameters; here the new resolver is to be stored
      * @throws ConfigurationException if an error occurs
      */
-    protected void configureEntityResolver(HierarchicalConfiguration config,
+    protected void configureEntityResolver(HierarchicalConfiguration<?> config,
             XMLBuilderParametersImpl xmlParams) throws ConfigurationException
     {
         if (config.getMaxIndex(KEY_ENTITY_RESOLVER) == 0)
@@ -1048,7 +1048,6 @@ public class CombinedConfigurationBuilde
     void initBean(Object bean, BeanDeclaration decl)
     {
         fetchBeanHelper().initBean(bean, decl);
-        ;
     }
 
     /**
@@ -1116,7 +1115,7 @@ public class CombinedConfigurationBuilde
         }
         else
         {
-            ConfigurationBuilder<? extends HierarchicalConfiguration> defBuilder =
+            ConfigurationBuilder<? extends HierarchicalConfiguration<?>> defBuilder =
                     getDefinitionBuilder();
             if (defBuilder instanceof FileBasedConfigurationBuilder)
             {
@@ -1260,12 +1259,12 @@ public class CombinedConfigurationBuilde
      * @param defConfig the definition configuration
      * @throws ConfigurationException if an error occurs
      */
-    private void registerConfiguredProviders(HierarchicalConfiguration defConfig)
+    private void registerConfiguredProviders(HierarchicalConfiguration<?> defConfig)
             throws ConfigurationException
     {
-        List<SubnodeConfiguration> nodes =
+        List<? extends HierarchicalConfiguration<?>> nodes =
                 defConfig.configurationsAt(KEY_CONFIGURATION_PROVIDERS);
-        for (SubnodeConfiguration config : nodes)
+        for (HierarchicalConfiguration<?> config : nodes)
         {
             XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
             String key = config.getString(KEY_PROVIDER_KEY);
@@ -1283,7 +1282,7 @@ public class CombinedConfigurationBuilde
      * @param defBuilder the definition builder
      */
     private void addDefinitionBuilderChangeListener(
-            final ConfigurationBuilder<? extends HierarchicalConfiguration> defBuilder)
+            final ConfigurationBuilder<? extends HierarchicalConfiguration<?>> defBuilder)
     {
         defBuilder.addBuilderListener(new BuilderListener()
         {
@@ -1324,7 +1323,7 @@ public class CombinedConfigurationBuilde
      * @param key the key for the list nodes
      */
     private static void initNodeCombinerListNodes(CombinedConfiguration cc,
-            HierarchicalConfiguration defConfig, String key)
+            HierarchicalConfiguration<?> defConfig, String key)
     {
         List<Object> listNodes = defConfig.getList(key);
         for (Object listNode : listNodes)
@@ -1361,10 +1360,10 @@ public class CombinedConfigurationBuilde
     private class ConfigurationSourceData
     {
         /** A list with all builders for override configurations. */
-        private final Collection<SubnodeConfiguration> overrideBuilders;
+        private final Collection<HierarchicalConfiguration<?>> overrideBuilders;
 
         /** A list with all builders for union configurations. */
-        private final Collection<SubnodeConfiguration> unionBuilders;
+        private final Collection<HierarchicalConfiguration<?>> unionBuilders;
 
         /** A map for direct access to a builder by its name. */
         private final Map<String, ConfigurationBuilder<? extends Configuration>> namedBuilders;
@@ -1381,9 +1380,9 @@ public class CombinedConfigurationBuilde
         public ConfigurationSourceData()
         {
             overrideBuilders =
-                    new LinkedList<SubnodeConfiguration>();
+                    new LinkedList<HierarchicalConfiguration<?>>();
             unionBuilders =
-                    new LinkedList<SubnodeConfiguration>();
+                    new LinkedList<HierarchicalConfiguration<?>>();
             namedBuilders =
                     new HashMap<String, ConfigurationBuilder<? extends Configuration>>();
             allBuilders =
@@ -1397,7 +1396,7 @@ public class CombinedConfigurationBuilde
          * @throws ConfigurationException if an error occurs
          */
         public void initFromDefinitionConfiguration(
-                HierarchicalConfiguration config) throws ConfigurationException
+                HierarchicalConfiguration<?> config) throws ConfigurationException
         {
             overrideBuilders.addAll(fetchTopLevelOverrideConfigs(config));
             overrideBuilders.addAll(config.childConfigurationsAt(KEY_OVERRIDE));
@@ -1415,11 +1414,11 @@ public class CombinedConfigurationBuilde
          * @throws ConfigurationException if an error occurs
          */
         public void createAndAddConfigurations(CombinedConfiguration ccResult,
-                Collection<SubnodeConfiguration> srcDecl)
+                Collection<HierarchicalConfiguration<?>> srcDecl)
                 throws ConfigurationException
         {
             createBuilderChangeListener();
-            for (HierarchicalConfiguration src : srcDecl)
+            for (HierarchicalConfiguration<?> src : srcDecl)
             {
                 ConfigurationDeclaration decl =
                         new ConfigurationDeclaration(
@@ -1460,7 +1459,7 @@ public class CombinedConfigurationBuilde
          *
          * @return the override configuration builders
          */
-        public Collection<SubnodeConfiguration> getOverrideSources()
+        public Collection<HierarchicalConfiguration<?>> getOverrideSources()
         {
             return overrideBuilders;
         }
@@ -1471,7 +1470,7 @@ public class CombinedConfigurationBuilde
          *
          * @return the union configuration builders
          */
-        public Collection<SubnodeConfiguration> getUnionSources()
+        public Collection<HierarchicalConfiguration<?>> getUnionSources()
         {
             return unionBuilders;
         }
@@ -1510,7 +1509,7 @@ public class CombinedConfigurationBuilde
          * @throws ConfigurationException if an error occurs
          */
         private ConfigurationBuilder<? extends Configuration> createConfigurationBuilder(
-                HierarchicalConfiguration src, ConfigurationDeclaration decl)
+                HierarchicalConfiguration<?> src, ConfigurationDeclaration decl)
                 throws ConfigurationException
         {
             ConfigurationBuilderProvider provider =
@@ -1591,16 +1590,18 @@ public class CombinedConfigurationBuilde
          * @return a list with sub configurations for the top level override
          *         configurations
          */
-        private List<SubnodeConfiguration> fetchTopLevelOverrideConfigs(
-                HierarchicalConfiguration config)
+        private List<? extends HierarchicalConfiguration<?>> fetchTopLevelOverrideConfigs(
+                HierarchicalConfiguration<?> config)
         {
-            List<SubnodeConfiguration> configs =
+
+            List<? extends HierarchicalConfiguration<?>> configs =
                     config.childConfigurationsAt(null);
-            for (Iterator<SubnodeConfiguration> it = configs.iterator(); it
-                    .hasNext();)
+            for (Iterator<? extends HierarchicalConfiguration<?>> it =
+                    configs.iterator(); it.hasNext();)
             {
                 String nodeName = it.next().getRootElementName();
-                for (String element : CONFIG_SECTIONS) {
+                for (String element : CONFIG_SECTIONS)
+                {
                     if (element.equals(nodeName))
                     {
                         it.remove();

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ConfigurationDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ConfigurationDeclaration.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ConfigurationDeclaration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ConfigurationDeclaration.java Sun Apr 20 19:32:08 2014
@@ -16,9 +16,10 @@
  */
 package org.apache.commons.configuration.builder.combined;
 
+import java.util.Set;
+
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.configuration.beanutils.XMLBeanDeclaration;
-import org.apache.commons.configuration.tree.ConfigurationNode;
 
 /**
  * <p>
@@ -50,7 +51,7 @@ public class ConfigurationDeclaration ex
      * @param config the configuration this declaration is based onto
      */
     public ConfigurationDeclaration(CombinedConfigurationBuilder builder,
-            HierarchicalConfiguration config)
+            HierarchicalConfiguration<?> config)
     {
         super(config);
         configurationBuilder = builder;
@@ -168,43 +169,28 @@ public class ConfigurationDeclaration ex
     }
 
     /**
-     * Checks whether the given node is reserved. This method will take further
-     * reserved attributes into account
-     *
-     * @param nd the node
-     * @return a flag whether this node is reserved
+     * {@inheritDoc} This implementation checks for additional reserved
+     * attribute names. Note that in some cases the presence of other attribute
+     * names determine whether a name is reserved or not. For instance, per
+     * default the attribute {@code config-at} is reserved. However, if this
+     * attribute is not present, the attribute {@code at} is also considered as
+     * a reserved attribute. (This is mainly done for dealing with legacy
+     * configuration files supported by earlier versions of this library.)
      */
     @Override
-    protected boolean isReservedNode(ConfigurationNode nd)
+    protected boolean isReservedAttributeName(String name)
     {
-        if (super.isReservedNode(nd))
+        if (super.isReservedAttributeName(name))
         {
             return true;
         }
 
-        return nd.isAttribute()
-                && ((CombinedConfigurationBuilder.ATTR_ATNAME.equals(nd
-                        .getName()) && nd.getParentNode().getAttributeCount(
-                        RESERVED_PREFIX
-                                + CombinedConfigurationBuilder.ATTR_ATNAME) == 0) || (CombinedConfigurationBuilder.ATTR_OPTIONALNAME
-                        .equals(nd.getName()) && nd
-                        .getParentNode()
-                        .getAttributeCount(
-                                RESERVED_PREFIX
-                                        + CombinedConfigurationBuilder.ATTR_OPTIONALNAME) == 0));
-    }
-
-//    /**
-//     * Performs interpolation. This implementation will delegate interpolation
-//     * to the configuration builder, which takes care that the currently
-//     * constructed configuration is taken into account, too.
-//     *
-//     * @param value the value to be interpolated
-//     * @return the interpolated value
-//     */
-//    @Override
-//    protected Object interpolate(Object value)
-//    {
-//        return getConfigurationBuilder().interpolate(value);
-//    }
+        Set<String> attributes = getAttributeNames();
+        return (CombinedConfigurationBuilder.ATTR_ATNAME.equals(name) && !attributes
+                .contains(RESERVED_PREFIX
+                        + CombinedConfigurationBuilder.ATTR_ATNAME))
+                || (CombinedConfigurationBuilder.ATTR_OPTIONALNAME.equals(name) && !attributes
+                        .contains(RESERVED_PREFIX
+                                + CombinedConfigurationBuilder.ATTR_OPTIONALNAME));
+    }
 }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ReloadingCombinedConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ReloadingCombinedConfigurationBuilder.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ReloadingCombinedConfigurationBuilder.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/combined/ReloadingCombinedConfigurationBuilder.java Sun Apr 20 19:32:08 2014
@@ -117,7 +117,7 @@ public class ReloadingCombinedConfigurat
      * configurations with reloading support.
      */
     @Override
-    protected ConfigurationBuilder<? extends HierarchicalConfiguration> createXMLDefinitionBuilder(
+    protected ConfigurationBuilder<? extends HierarchicalConfiguration<?>> createXMLDefinitionBuilder(
             BuilderParameters builderParams)
     {
         return new ReloadingFileBasedConfigurationBuilder<XMLConfiguration>(
@@ -152,7 +152,7 @@ public class ReloadingCombinedConfigurat
     {
         Collection<ReloadingController> subControllers =
                 new LinkedList<ReloadingController>();
-        ConfigurationBuilder<? extends HierarchicalConfiguration> defBuilder =
+        ConfigurationBuilder<? extends HierarchicalConfiguration<?>> defBuilder =
                 getDefinitionBuilder();
         obtainReloadingController(subControllers, defBuilder);
 

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/AbstractListDelimiterHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/AbstractListDelimiterHandler.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/AbstractListDelimiterHandler.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/AbstractListDelimiterHandler.java Sun Apr 20 19:32:08 2014
@@ -58,10 +58,9 @@ public abstract class AbstractListDelimi
      * primitive objects.</li>
      * </ul>
      */
-    @Override
-    public Iterator<?> parse(Object value)
+    public Iterable<?> parse(Object value)
     {
-        return flatten(value).iterator();
+        return flatten(value);
     }
 
     /**
@@ -69,7 +68,6 @@ public abstract class AbstractListDelimi
      * string is <b>null</b>. In this case, an empty collection is returned.
      * Otherwise, this method delegates to {@link #splitString(String, boolean)}.
      */
-    @Override
     public Collection<String> split(String s, boolean trim)
     {
         if (s == null)
@@ -85,7 +83,6 @@ public abstract class AbstractListDelimi
      * otherwise no escaping is performed. Eventually, the passed in transformer
      * is invoked so that additional encoding can be performed.
      */
-    @Override
     public Object escape(Object value, ValueTransformer transformer)
     {
         Object escValue =

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/ListDelimiterHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/ListDelimiterHandler.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/ListDelimiterHandler.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/convert/ListDelimiterHandler.java Sun Apr 20 19:32:08 2014
@@ -17,7 +17,6 @@
 package org.apache.commons.configuration.convert;
 
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -74,13 +73,13 @@ public interface ListDelimiterHandler
      * Parses the specified value for list delimiters and splits it if
      * necessary. The passed in object can be either a single value or a complex
      * one, e.g. a collection, an array, or an {@code Iterable}. It is the
-     * responsibility of this method to return an {@code Iterator} which
+     * responsibility of this method to return an {@code Iterable} which
      * contains all extracted values.
      *
      * @param value the value to be parsed
-     * @return an {@code Iterator} allowing access to all extracted values
+     * @return an {@code Iterable} allowing access to all extracted values
      */
-    Iterator<?> parse(Object value);
+    Iterable<?> parse(Object value);
 
     /**
      * Splits the specified string at the list delimiter and returns a

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/PropertyListConfiguration.java Sun Apr 20 19:32:08 2014
@@ -36,8 +36,9 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.configuration.MapConfiguration;
 import org.apache.commons.configuration.ex.ConfigurationException;
-import org.apache.commons.configuration.tree.ConfigurationNode;
-import org.apache.commons.configuration.tree.DefaultConfigurationNode;
+import org.apache.commons.configuration.tree.ImmutableNode;
+import org.apache.commons.configuration.tree.InMemoryNodeModel;
+import org.apache.commons.configuration.tree.NodeHandler;
 import org.apache.commons.lang3.StringUtils;
 
 /**
@@ -146,11 +147,22 @@ public class PropertyListConfiguration e
      * @param c the configuration to copy
      * @since 1.4
      */
-    public PropertyListConfiguration(HierarchicalConfiguration c)
+    public PropertyListConfiguration(HierarchicalConfiguration<ImmutableNode> c)
     {
         super(c);
     }
 
+    /**
+     * Creates a new instance of {@code PropertyListConfiguration} with the
+     * given root node.
+     *
+     * @param root the root node
+     */
+    PropertyListConfiguration(ImmutableNode root)
+    {
+        super(new InMemoryNodeModel(root));
+    }
+
     @Override
     protected void setPropertyInternal(String key, Object value)
     {
@@ -193,7 +205,7 @@ public class PropertyListConfiguration e
         PropertyListParser parser = new PropertyListParser(in);
         try
         {
-            HierarchicalConfiguration config = parser.parse();
+            PropertyListConfiguration config = parser.parse();
             setRootNode(config.getRootNode());
         }
         catch (ParseException e)
@@ -206,23 +218,25 @@ public class PropertyListConfiguration e
     public void write(Writer out) throws ConfigurationException
     {
         PrintWriter writer = new PrintWriter(out);
-        printNode(writer, 0, getRootNode());
+        NodeHandler<ImmutableNode> handler = getModel().getNodeHandler();
+        printNode(writer, 0, handler.getRootNode(), handler);
         writer.flush();
     }
 
     /**
      * Append a node to the writer, indented according to a specific level.
      */
-    private void printNode(PrintWriter out, int indentLevel, ConfigurationNode node)
+    private void printNode(PrintWriter out, int indentLevel,
+            ImmutableNode node, NodeHandler<ImmutableNode> handler)
     {
         String padding = StringUtils.repeat(" ", indentLevel * INDENT_SIZE);
 
-        if (node.getName() != null)
+        if (node.getNodeName() != null)
         {
-            out.print(padding + quoteString(node.getName()) + " = ");
+            out.print(padding + quoteString(node.getNodeName()) + " = ");
         }
 
-        List<ConfigurationNode> children = new ArrayList<ConfigurationNode>(node.getChildren());
+        List<ImmutableNode> children = new ArrayList<ImmutableNode>(node.getChildren());
         if (!children.isEmpty())
         {
             // skip a line, except for the root dictionary
@@ -234,12 +248,12 @@ public class PropertyListConfiguration e
             out.println(padding + "{");
 
             // display the children
-            Iterator<ConfigurationNode> it = children.iterator();
+            Iterator<ImmutableNode> it = children.iterator();
             while (it.hasNext())
             {
-                ConfigurationNode child = it.next();
+                ImmutableNode child = it.next();
 
-                printNode(out, indentLevel + 1, child);
+                printNode(out, indentLevel + 1, child, handler);
 
                 // add a semi colon for elements that are not dictionaries
                 Object value = child.getValue();
@@ -258,7 +272,7 @@ public class PropertyListConfiguration e
             out.print(padding + "}");
 
             // line feed if the dictionary is not in an array
-            if (node.getParentNode() != null)
+            if (handler.getParent(node) != null)
             {
                 out.println();
             }
@@ -269,7 +283,7 @@ public class PropertyListConfiguration e
             out.print(padding + "{ };");
 
             // line feed if the dictionary is not in an array
-            if (node.getParentNode() != null)
+            if (handler.getParent(node) != null)
             {
                 out.println();
             }
@@ -303,9 +317,12 @@ public class PropertyListConfiguration e
             }
             out.print(" )");
         }
-        else if (value instanceof HierarchicalConfiguration)
+        else if (value instanceof PropertyListConfiguration)
         {
-            printNode(out, indentLevel, ((HierarchicalConfiguration) value).getRootNode());
+            NodeHandler<ImmutableNode> handler =
+                    ((PropertyListConfiguration) value).getModel()
+                            .getNodeHandler();
+            printNode(out, indentLevel, handler.getRootNode(), handler);
         }
         else if (value instanceof Configuration)
         {
@@ -318,10 +335,11 @@ public class PropertyListConfiguration e
             while (it.hasNext())
             {
                 String key = it.next();
-                ConfigurationNode node = new DefaultConfigurationNode(key);
-                node.setValue(config.getProperty(key));
-
-                printNode(out, indentLevel + 1, node);
+                ImmutableNode node =
+                        new ImmutableNode.Builder().name(key)
+                                .value(config.getProperty(key)).create();
+                InMemoryNodeModel tempModel = new InMemoryNodeModel(node);
+                printNode(out, indentLevel + 1, node, tempModel.getNodeHandler());
                 out.println(";");
             }
             out.println(padding + "}");

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/plist/XMLPropertyListConfiguration.java Sun Apr 20 19:32:08 2014
@@ -17,6 +17,8 @@
 
 package org.apache.commons.configuration.plist;
 
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import java.io.PrintWriter;
 import java.io.Reader;
 import java.io.Writer;
@@ -31,13 +33,11 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
 
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.configuration.BaseHierarchicalConfiguration;
 import org.apache.commons.configuration.Configuration;
@@ -47,8 +47,8 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.ex.ConfigurationException;
 import org.apache.commons.configuration.io.FileLocator;
 import org.apache.commons.configuration.io.FileLocatorAware;
-import org.apache.commons.configuration.tree.ConfigurationNode;
-import org.apache.commons.configuration.tree.DefaultConfigurationNode;
+import org.apache.commons.configuration.tree.ImmutableNode;
+import org.apache.commons.configuration.tree.InMemoryNodeModel;
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.xml.sax.Attributes;
@@ -144,7 +144,6 @@ public class XMLPropertyListConfiguratio
      */
     public XMLPropertyListConfiguration()
     {
-        initRoot();
     }
 
     /**
@@ -154,11 +153,22 @@ public class XMLPropertyListConfiguratio
      * @param configuration the configuration to copy
      * @since 1.4
      */
-    public XMLPropertyListConfiguration(HierarchicalConfiguration configuration)
+    public XMLPropertyListConfiguration(HierarchicalConfiguration<ImmutableNode> configuration)
     {
         super(configuration);
     }
 
+    /**
+     * Creates a new instance of {@code XMLPropertyConfiguration} with the given
+     * root node.
+     *
+     * @param root the root node
+     */
+    XMLPropertyListConfiguration(ImmutableNode root)
+    {
+        super(new InMemoryNodeModel(root));
+    }
+
     @Override
     protected void setPropertyInternal(String key, Object value)
     {
@@ -210,26 +220,19 @@ public class XMLPropertyListConfiguratio
     @Override
     public void read(Reader in) throws ConfigurationException
     {
-        // We have to make sure that the root node is actually a PListNode.
-        // If this object was not created using the standard constructor, the
-        // root node is a plain Node.
-        if (!(getRootNode() instanceof PListNode))
-        {
-            initRoot();
-        }
-
         // set up the DTD validation
         EntityResolver resolver = new EntityResolver()
         {
             @Override
             public InputSource resolveEntity(String publicId, String systemId)
             {
-                return new InputSource(getClass().getClassLoader().getResourceAsStream("PropertyList-1.0.dtd"));
+                return new InputSource(getClass().getClassLoader()
+                        .getResourceAsStream("PropertyList-1.0.dtd"));
             }
         };
 
         // parse the file
-        XMLPropertyListHandler handler = new XMLPropertyListHandler(getRootNode());
+        XMLPropertyListHandler handler = new XMLPropertyListHandler();
         try
         {
             SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -239,10 +242,14 @@ public class XMLPropertyListConfiguratio
             parser.getXMLReader().setEntityResolver(resolver);
             parser.getXMLReader().setContentHandler(handler);
             parser.getXMLReader().parse(new InputSource(in));
+
+            getNodeModel().mergeRoot(handler.getResultBuilder().createNode(),
+                    null, null, null, this);
         }
         catch (Exception e)
         {
-            throw new ConfigurationException("Unable to parse the configuration file", e);
+            throw new ConfigurationException(
+                    "Unable to parse the configuration file", e);
         }
     }
 
@@ -272,24 +279,24 @@ public class XMLPropertyListConfiguratio
     /**
      * Append a node to the writer, indented according to a specific level.
      */
-    private void printNode(PrintWriter out, int indentLevel, ConfigurationNode node)
+    private void printNode(PrintWriter out, int indentLevel, ImmutableNode node)
     {
         String padding = StringUtils.repeat(" ", indentLevel * INDENT_SIZE);
 
-        if (node.getName() != null)
+        if (node.getNodeName() != null)
         {
-            out.println(padding + "<key>" + StringEscapeUtils.escapeXml(node.getName()) + "</key>");
+            out.println(padding + "<key>" + StringEscapeUtils.escapeXml(node.getNodeName()) + "</key>");
         }
 
-        List<ConfigurationNode> children = node.getChildren();
+        List<ImmutableNode> children = node.getChildren();
         if (!children.isEmpty())
         {
             out.println(padding + "<dict>");
 
-            Iterator<ConfigurationNode> it = children.iterator();
+            Iterator<ImmutableNode> it = children.iterator();
             while (it.hasNext())
             {
-                ConfigurationNode child = it.next();
+                ImmutableNode child = it.next();
                 printNode(out, indentLevel + 1, child);
 
                 if (it.hasNext())
@@ -320,9 +327,9 @@ public class XMLPropertyListConfiguratio
 
         if (value instanceof Date)
         {
-            synchronized (PListNode.FORMAT)
+            synchronized (PListNodeBuilder.FORMAT)
             {
-                out.println(padding + "<date>" + PListNode.FORMAT.format((Date) value) + "</date>");
+                out.println(padding + "<date>" + PListNodeBuilder.FORMAT.format((Date) value) + "</date>");
             }
         }
         else if (value instanceof Calendar)
@@ -354,16 +361,20 @@ public class XMLPropertyListConfiguratio
         else if (value instanceof List)
         {
             out.println(padding + "<array>");
-            Iterator<?> it = ((List<?>) value).iterator();
-            while (it.hasNext())
+            for (Object o : (List<?>) value)
             {
-                printValue(out, indentLevel + 1, it.next());
+                printValue(out, indentLevel + 1, o);
             }
             out.println(padding + "</array>");
         }
         else if (value instanceof HierarchicalConfiguration)
         {
-            printNode(out, indentLevel, ((HierarchicalConfiguration) value).getRootNode());
+            // This is safe because we have created this configuration
+            @SuppressWarnings("unchecked")
+            HierarchicalConfiguration<ImmutableNode> config =
+                    (HierarchicalConfiguration<ImmutableNode>) value;
+            printNode(out, indentLevel, config.getNodeModel().getNodeHandler()
+                    .getRootNode());
         }
         else if (value instanceof Configuration)
         {
@@ -376,8 +387,9 @@ public class XMLPropertyListConfiguratio
             {
                 // create a node for each property
                 String key = it.next();
-                ConfigurationNode node = new DefaultConfigurationNode(key);
-                node.setValue(config.getProperty(key));
+                ImmutableNode node =
+                        new ImmutableNode.Builder().name(key)
+                                .value(config.getProperty(key)).create();
 
                 // print the node
                 printNode(out, indentLevel + 1, node);
@@ -411,14 +423,6 @@ public class XMLPropertyListConfiguratio
     }
 
     /**
-     * Helper method for initializing the configuration's root node.
-     */
-    private void initRoot()
-    {
-        setRootNode(new PListNode());
-    }
-
-    /**
      * Transform a map of arbitrary types into a map with string keys and object
      * values. All keys of the source map which are not of type String are
      * dropped.
@@ -448,17 +452,31 @@ public class XMLPropertyListConfiguratio
         private final StringBuilder buffer = new StringBuilder();
 
         /** The stack of configuration nodes */
-        private final List<ConfigurationNode> stack = new ArrayList<ConfigurationNode>();
+        private final List<PListNodeBuilder> stack = new ArrayList<PListNodeBuilder>();
+
+        /** The builder for the resulting node. */
+        private final PListNodeBuilder resultBuilder;
 
-        public XMLPropertyListHandler(ConfigurationNode root)
+        public XMLPropertyListHandler()
+        {
+            resultBuilder = new PListNodeBuilder();
+            push(resultBuilder);
+        }
+
+        /**
+         * Returns the builder for the result node.
+         *
+         * @return the result node builder
+         */
+        public PListNodeBuilder getResultBuilder()
         {
-            push(root);
+            return resultBuilder;
         }
 
         /**
          * Return the node on the top of the stack.
          */
-        private ConfigurationNode peek()
+        private PListNodeBuilder peek()
         {
             if (!stack.isEmpty())
             {
@@ -473,7 +491,7 @@ public class XMLPropertyListConfiguratio
         /**
          * Remove and return the node on the top of the stack.
          */
-        private ConfigurationNode pop()
+        private PListNodeBuilder pop()
         {
             if (!stack.isEmpty())
             {
@@ -488,7 +506,7 @@ public class XMLPropertyListConfiguratio
         /**
          * Put a node on the top of the stack.
          */
-        private void push(ConfigurationNode node)
+        private void push(PListNodeBuilder node)
         {
             stack.add(node);
         }
@@ -498,21 +516,14 @@ public class XMLPropertyListConfiguratio
         {
             if ("array".equals(qName))
             {
-                push(new ArrayNode());
+                push(new ArrayNodeBuilder());
             }
             else if ("dict".equals(qName))
             {
-                if (peek() instanceof ArrayNode)
+                if (peek() instanceof ArrayNodeBuilder)
                 {
-                    // create the configuration
-                    XMLPropertyListConfiguration config = new XMLPropertyListConfiguration();
-
-                    // add it to the ArrayNode
-                    ArrayNode node = (ArrayNode) peek();
-                    node.addValue(config);
-
-                    // push the root on the stack
-                    push(config.getRootNode());
+                    // push the new root builder on the stack
+                    push(new PListNodeBuilder());
                 }
             }
         }
@@ -523,7 +534,7 @@ public class XMLPropertyListConfiguratio
             if ("key".equals(qName))
             {
                 // create a new node, link it to its parent and push it on the stack
-                PListNode node = new PListNode();
+                PListNodeBuilder node = new PListNodeBuilder();
                 node.setName(buffer.toString());
                 peek().addChild(node);
                 push(node);
@@ -531,39 +542,48 @@ public class XMLPropertyListConfiguratio
             else if ("dict".equals(qName))
             {
                 // remove the root of the XMLPropertyListConfiguration previously pushed on the stack
-                pop();
+                PListNodeBuilder builder = pop();
+                if (peek() instanceof ArrayNodeBuilder)
+                {
+                    // create the configuration
+                    XMLPropertyListConfiguration config = new XMLPropertyListConfiguration(builder.createNode());
+
+                    // add it to the ArrayNodeBuilder
+                    ArrayNodeBuilder node = (ArrayNodeBuilder) peek();
+                    node.addValue(config);
+                }
             }
             else
             {
                 if ("string".equals(qName))
                 {
-                    ((PListNode) peek()).addValue(buffer.toString());
+                    peek().addValue(buffer.toString());
                 }
                 else if ("integer".equals(qName))
                 {
-                    ((PListNode) peek()).addIntegerValue(buffer.toString());
+                    peek().addIntegerValue(buffer.toString());
                 }
                 else if ("real".equals(qName))
                 {
-                    ((PListNode) peek()).addRealValue(buffer.toString());
+                    peek().addRealValue(buffer.toString());
                 }
                 else if ("true".equals(qName))
                 {
-                    ((PListNode) peek()).addTrueValue();
+                    peek().addTrueValue();
                 }
                 else if ("false".equals(qName))
                 {
-                    ((PListNode) peek()).addFalseValue();
+                    peek().addFalseValue();
                 }
                 else if ("data".equals(qName))
                 {
-                    ((PListNode) peek()).addDataValue(buffer.toString());
+                    peek().addDataValue(buffer.toString());
                 }
                 else if ("date".equals(qName))
                 {
                     try
                     {
-                        ((PListNode) peek()).addDateValue(buffer.toString());
+                        peek().addDateValue(buffer.toString());
                     }
                     catch (IllegalArgumentException iex)
                     {
@@ -573,13 +593,13 @@ public class XMLPropertyListConfiguratio
                 }
                 else if ("array".equals(qName))
                 {
-                    ArrayNode array = (ArrayNode) pop();
-                    ((PListNode) peek()).addList(array);
+                    ArrayNodeBuilder array = (ArrayNodeBuilder) pop();
+                    peek().addList(array);
                 }
 
                 // remove the plist node on the stack once the value has been parsed,
                 // array nodes remains on the stack for the next values in the list
-                if (!(peek() instanceof ArrayNode))
+                if (!(peek() instanceof ArrayNodeBuilder))
                 {
                     pop();
                 }
@@ -596,18 +616,12 @@ public class XMLPropertyListConfiguratio
     }
 
     /**
-     * Node extension with addXXX methods to parse the typed data passed by the SAX handler.
-     * <b>Do not use this class !</b> It is used internally by XMLPropertyConfiguration
-     * to parse the configuration file, it may be removed at any moment in the future.
+     * A specialized builder class with addXXX methods to parse the typed data passed by the SAX handler.
+     * It is used for creating the nodes of the configuration.
      */
-    public static class PListNode extends DefaultConfigurationNode
+    private static class PListNodeBuilder
     {
         /**
-         * The serial version UID.
-         */
-        private static final long serialVersionUID = -7614060264754798317L;
-
-        /**
          * The MacOS FORMAT of dates in plist files. Note: Because
          * {@code SimpleDateFormat} is not thread-safe, each access has to be
          * synchronized.
@@ -625,33 +639,43 @@ public class XMLPropertyListConfiguratio
          */
         private static final DateFormat GNUSTEP_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
 
+        /** A collection with child builders of this builder. */
+        private final Collection<PListNodeBuilder> childBuilders =
+                new LinkedList<PListNodeBuilder>();
+
+        /** The name of the represented node. */
+        private String name;
+
+        /** The current value of the represented node. */
+        private Object value;
+
         /**
          * Update the value of the node. If the existing value is null, it's
          * replaced with the new value. If the existing value is a list, the
          * specified value is appended to the list. If the existing value is
          * not null, a list with the two values is built.
          *
-         * @param value the value to be added
+         * @param v the value to be added
          */
-        public void addValue(Object value)
+        public void addValue(Object v)
         {
-            if (getValue() == null)
+            if (value == null)
             {
-                setValue(value);
+                value = v;
             }
-            else if (getValue() instanceof Collection)
+            else if (value instanceof Collection)
             {
                 // This is safe because we create the collections ourselves
                 @SuppressWarnings("unchecked")
-                Collection<Object> collection = (Collection<Object>) getValue();
-                collection.add(value);
+                Collection<Object> collection = (Collection<Object>) value;
+                collection.add(v);
             }
             else
             {
                 List<Object> list = new ArrayList<Object>();
-                list.add(getValue());
                 list.add(value);
-                setValue(list);
+                list.add(v);
+                value = list;
             }
         }
 
@@ -741,9 +765,56 @@ public class XMLPropertyListConfiguratio
          *
          * @param node the node whose value will be added to the current node value
          */
-        public void addList(ArrayNode node)
+        public void addList(ArrayNodeBuilder node)
         {
-            addValue(node.getValue());
+            addValue(node.getNodeValue());
+        }
+
+        /**
+         * Sets the name of the represented node.
+         *
+         * @param nodeName the node name
+         */
+        public void setName(String nodeName)
+        {
+            name = nodeName;
+        }
+
+        /**
+         * Adds the given child builder to this builder.
+         *
+         * @param child the child builder to be added
+         */
+        public void addChild(PListNodeBuilder child)
+        {
+            childBuilders.add(child);
+        }
+
+        /**
+         * Creates the configuration node defined by this builder.
+         *
+         * @return the newly created configuration node
+         */
+        public ImmutableNode createNode()
+        {
+            ImmutableNode.Builder nodeBuilder =
+                    new ImmutableNode.Builder(childBuilders.size());
+            for (PListNodeBuilder child : childBuilders)
+            {
+                nodeBuilder.addChild(child.createNode());
+            }
+            return nodeBuilder.name(name).value(getNodeValue()).create();
+        }
+
+        /**
+         * Returns the final value for the node to be created. This method is
+         * called when the represented configuration node is actually created.
+         *
+         * @return the value of the resulting configuration node
+         */
+        protected Object getNodeValue()
+        {
+            return value;
         }
     }
 
@@ -752,13 +823,8 @@ public class XMLPropertyListConfiguratio
      * It is used internally by XMLPropertyConfiguration to parse the
      * configuration file, it may be removed at any moment in the future.
      */
-    public static class ArrayNode extends PListNode
+    private static class ArrayNodeBuilder extends PListNodeBuilder
     {
-        /**
-         * The serial version UID.
-         */
-        private static final long serialVersionUID = 5586544306664205835L;
-
         /** The list of values in the array. */
         private final List<Object> list = new ArrayList<Object>();
 
@@ -779,7 +845,7 @@ public class XMLPropertyListConfiguratio
          * @return the {@link List} of values
          */
         @Override
-        public Object getValue()
+        protected Object getNodeValue()
         {
             return list;
         }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitor.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitor.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitor.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitor.java Sun Apr 20 19:32:08 2014
@@ -22,44 +22,49 @@ package org.apache.commons.configuration
  * structure.
  * </p>
  * <p>
- * The {@code ConfigurationNode} interface defines a {@code visit()},
- * which simplifies traversal of a complex node hierarchy. A configuration node
- * implementation must provide a way of visiting all nodes in the current
- * hierarchy. This is a typical application of the GoF <em>Visitor</em>
- * pattern.
+ * This is a typical application of the GoF <em>Visitor</em> pattern. An object
+ * implementing this interface can be used to traverse a hierarchical structure
+ * of nodes in various ways. The type of the nodes in the structure is generic;
+ * a corresponding {@link NodeHandler} implementation must be available for
+ * navigating through the structure.
+ * </p>
+ * <p>
+ * Note that the exact way the methods of a {@code ConfigurationNodeVisitor} are
+ * invoked is dependent on a specific traversal process.
  * </p>
  *
  * @since 1.3
- * @see ConfigurationNode
- * @author <a
- * href="http://commons.apache.org/configuration/team-list.html">Commons
- * Configuration team</a>
  * @version $Id$
+ * @param <T> the type of the nodes processed by this visitor
  */
-public interface ConfigurationNodeVisitor
+public interface ConfigurationNodeVisitor<T>
 {
     /**
-     * Visits the specified node. This method is called before eventually
-     * existing children of this node are processed.
+     * Visits the specified node before the children of this node - if existing
+     * - are processed.
      *
      * @param node the node to be visited
+     * @param handler the {@code NodeHandler}
      */
-    void visitBeforeChildren(ConfigurationNode node);
+    void visitBeforeChildren(T node, NodeHandler<T> handler);
 
     /**
-     * Visits the specified node. This method is called after eventually
-     * existing children of this node have been processed.
+     * Visits the specified node after after its children - if existing - have
+     * been processed.
      *
      * @param node the node to be visited
+     * @param handler the {@code NodeHandler}
      */
-    void visitAfterChildren(ConfigurationNode node);
+    void visitAfterChildren(T node, NodeHandler<T> handler);
 
     /**
-     * Returns a flag whether the actual visit process should be aborted. This
+     * Returns a flag whether the current visit process should be aborted. This
      * method allows a visitor implementation to state that it does not need any
      * further data. It may be used e.g. by visitors that search for a certain
      * node in the hierarchy. After that node was found, there is no need to
-     * process the remaining nodes, too.
+     * process the remaining nodes, too. This method is called after each
+     * visited node. A result of <strong>true</strong> indicates that the
+     * current iteration is to be aborted.
      *
      * @return a flag if the visit process should be stopped
      */

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitorAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitorAdapter.java?rev=1588831&r1=1588830&r2=1588831&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitorAdapter.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/tree/ConfigurationNodeVisitorAdapter.java Sun Apr 20 19:32:08 2014
@@ -27,38 +27,31 @@ package org.apache.commons.configuration
  * to override the methods they really need.
  * </p>
  *
- * @author <a
- * href="http://commons.apache.org/configuration/team-list.html">Commons
- * Configuration team</a>
  * @version $Id$
+ * @param  <T> the type of the nodes processed by this visitor
  */
-public class ConfigurationNodeVisitorAdapter implements
-        ConfigurationNodeVisitor
+public class ConfigurationNodeVisitorAdapter<T> implements
+        ConfigurationNodeVisitor<T>
 {
     /**
-     * Empty dummy implementation of this interface method.
-     *
-     * @param node the node
+     * {@inheritDoc} Empty dummy implementation of this interface method.
      */
     @Override
-    public void visitBeforeChildren(ConfigurationNode node)
+    public void visitBeforeChildren(T node, NodeHandler<T> handler)
     {
     }
 
     /**
-     * Empty dummy implementation of this interface method.
-     *
-     * @param node the node
+     * {@inheritDoc} Empty dummy implementation of this interface method.
      */
     @Override
-    public void visitAfterChildren(ConfigurationNode node)
+    public void visitAfterChildren(T node, NodeHandler<T> handler)
     {
     }
 
     /**
-     * Dummy implementation of this interface method. Returns always <b>false</b>.
-     *
-     * @return the terminate flag
+     * {@inheritDoc} This implementation returns always <b>false</b>; this means
+     * that all nodes in the current hierarchy are traversed.
      */
     @Override
     public boolean terminate()