commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1638383 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration2/builder/ test/java/org/apache/commons/configuration2/builder/
Date Tue, 11 Nov 2014 20:47:24 GMT
Author: oheger
Date: Tue Nov 11 20:47:23 2014
New Revision: 1638383

URL: http://svn.apache.org/r1638383
Log:
Extended BasicBuilderProperties by a ConfigurationDecoder property.

It is now possible to set the decoder property via initialization parameters of
a configuration builder.

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

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java?rev=1638383&r1=1638382&r2=1638383&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderParameters.java
Tue Nov 11 20:47:23 2014
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.ConfigurationDecoder;
 import org.apache.commons.configuration2.beanutils.BeanHelper;
 import org.apache.commons.configuration2.convert.ConversionHandler;
 import org.apache.commons.configuration2.convert.ListDelimiterHandler;
@@ -82,6 +83,9 @@ public class BasicBuilderParameters impl
     /** The key for the <em>conversionHandler</em> property. */
     private static final String PROP_CONVERSION_HANDLER = "conversionHandler";
 
+    /** The key for the <em>configurationDecoder</em> property. */
+    private static final String PROP_CONFIGURATION_DECODER = "configurationDecoder";
+
     /** The key for the {@code BeanHelper}. */
     private static final String PROP_BEAN_HELPER = RESERVED_PARAMETER_PREFIX
             + "BeanHelper";
@@ -266,6 +270,17 @@ public class BasicBuilderParameters impl
     }
 
     /**
+     * {@inheritDoc} This implementation stores the passed in
+     * {@code ConfigurationDecoder} object in the internal parameters map.
+     */
+    @Override
+    public BasicBuilderParameters setConfigurationDecoder(
+            ConfigurationDecoder decoder)
+    {
+        return setProperty(PROP_CONFIGURATION_DECODER, decoder);
+    }
+
+    /**
      * Merges this object with the given parameters object. This method adds all
      * property values defined by the passed in parameters object to the
      * internal storage which are not already in. So properties already defined

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderProperties.java?rev=1638383&r1=1638382&r2=1638383&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderProperties.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/builder/BasicBuilderProperties.java
Tue Nov 11 20:47:23 2014
@@ -20,6 +20,7 @@ import java.util.Collection;
 import java.util.Map;
 
 import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.ConfigurationDecoder;
 import org.apache.commons.configuration2.beanutils.BeanHelper;
 import org.apache.commons.configuration2.convert.ConversionHandler;
 import org.apache.commons.configuration2.convert.ListDelimiterHandler;
@@ -165,6 +166,16 @@ public interface BasicBuilderProperties<
     T setConversionHandler(ConversionHandler handler);
 
     /**
+     * Sets the {@code ConfigurationDecoder} object for this configuration. This
+     * object is called when encoded properties are queried using the
+     * {@code getEncodedString()} method.
+     *
+     * @param decoder the {@code ConfigurationDecoder} to be used
+     * @return a reference to this object for method chaining
+     */
+    T setConfigurationDecoder(ConfigurationDecoder decoder);
+
+    /**
      * Sets a {@code BeanHelper} object to be used by the configuration builder.
      * The {@code BeanHelper} is used to create the managed configuration
      * instance dynamically. It is not a property of the configuration as most

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestBasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestBasicBuilderParameters.java?rev=1638383&r1=1638382&r2=1638383&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestBasicBuilderParameters.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/builder/TestBasicBuilderParameters.java
Tue Nov 11 20:47:23 2014
@@ -29,6 +29,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.configuration2.ConfigurationDecoder;
 import org.apache.commons.configuration2.beanutils.BeanHelper;
 import org.apache.commons.configuration2.convert.ConversionHandler;
 import org.apache.commons.configuration2.convert.ListDelimiterHandler;
@@ -515,4 +516,19 @@ public class TestBasicBuilderParameters
     {
         BasicBuilderParameters.fetchBeanHelper(null);
     }
+
+    /**
+     * Tests whether a decoder can be set.
+     */
+    @Test
+    public void testSetConfigurationDecoder()
+    {
+        ConfigurationDecoder decoder =
+                EasyMock.createMock(ConfigurationDecoder.class);
+        EasyMock.replay(decoder);
+        assertSame("Wrong result", params,
+                params.setConfigurationDecoder(decoder));
+        assertSame("Decoder not set", decoder,
+                params.getParameters().get("configurationDecoder"));
+    }
 }



Mime
View raw message