You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oh...@apache.org on 2005/11/14 18:10:08 UTC

svn commit: r344160 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ConfigurationMap.java src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java xdocs/changes.xml

Author: oheger
Date: Mon Nov 14 09:09:48 2005
New Revision: 344160

URL: http://svn.apache.org/viewcvs?rev=344160&view=rev
Log:
ConfigurationDynaBean now implements the Map interface; fix for issue 37486

Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
    jakarta/commons/proper/configuration/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java?rev=344160&r1=344159&r2=344160&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationMap.java Mon Nov 14 09:09:48 2005
@@ -42,6 +42,17 @@
     Configuration configuration;
 
     /**
+     * Returns the wrapped <code>Configuration</code> object.
+     *
+     * @return the wrapped configuration
+     * @since 1.2
+     */
+    public Configuration getConfiguration()
+    {
+        return configuration;
+    }
+
+    /**
      * Creates a new instance of a <code>ConfigurationMap</code>
      * that wraps the specified <code>Configuration</code>
      * instance.

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java?rev=344160&r1=344159&r2=344160&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java Mon Nov 14 09:09:48 2005
@@ -22,6 +22,7 @@
 import org.apache.commons.beanutils.DynaBean;
 import org.apache.commons.beanutils.DynaClass;
 import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationMap;
 import org.apache.commons.configuration.ConversionException;
 import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.logging.Log;
@@ -46,14 +47,11 @@
  * @version $Revision$, $Date$
  * @since 1.0-rc1
  */
-public class ConfigurationDynaBean implements DynaBean
+public class ConfigurationDynaBean extends ConfigurationMap implements DynaBean
 {
     /** The logger.*/
     private static Log log = LogFactory.getLog(ConfigurationDynaBean.class);
 
-    /** Stores the associated configuration instance.*/
-    Configuration configuration;
-
     /**
      * Creates a new instance of <code>ConfigurationDynaBean</code> and sets
      * the configuration this bean is associated with.
@@ -61,12 +59,11 @@
      */
     public ConfigurationDynaBean(Configuration configuration)
     {
+        super(configuration);
         if (log.isTraceEnabled())
         {
             log.trace("ConfigurationDynaBean(" + configuration + ")");
         }
-
-        this.configuration = configuration;
     }
 
     /**
@@ -90,7 +87,7 @@
             Iterator iterator = list.iterator();
             while (iterator.hasNext())
             {
-                configuration.addProperty(name, iterator.next());
+                getConfiguration().addProperty(name, iterator.next());
             }
         }
         else if (value instanceof int[])
@@ -98,7 +95,7 @@
             int[] array = (int[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Integer(array[i]));
+                getConfiguration().addProperty(name, new Integer(array[i]));
             }
         }
         else if (value instanceof boolean[])
@@ -106,7 +103,7 @@
             boolean[] array = (boolean[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, BooleanUtils.toBooleanObject(array[i]));
+                getConfiguration().addProperty(name, BooleanUtils.toBooleanObject(array[i]));
             }
         }
         else if (value instanceof char[])
@@ -114,7 +111,7 @@
             char[] array = (char[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Character(array[i]));
+                getConfiguration().addProperty(name, new Character(array[i]));
             }
         }
         else if (value instanceof byte[])
@@ -122,7 +119,7 @@
             byte[] array = (byte[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Byte(array[i]));
+                getConfiguration().addProperty(name, new Byte(array[i]));
             }
         }
         else if (value instanceof short[])
@@ -130,7 +127,7 @@
             short[] array = (short[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Short(array[i]));
+                getConfiguration().addProperty(name, new Short(array[i]));
             }
         }
         else if (value instanceof long[])
@@ -138,7 +135,7 @@
             long[] array = (long[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Long(array[i]));
+                getConfiguration().addProperty(name, new Long(array[i]));
             }
         }
         else if (value instanceof float[])
@@ -146,7 +143,7 @@
             float[] array = (float[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Float(array[i]));
+                getConfiguration().addProperty(name, new Float(array[i]));
             }
         }
         else if (value instanceof double[])
@@ -154,7 +151,7 @@
             double[] array = (double[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, new Double(array[i]));
+                getConfiguration().addProperty(name, new Double(array[i]));
             }
         }
         else if (value instanceof Object[])
@@ -162,12 +159,12 @@
             Object[] array = (Object[]) value;
             for (int i = 0; i < array.length; i++)
             {
-                configuration.addProperty(name, array[i]);
+                getConfiguration().addProperty(name, array[i]);
             }
         }
         else
         {
-            configuration.setProperty(name, value);
+            getConfiguration().setProperty(name, value);
         }
     }
 
@@ -182,14 +179,14 @@
         }
 
         // get configuration property
-        Object result = configuration.getProperty(name);
+        Object result = getConfiguration().getProperty(name);
         if (result == null)
         {
             // otherwise attempt to create bean from configuration subset
-            Configuration subset = configuration.subset(name);
+            Configuration subset = getConfiguration().subset(name);
             if (!subset.isEmpty())
             {
-                result = new ConfigurationDynaBean(configuration.subset(name));
+                result = new ConfigurationDynaBean(getConfiguration().subset(name));
             }
         }
 
@@ -210,7 +207,7 @@
      */
     public boolean contains(String name, String key)
     {
-        Configuration subset = configuration.subset(name);
+        Configuration subset = getConfiguration().subset(name);
         if (subset == null)
         {
             throw new IllegalArgumentException("Mapped property '" + name + "' does not exist.");
@@ -226,7 +223,7 @@
     {
         try
         {
-            List list = configuration.getList(name);
+            List list = getConfiguration().getList(name);
             if (list.isEmpty())
             {
                 throw new IllegalArgumentException("Indexed property '" + name + "' does not exist.");
@@ -245,7 +242,7 @@
      */
     public Object get(String name, String key)
     {
-        Configuration subset = configuration.subset(name);
+        Configuration subset = getConfiguration().subset(name);
         if (subset == null)
         {
             throw new IllegalArgumentException("Mapped property '" + name + "' does not exist.");
@@ -259,7 +256,7 @@
      */
     public DynaClass getDynaClass()
     {
-        return new ConfigurationDynaClass(configuration);
+        return new ConfigurationDynaClass(getConfiguration());
     }
 
     /**
@@ -267,7 +264,7 @@
      */
     public void remove(String name, String key)
     {
-        Configuration subset = configuration.subset(name);
+        Configuration subset = getConfiguration().subset(name);
         if (subset == null)
         {
             throw new IllegalArgumentException("Mapped property '" + name + "' does not exist.");
@@ -282,7 +279,7 @@
     {
         try
         {
-            Object property = configuration.getProperty(name);
+            Object property = getConfiguration().getProperty(name);
 
             if (property == null)
             {
@@ -300,7 +297,7 @@
             }
             else if (index == 0)
             {
-                configuration.setProperty(name, value);
+                getConfiguration().setProperty(name, value);
             }
             else
             {
@@ -318,7 +315,7 @@
      */
     public void set(String name, String key, Object value)
     {
-        configuration.setProperty(name + "." + key, value);
+        getConfiguration().setProperty(name + "." + key, value);
     }
 
 }

Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=344160&r1=344159&r2=344160&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Mon Nov 14 09:09:48 2005
@@ -23,6 +23,14 @@
   <body>
 
     <release version="1.2-dev" date="in SVN">
+      <action dev="oheger" type="update" issue="37486">
+        ConfigurationDynaBean now implements the java.util.Map interface (as
+        was stated in the javadocs). This was done by deriving the class from
+        ConfigurationMap.
+      </action>
+    </release>
+    
+    <release version="1.2-rc1" date="2005-11-11">
       <action dev="oheger" type="update" issue="36665">
         The reload() method in AbstractFileConfiguration was updated to prevent
         reentrant invocation, which may be caused by some methods when they



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