commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1502838 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/ test/java/org/apache/commons/configuration/
Date Sat, 13 Jul 2013 19:20:33 GMT
Author: oheger
Date: Sat Jul 13 19:20:33 2013
New Revision: 1502838

URL: http://svn.apache.org/r1502838
Log:
Integrated ListDelimiterHandler with MapConfiguration.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestConfigurationConverter.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestMapConfiguration.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java?rev=1502838&r1=1502837&r2=1502838&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
Sat Jul 13 19:20:33 2013
@@ -18,6 +18,7 @@
 package org.apache.commons.configuration;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -164,10 +165,10 @@ public class MapConfiguration extends Ab
     protected Object getPropertyInternal(String key)
     {
         Object value = map.get(key);
-        if ((value instanceof String) && (!isDelimiterParsingDisabled()))
+        if (value instanceof String)
         {
-            List<String> list = PropertyConverter.split((String) value, getListDelimiter(),
!isTrimmingDisabled());
-            return list.size() > 1 ? list : list.get(0);
+            Collection<String> list = getListDelimiterHandler().split((String) value,
!isTrimmingDisabled());
+            return list.size() > 1 ? list : list.iterator().next();
         }
         else
         {

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestConfigurationConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestConfigurationConverter.java?rev=1502838&r1=1502837&r2=1502838&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestConfigurationConverter.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestConfigurationConverter.java
Sat Jul 13 19:20:33 2013
@@ -62,7 +62,9 @@ public class TestConfigurationConverter
         props.setProperty("int", "123");
         props.setProperty("list", "item 1, item 2");
 
-        Configuration config = ConfigurationConverter.getConfiguration(props);
+        AbstractConfiguration config =
+                (AbstractConfiguration) ConfigurationConverter.getConfiguration(props);
+        config.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
 
         assertEquals("This returns 'teststring'", "teststring", config.getString("string"));
         List<Object> item1 = config.getList("list");

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestMapConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestMapConfiguration.java?rev=1502838&r1=1502837&r2=1502838&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestMapConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestMapConfiguration.java
Sat Jul 13 19:20:33 2013
@@ -55,7 +55,9 @@ public class TestMapConfiguration extend
         map.put("list", "value1, value2");
         map.put("listesc", "value1\\,value2");
 
-        return new MapConfiguration(map);
+        MapConfiguration config = new MapConfiguration(map);
+        config.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
+        return config;
     }
 
     @Override
@@ -163,7 +165,7 @@ public class TestMapConfiguration extend
     }
 
     /**
-     * Tests querying a property when trimming is enabled, but list splitting is
+     * Tests querying a property if trimming is enabled, but list splitting is
      * disabled. In this case no trimming is performed (trimming only works if
      * list splitting is enabled).
      */
@@ -172,7 +174,7 @@ public class TestMapConfiguration extend
     {
         MapConfiguration config = (MapConfiguration) getConfiguration();
         config.getMap().put(KEY, SPACE_VALUE);
-        config.setDelimiterParsingDisabled(true);
+        config.setListDelimiterHandler(new DisabledListDelimiterHandler());
         assertEquals("Wrong trimmed value", SPACE_VALUE, config.getProperty(KEY));
     }
 }



Mime
View raw message