You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/07/11 22:20:33 UTC
svn commit: r1609797 - in /commons/proper/configuration/trunk/src:
main/java/org/apache/commons/configuration/
main/java/org/apache/commons/configuration/event/
test/java/org/apache/commons/configuration/event/
Author: oheger
Date: Fri Jul 11 20:20:33 2014
New Revision: 1609797
URL: http://svn.apache.org/r1609797
Log:
Added event type constants for hierarchical configuration events.
The existing numeric constants in AbstractHierarchicalConfiguration have been
(temporarily) deprecated before they are eventually removed.
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java?rev=1609797&r1=1609796&r2=1609797&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java Fri Jul 11 20:20:33 2014
@@ -120,15 +120,16 @@ import org.apache.commons.configuration.
* {@link org.apache.commons.configuration.tree.xpath.XPathExpressionEngine}
* there is an expression engine available that supports configuration keys in
* XPATH syntax.</p>
- * <p>In addition to the events common for all configuration classes hierarchical
+ * <p>In addition to the events common for all configuration classes, hierarchical
* configurations support some more events that correspond to some specific
- * methods and features:
- * <dl><dt><em>EVENT_ADD_NODES</em></dt><dd>The {@code addNodes()} method
+ * methods and features. For those events specific event type constants in
+ * {@code ConfigurationEvent} exist:
+ * <dl><dt><em>ADD_NODES</em></dt><dd>The {@code addNodes()} method
* was called; the event object contains the key, to which the nodes were added,
* and a collection with the new nodes as value.</dd>
- * <dt><em>EVENT_CLEAR_TREE</em></dt><dd>The {@code clearTree()} method was
+ * <dt><em>CLEAR_TREE</em></dt><dd>The {@code clearTree()} method was
* called; the event object stores the key of the removed sub tree.</dd>
- * <dt><em>EVENT_SUBNODE_CHANGED</em></dt><dd>A {@code SubnodeConfiguration}
+ * <dt><em>SUBNODE_CHANGED</em></dt><dd>A {@code SubnodeConfiguration}
* that was created from this configuration has been changed. The value property
* of the event object contains the original event object as it was sent by the
* subnode configuration.</dd></dl></p>
@@ -164,19 +165,25 @@ public abstract class AbstractHierarchic
/**
* Constant for the clear tree event.
* @since 1.3
+ * @deprecated Use the event type constant in {@code ConfigurationEvent}
*/
+ @Deprecated
public static final int EVENT_CLEAR_TREE = 10;
/**
* Constant for the add nodes event.
* @since 1.3
+ * @deprecated Use the event type constant in {@code ConfigurationEvent}
*/
+ @Deprecated
public static final int EVENT_ADD_NODES = 11;
/**
* Constant for the subnode configuration modified event.
+ * @deprecated Use the event type constant in {@code ConfigurationEvent}
* @since 1.5
*/
+ @Deprecated
public static final int EVENT_SUBNODE_CHANGED = 12;
/** The model for managing the data stored in this configuration. */
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java?rev=1609797&r1=1609796&r2=1609797&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/ConfigurationEvent.java Fri Jul 11 20:20:33 2014
@@ -117,6 +117,41 @@ public class ConfigurationEvent extends
public static final EventType<ConfigurationEvent> CLEAR =
new EventType<ConfigurationEvent>(ANY, "CLEAR");
+ /**
+ * Constant for the common base event type for all hierarchical update
+ * events. Events derived from this type are generated by some specific
+ * methods of hierarchical configurations.
+ *
+ * @since 2.0
+ */
+ public static final EventType<ConfigurationEvent> ANY_HIERARCHICAL =
+ new EventType<ConfigurationEvent>(ANY, "HIERARCHICAL");
+
+ /**
+ * Constant for the event type for an add nodes operation.
+ *
+ * @since 2.0
+ */
+ public static final EventType<ConfigurationEvent> ADD_NODES =
+ new EventType<ConfigurationEvent>(ANY_HIERARCHICAL, "ADD_NODES");
+
+ /**
+ * Constant for the event type for a clear tree operation.
+ *
+ * @since 2.0
+ */
+ public static final EventType<ConfigurationEvent> CLEAR_TREE =
+ new EventType<ConfigurationEvent>(ANY_HIERARCHICAL, "CLEAR_TREE");
+
+ /**
+ * Constant for the event type indicating a change on a sub configuration.
+ *
+ * @since 2.0
+ */
+ public static final EventType<ConfigurationEvent> SUBNODE_CHANGED =
+ new EventType<ConfigurationEvent>(ANY_HIERARCHICAL,
+ "SUBNODE_CHANGED");
+
/** The legacy event type. */
private final int type;
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java?rev=1609797&r1=1609796&r2=1609797&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestConfigurationEventTypes.java Fri Jul 11 20:20:33 2014
@@ -85,4 +85,52 @@ public class TestConfigurationEventTypes
{
checkUpdateEvent(ConfigurationEvent.CLEAR);
}
+
+ /**
+ * Tests the common base event type for hierarchical update events.
+ */
+ @Test
+ public void testHierarchicalEventType()
+ {
+ checkUpdateEvent(ConfigurationEvent.ANY_HIERARCHICAL);
+ }
+
+ /**
+ * Helper method for checking the relevant properties of a given event type
+ * representing a hierarchical update event.
+ *
+ * @param eventType the event type to check
+ */
+ private void checkHierarchicalEvent(EventType<ConfigurationEvent> eventType)
+ {
+ assertSame("Wrong super type for " + eventType,
+ ConfigurationEvent.ANY_HIERARCHICAL, eventType.getSuperType());
+ }
+
+ /**
+ * Tests the event type for an add nodes operation.
+ */
+ @Test
+ public void testAddNodesEventType()
+ {
+ checkHierarchicalEvent(ConfigurationEvent.ADD_NODES);
+ }
+
+ /**
+ * Tests the event type for a clear tree operation.
+ */
+ @Test
+ public void testClearTreeEventType()
+ {
+ checkHierarchicalEvent(ConfigurationEvent.CLEAR_TREE);
+ }
+
+ /**
+ * Tests the event type indicating a change on a sub configuration.
+ */
+ @Test
+ public void testSubnodeChangedEventType()
+ {
+ checkHierarchicalEvent(ConfigurationEvent.SUBNODE_CHANGED);
+ }
}