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:19:31 UTC

svn commit: r1588820 - in /commons/proper/configuration/branches/immutableNodes/src: main/java/org/apache/commons/configuration/ test/java/org/apache/commons/configuration/event/

Author: oheger
Date: Sun Apr 20 19:19:31 2014
New Revision: 1588820

URL: http://svn.apache.org/r1588820
Log:
Reworked the return type of clearTreeInternal().

The method can now return an arbitrary object which is used as value when
creating a configuration change event. It is up to the NodeModel in use how
this value is constructed.

Modified:
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/event/TestHierarchicalConfigurationEvents.java

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java?rev=1588820&r1=1588819&r2=1588820&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java (original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java Sun Apr 20 19:19:31 2014
@@ -33,7 +33,6 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.sync.LockMode;
 import org.apache.commons.configuration.sync.NoOpSynchronizer;
 import org.apache.commons.configuration.sync.Synchronizer;
-import org.apache.commons.configuration.tree.ConfigurationNode;
 import org.apache.commons.configuration.tree.ConfigurationNodeVisitorAdapter;
 import org.apache.commons.configuration.tree.DefaultExpressionEngine;
 import org.apache.commons.configuration.tree.ExpressionEngine;
@@ -626,7 +625,7 @@ public abstract class AbstractHierarchic
         try
         {
             fireEvent(EVENT_CLEAR_TREE, key, null, true);
-            List<ConfigurationNode> nodes = clearTreeInternal(key);
+            Object nodes = clearTreeInternal(key);
             fireEvent(EVENT_CLEAR_TREE, key, nodes, false);
         }
         finally
@@ -642,15 +641,14 @@ public abstract class AbstractHierarchic
      * delegates to the node model.
      *
      * @param key the key of the property to be removed
-     * @return a collection with the nodes that have been removed (this is
-     *         needed for firing a meaningful event of type EVENT_CLEAR_TREE)
+     * @return an object with information about the nodes that have been removed
+     *         (this is needed for firing a meaningful event of type
+     *         EVENT_CLEAR_TREE)
      * @since 2.0
      */
-    protected List<ConfigurationNode> clearTreeInternal(String key)
+    protected Object clearTreeInternal(String key)
     {
-        getModel().clearTree(key, this);
-        //TODO return something meaningful
-        return null;
+        return getModel().clearTree(key, this);
     }
 
     /**

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/event/TestHierarchicalConfigurationEvents.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/event/TestHierarchicalConfigurationEvents.java?rev=1588820&r1=1588819&r2=1588820&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/event/TestHierarchicalConfigurationEvents.java (original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/event/TestHierarchicalConfigurationEvents.java Sun Apr 20 19:19:31 2014
@@ -27,6 +27,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.configuration.tree.ImmutableNode;
 import org.apache.commons.configuration.tree.NodeStructureHelper;
+import org.apache.commons.configuration.tree.QueryResult;
 import org.junit.Test;
 
 /**
@@ -51,12 +52,12 @@ public class TestHierarchicalConfigurati
     {
         BaseHierarchicalConfiguration hc = (BaseHierarchicalConfiguration) config;
         String key = EXIST_PROPERTY.substring(0, EXIST_PROPERTY.indexOf('.'));
-//        Collection<ImmutableNode> nodes = hc.getExpressionEngine()
-//                .query(hc.getRootNode(), key, hc.getModel().getNodeHandler());
+        Collection<QueryResult<ImmutableNode>> nodes = hc.getExpressionEngine()
+                .query(hc.getRootNode(), key, hc.getNodeModel().getNodeHandler());
         hc.clearTree(key);
         l.checkEvent(BaseHierarchicalConfiguration.EVENT_CLEAR_TREE, key, null,
                 true);
-        l.checkEvent(BaseHierarchicalConfiguration.EVENT_CLEAR_TREE, key, null /* nodes*/,
+        l.checkEvent(BaseHierarchicalConfiguration.EVENT_CLEAR_TREE, key, nodes,
                 false);
         l.done();
     }