You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by eb...@apache.org on 2005/08/24 13:08:30 UTC
svn commit: r239600 - in /jakarta/commons/proper/configuration/trunk:
src/java/org/apache/commons/configuration/MapConfiguration.java
src/test/org/apache/commons/configuration/TestAbstractConfiguration.java
xdocs/changes.xml
Author: ebourg
Date: Wed Aug 24 04:08:23 2005
New Revision: 239600
URL: http://svn.apache.org/viewcvs?rev=239600&view=rev
Log:
Fixed MapConfiguration to store the list of values added under a same key instead of the last value added.
Modified:
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java
jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java?rev=239600&r1=239599&r2=239600&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/MapConfiguration.java Wed Aug 24 04:08:23 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.apache.commons.configuration;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -66,9 +67,28 @@
}
}
- protected void addPropertyDirect(String key, Object obj)
+ protected void addPropertyDirect(String key, Object value)
{
- map.put(key, obj);
+ Object previousValue = getProperty(key);
+
+ if (previousValue == null)
+ {
+ map.put(key, value);
+ }
+ else if (previousValue instanceof List)
+ {
+ // the value is added to the existing list
+ ((List) previousValue).add(value);
+ }
+ else
+ {
+ // the previous value is replaced by a list containing the previous value and the new value
+ List list = new ArrayList();
+ list.add(previousValue);
+ list.add(value);
+
+ map.put(key, list);
+ }
}
public boolean isEmpty()
Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java?rev=239600&r1=239599&r2=239600&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java Wed Aug 24 04:08:23 2005
@@ -70,6 +70,18 @@
AbstractConfiguration config = getConfiguration();
config.addPropertyDirect("key3", "value3");
assertEquals("key3", "value3", config.getProperty("key3"));
+
+ config.addPropertyDirect("key3", "value4");
+ config.addPropertyDirect("key3", "value5");
+ List list = config.getList("key3");
+ assertNotNull("no list found for the 'key3' property", list);
+
+ List expected = new ArrayList();
+ expected.add("value3");
+ expected.add("value4");
+ expected.add("value5");
+
+ ListAssert.assertEquals("values for the 'key3' property", expected, list);
}
public void testIsEmpty()
Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=239600&r1=239599&r2=239600&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Wed Aug 24 04:08:23 2005
@@ -23,6 +23,10 @@
<body>
<release version="1.2-dev" date="in SVN">
+ <action dev="ebourg" type="update" issue="35945" due-to="Steve Bate">
+ Fixed MapConfiguration to store the list of values added under a same
+ key instead of the last value added.
+ </action>
<action dev="oheger" type="update" issue="35316">
Fixed a bug in the handling of relative file names in ConfigurationFactory:
In most cases relative file names were not resolved relative to the
@@ -122,7 +126,7 @@
strategy, so no reload was performed.
</action>
<action dev="oheger" type="update" issue="34410">
- Disabled auto save mode during PropertiesCconfiguration.load(). Prior
+ Disabled auto save mode during PropertiesConfiguration.load(). Prior
it was possible that the properties file to be loaded was immideately
overwritten.
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org