commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r618063 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/ConfigurationConverter.java test/java/org/apache/commons/configuration2/TestConfigurationConverter.java
Date Sun, 03 Feb 2008 19:18:47 GMT
Author: oheger
Date: Sun Feb  3 11:18:46 2008
New Revision: 618063

URL: http://svn.apache.org/viewvc?rev=618063&view=rev
Log:
Removed dependency to commons-collections from ConfigurationConverter. The methods dealing
with ExtendedProperties have been removed (this class is more or less replaced by PropertiesConfiguration
anyway according to its Javadocs).

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationConverter.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestConfigurationConverter.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationConverter.java?rev=618063&r1=618062&r2=618063&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationConverter.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/ConfigurationConverter.java
Sun Feb  3 11:18:46 2008
@@ -21,9 +21,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Vector;
 
-import org.apache.commons.collections.ExtendedProperties;
 import org.apache.commons.lang.StringUtils;
 
 /**
@@ -40,18 +38,7 @@
      */
     private ConfigurationConverter()
     {
-        // to prevent instanciation...
-    }
-
-    /**
-     * Convert a ExtendedProperties class into a Configuration class.
-     *
-     * @param eprops ExtendedProperties object to convert
-     * @return Configuration created from the ExtendedProperties
-     */
-    public static Configuration getConfiguration(ExtendedProperties eprops)
-    {
-        return new MapConfiguration(eprops);
+        // to prevent instantiation...
     }
 
     /**
@@ -66,35 +53,6 @@
     }
 
     /**
-     * Convert a Configuration class into a ExtendedProperties class.
-     *
-     * @param config Configuration object to convert
-     * @return ExtendedProperties created from the Configuration
-     */
-    public static ExtendedProperties getExtendedProperties(Configuration config)
-    {
-        ExtendedProperties props = new ExtendedProperties();
-
-        Iterator keys = config.getKeys();
-
-        while (keys.hasNext())
-        {
-            String key = (String) keys.next();
-            Object property = config.getProperty(key);
-
-            // turn lists into vectors
-            if (property instanceof List)
-            {
-                property = new Vector((List) property);
-            }
-
-            props.setProperty(key, property);
-        }
-
-        return props;
-    }
-
-    /**
      * Convert a Configuration class into a Properties class. List properties
      * are joined into a string using the delimiter of the configuration if it
      * extends AbstractConfiguration, and a comma otherwise.
@@ -109,11 +67,11 @@
         char delimiter = (config instanceof AbstractConfiguration)
             ? ((AbstractConfiguration) config).getListDelimiter() : ',';
 
-        Iterator keys = config.getKeys();
+        Iterator<String> keys = config.getKeys();
         while (keys.hasNext())
         {
-            String key = (String) keys.next();
-            List list = config.getList(key);
+            String key = keys.next();
+            List<?> list = config.getList(key);
 
             // turn the list into a string
             props.setProperty(key, StringUtils.join(list.iterator(), delimiter));
@@ -128,7 +86,7 @@
      * @param config Configuration object to convert
      * @return Map created from the Configuration
      */
-    public static Map getMap(Configuration config)
+    public static Map<String, Object> getMap(Configuration config)
     {
         return new ConfigurationMap(config);
     }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestConfigurationConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestConfigurationConverter.java?rev=618063&r1=618062&r2=618063&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestConfigurationConverter.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestConfigurationConverter.java
Sun Feb  3 11:18:46 2008
@@ -22,7 +22,6 @@
 import java.util.Properties;
 
 import junit.framework.TestCase;
-import org.apache.commons.collections.ExtendedProperties;
 import org.apache.commons.configuration2.BaseConfiguration;
 import org.apache.commons.configuration2.Configuration;
 import org.apache.commons.configuration2.ConfigurationConverter;
@@ -36,23 +35,6 @@
  */
 public class TestConfigurationConverter extends TestCase
 {
-    public void testExtendedPropertiesToConfiguration()
-    {
-        ExtendedProperties eprops = new ExtendedProperties();
-        eprops.setProperty("string", "teststring");
-        eprops.setProperty("int", "123");
-        eprops.addProperty("list", "item 1");
-        eprops.addProperty("list", "item 2");
-
-        Configuration config = ConfigurationConverter.getConfiguration(eprops);
-
-        assertEquals("This returns 'teststring'", "teststring", config.getString("string"));
-        List item1 = config.getList("list");
-        assertEquals("This returns 'item 1'", "item 1", (String) item1.get(0));
-
-        assertEquals("This returns 123", 123, config.getInt("int"));
-    }
-
     public void testPropertiesToConfiguration()
     {
         Properties props = new Properties();
@@ -63,28 +45,12 @@
         Configuration config = ConfigurationConverter.getConfiguration(props);
 
         assertEquals("This returns 'teststring'", "teststring", config.getString("string"));
-        List item1 = config.getList("list");
+        List<?> item1 = config.getList("list");
         assertEquals("This returns 'item 1'", "item 1", (String) item1.get(0));
 
         assertEquals("This returns 123", 123, config.getInt("int"));
     }
 
-    public void testConfigurationToExtendedProperties()
-    {
-        Configuration config = new BaseConfiguration();
-        config.setProperty("string", "teststring");
-        config.setProperty("int", "123");
-        config.addProperty("list", "item 1");
-        config.addProperty("list", "item 2");
-
-        ExtendedProperties eprops = ConfigurationConverter.getExtendedProperties(config);
-
-        assertEquals("This returns 'teststring'", "teststring", eprops.getString("string"));
-        List list = eprops.getVector("list");
-        assertEquals("This returns 'item 1'", "item 1", (String) list.get(0));
-        assertEquals("This returns 123", 123, eprops.getInt("int"));
-    }
-
     public void testConfigurationToProperties()
     {
         BaseConfiguration config = new BaseConfiguration();
@@ -114,7 +80,7 @@
         Configuration config = new BaseConfiguration();
         config.addProperty("string", "teststring");
 
-        Map map = ConfigurationConverter.getMap(config);
+        Map<String, Object> map = ConfigurationConverter.getMap(config);
 
         assertNotNull("null map", map);
         assertEquals("'string' property", "teststring", map.get("string"));



Mime
View raw message