commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r801810 - in /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base: AbstractHierarchicalConfigurationSource.java ConfigurationSource.java
Date Thu, 06 Aug 2009 20:21:08 GMT
Author: oheger
Date: Thu Aug  6 20:21:08 2009
New Revision: 801810

URL: http://svn.apache.org/viewvc?rev=801810&view=rev
Log:
Added methods for registering event listeners to ConfigurationSource. Removed the method for
setting a collection property.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/AbstractHierarchicalConfigurationSource.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/AbstractHierarchicalConfigurationSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/AbstractHierarchicalConfigurationSource.java?rev=801810&r1=801809&r2=801810&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/AbstractHierarchicalConfigurationSource.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/AbstractHierarchicalConfigurationSource.java
Thu Aug  6 20:21:08 2009
@@ -276,7 +276,7 @@
                 Object value = nodes.getValue(i, getNodeHandler());
                 if (value != null)
                 {
-                    if (nodes.isAttribute(i) && value instanceof Collection)
+                    if (nodes.isAttribute(i) && value instanceof Collection<?>)
                     {
                         // there may be multiple values
                         list.addAll((Collection<?>) value);
@@ -413,7 +413,7 @@
         for (int index = 0; index < nodes.size(); index++)
         {
             Object value = nodes.getValue(index, getNodeHandler());
-            if (value instanceof Collection)
+            if (value instanceof Collection<?>)
             {
                 // if there are multiple values, count them all
                 cnt += ((Collection<?>) value).size();
@@ -450,6 +450,34 @@
     }
 
     /**
+     * Adds a listener to this configuration source. This implementation does
+     * not support event notifications, so an exception is thrown.
+     *
+     * @param l the listener to be added
+     * @throws UnsupportedOperationException because this operation is not
+     *         supported
+     */
+    public void addConfigurationSourceListener(ConfigurationSourceListener l)
+    {
+        throw new UnsupportedOperationException("Not implemented!");
+    }
+
+    /**
+     * Removes a listener from this configuration source. This implementation
+     * does not support event notifications, so an exception is thrown.
+     *
+     * @param l the listener to be removed
+     * @return a flag whether the listener could be removed
+     * @throws UnsupportedOperationException because this operation is not
+     *         supported
+     */
+    public boolean removeConfigurationSourceListener(
+            ConfigurationSourceListener l)
+    {
+        throw new UnsupportedOperationException("Not implemented!");
+    }
+
+    /**
      * The actual implementation of the traversal of all nodes. This method is
      * called by {@link #visit(Object, NodeVisitor)}.
      *
@@ -683,7 +711,7 @@
             for (String attr : handler.getAttributes(node))
             {
                 Object value = handler.getAttributeValue(node, attr);
-                if (value instanceof Collection)
+                if (value instanceof Collection<?>)
                 {
                     count += ((Collection<?>) value).size();
                 }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java?rev=801810&r1=801809&r2=801810&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
Thu Aug  6 20:21:08 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.configuration2.base;
 
-import java.util.Collection;
 import java.util.Iterator;
 
 /**
@@ -120,16 +119,6 @@
     void setProperty(String key, Object value);
 
     /**
-     * Sets multiple values for a property. Any previously set values will be
-     * replaced. The new value of this property will be constructed from all
-     * values stored in the given collection.
-     *
-     * @param key the key of the property to change
-     * @param values a collection with the new values of this property
-     */
-    void setProperty(String key, Collection<?> values);
-
-    /**
      * Removes a property from the configuration.
      *
      * @param key the key to remove along with corresponding value.
@@ -220,4 +209,34 @@
      * @see #getProperty(String)
      */
     int valueCount(String key);
+
+    /**
+     * Adds a {@code ConfigurationSourceListener} for this {@code
+     * ConfigurationSource}. This listener will be notified about manipulations
+     * on this source. Support for event listeners is optional. An
+     * implementation can throw an {@code UnsupportedOperationException}
+     * exception. By using a wrapper that supports event notifications it is
+     * possible to monitor such a {@code ConfigurationSource}.
+     *
+     * @param l the listener to be added (must not be <b>null</b>)
+     * @throws IllegalArgumentException if the listener is <b>null</b>
+     * @throws UnsupportedOperationException if this operation is not
+     *         implemented
+     */
+    void addConfigurationSourceListener(ConfigurationSourceListener l);
+
+    /**
+     * Removes the specified {@code ConfigurationSourceListener} from this
+     * {@code ConfigurationSource}. It will not receive notifications about
+     * changes on this source any more. The return value indicates whether the
+     * listener existed and could be removed. As was pointed out for
+     * {@link #addConfigurationSourceListener(ConfigurationSourceListener)},
+     * this is an optional operation.
+     *
+     * @param l the listener to be removed
+     * @return a flag whether the listener could be removed
+     * @throws UnsupportedOperationException if this operation is not
+     *         implemented
+     */
+    boolean removeConfigurationSourceListener(ConfigurationSourceListener l);
 }



Mime
View raw message