commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r494581 - in /jakarta/commons/proper/configuration/trunk/src: java/org/apache/commons/configuration/CompositeConfiguration.java test/org/apache/commons/configuration/TestCompositeConfiguration.java
Date Tue, 09 Jan 2007 21:14:21 GMT
Author: oheger
Date: Tue Jan  9 13:14:20 2007
New Revision: 494581

URL: http://svn.apache.org/viewvc?view=rev&rev=494581
Log:
CONFIGURATION-155: Incorporate instance list delimiters to CompositeConfiguration

Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java?view=diff&rev=494581&r1=494580&r2=494581
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/CompositeConfiguration.java
Tue Jan  9 13:14:20 2007
@@ -158,6 +158,8 @@
         // recreate the in memory configuration
         inMemoryConfiguration = new BaseConfiguration();
         ((BaseConfiguration) inMemoryConfiguration).setThrowExceptionOnMissing(isThrowExceptionOnMissing());
+        ((BaseConfiguration) inMemoryConfiguration).setListDelimiter(getListDelimiter());
+        ((BaseConfiguration) inMemoryConfiguration).setDelimiterParsingDisabled(isDelimiterParsingDisabled());
         configList.add(inMemoryConfiguration);
     }
 
@@ -410,5 +412,34 @@
             // cannot happen
             throw new ConfigurationRuntimeException(cnex);
         }
+    }
+
+    /**
+     * Sets a flag whether added values for string properties should be checked
+     * for the list delimiter. This implementation ensures that the in memory
+     * configuration is correctly initialized.
+     *
+     * @param delimiterParsingDisabled the new value of the flag
+     * @since 1.4
+     */
+    public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)
+    {
+        ((BaseConfiguration) getInMemoryConfiguration())
+                .setDelimiterParsingDisabled(delimiterParsingDisabled);
+        super.setDelimiterParsingDisabled(delimiterParsingDisabled);
+    }
+
+    /**
+     * Sets the character that is used as list delimiter. This implementation
+     * ensures that the in memory configuration is correctly initialized.
+     *
+     * @param listDelimiter the new list delimiter character
+     * @since 1.4
+     */
+    public void setListDelimiter(char listDelimiter)
+    {
+        ((BaseConfiguration) getInMemoryConfiguration())
+                .setListDelimiter(listDelimiter);
+        super.setListDelimiter(listDelimiter);
     }
 }

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java?view=diff&rev=494581&r1=494580&r2=494581
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestCompositeConfiguration.java
Tue Jan  9 13:14:20 2007
@@ -559,6 +559,70 @@
     }
 
     /**
+     * Tests chaning the list delimiter character.
+     */
+    public void testSetListDelimiter()
+    {
+        cc.setListDelimiter('/');
+        checkSetListDelimiter();
+    }
+
+    /**
+     * Tests whether the correct list delimiter is set after a clear operation.
+     */
+    public void testSetListDelimiterAfterClear()
+    {
+        cc.setListDelimiter('/');
+        cc.clear();
+        checkSetListDelimiter();
+    }
+
+    /**
+     * Helper method for testing whether the list delimiter is correctly
+     * handled.
+     */
+    private void checkSetListDelimiter()
+    {
+        cc.addProperty("test.list", "a/b/c");
+        cc.addProperty("test.property", "a,b,c");
+        assertEquals("Wrong number of list elements", 3, cc
+                .getList("test.list").size());
+        assertEquals("Wrong value of property", "a,b,c", cc
+                .getString("test.property"));
+    }
+
+    /**
+     * Tests whether list splitting can be disabled.
+     */
+    public void testSetDelimiterParsingDisabled()
+    {
+        cc.setDelimiterParsingDisabled(true);
+        checkSetListDelimiterParsingDisabled();
+    }
+
+    /**
+     * Tests whether the list parsing flag is correctly handled after a clear()
+     * operation.
+     */
+    public void testSetDelimiterParsingDisabledAfterClear()
+    {
+        cc.setDelimiterParsingDisabled(true);
+        cc.clear();
+        checkSetListDelimiterParsingDisabled();
+    }
+
+    /**
+     * Helper method for checking whether the list parsing flag is correctly
+     * handled.
+     */
+    private void checkSetListDelimiterParsingDisabled()
+    {
+        cc.addProperty("test.property", "a,b,c");
+        assertEquals("Wrong value of property", "a,b,c", cc
+                .getString("test.property"));
+    }
+
+    /**
      * A test configuration event listener that counts the number of received
      * events. Used for testing the event facilities.
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message