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 2013/01/13 22:15:27 UTC

svn commit: r1432742 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java

Author: oheger
Date: Sun Jan 13 21:15:27 2013
New Revision: 1432742

URL: http://svn.apache.org/viewvc?rev=1432742&view=rev
Log:
Provide access to the ConfigurationInterpolator. (This is probably only a temporary solution.)

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java?rev=1432742&r1=1432741&r2=1432742&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java Sun Jan 13 21:15:27 2013
@@ -251,6 +251,22 @@ public class BasicBuilderParameters impl
     }
 
     /**
+     * Obtains the {@code ConfigurationInterpolator} from the given map with
+     * parameters. If such an object is stored in the map under the correct key,
+     * it is returned. Otherwise, result is <b>null</b>.
+     *
+     * @param params the map with parameters (must not be <b>null</b>)
+     * @return the {@code ConfigurationInterpolator} obtained from this map or
+     *         <b>null</b>
+     * @throws NullPointerException if the map is <b>null</b>
+     */
+    public static ConfigurationInterpolator fetchInterpolator(
+            Map<String, Object> params)
+    {
+        return (ConfigurationInterpolator) params.get(PROP_INTERPOLATOR);
+    }
+
+    /**
      * Sets a property for this parameters object. Properties are stored in an
      * internal map. With this method a new entry can be added to this map. If
      * the value is <b>null</b>, the key is removed from the internal map. This

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java?rev=1432742&r1=1432741&r2=1432742&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java Sun Jan 13 21:15:27 2013
@@ -19,6 +19,7 @@ package org.apache.commons.configuration
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 
 import java.util.ArrayList;
@@ -269,4 +270,29 @@ public class TestBasicBuilderParameters
                 map.containsKey(BuilderParameters.RESERVED_PARAMETER_PREFIX
                         + "test"));
     }
+
+    /**
+     * Tests fetchInterpolator() if the map does not contain an object.
+     */
+    @Test
+    public void testFetchInterpolatorNotFound()
+    {
+        Map<String, Object> params = new HashMap<String, Object>();
+        assertNull("Got an interpolator",
+                BasicBuilderParameters.fetchInterpolator(params));
+    }
+
+    /**
+     * Tests whether a {@code ConfigurationInterpolator} can be obtained from a
+     * parameters map.
+     */
+    @Test
+    public void testFetchInterpolatorFound()
+    {
+        ConfigurationInterpolator ci = new ConfigurationInterpolator();
+        params.setInterpolator(ci);
+        Map<String, Object> map = params.getParameters();
+        assertSame("Wrong interpolator", ci,
+                BasicBuilderParameters.fetchInterpolator(map));
+    }
 }