commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1102402 [9/20] - in /commons/sandbox/digester3/trunk/src: main/java/org/apache/commons/digester3/ main/java/org/apache/commons/digester3/annotations/ main/java/org/apache/commons/digester3/annotations/handlers/ main/java/org/apache/commons...
Date Thu, 12 May 2011 18:03:33 GMT
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/LogUtils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/LogUtils.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/LogUtils.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/LogUtils.java Thu May 12 18:03:26 2011
@@ -23,51 +23,44 @@ import org.apache.commons.logging.Log;
 /**
  * Simple utility class to assist in logging.
  * <p>
- * This class is intended only for the use of the code in the
- * plugins packages. No "user" code should use this package.
+ * This class is intended only for the use of the code in the plugins packages. No "user" code should use this package.
  * <p>
- * The Digester module has an interesting approach to logging:
- * all logging should be done via the Log object stored on the
- * digester instance that the object *doing* the logging is associated
- * with.
+ * The Digester module has an interesting approach to logging: all logging should be done via the Log object stored on
+ * the digester instance that the object *doing* the logging is associated with.
  * <p>
- * This is done because apparently some "container"-type applications
- * such as Avalon and Tomcat need to be able to configure different logging
- * for different <i>instances</i> of the Digester class which have been
- * loaded from the same ClassLoader [info from Craig McClanahan]. 
- * Not only the logging of the Digester instance should be affected; all 
- * objects associated with that Digester instance should obey the 
- * reconfiguration of their owning Digester instance's logging. The current 
- * solution is to force all objects to output logging info via a single 
- * Log object stored on the Digester instance they are associated with.
+ * This is done because apparently some "container"-type applications such as Avalon and Tomcat need to be able to
+ * configure different logging for different <i>instances</i> of the Digester class which have been loaded from the same
+ * ClassLoader [info from Craig McClanahan]. Not only the logging of the Digester instance should be affected; all
+ * objects associated with that Digester instance should obey the reconfiguration of their owning Digester instance's
+ * logging. The current solution is to force all objects to output logging info via a single Log object stored on the
+ * Digester instance they are associated with.
  * <p>
- * Of course this causes problems if logging is attempted before an
- * object <i>has</i> a valid reference to its owning Digester. The 
- * getLogging method provided here resolves this issue by returning a
- * Log object which silently discards all logging output in this
- * situation.
+ * Of course this causes problems if logging is attempted before an object <i>has</i> a valid reference to its owning
+ * Digester. The getLogging method provided here resolves this issue by returning a Log object which silently discards
+ * all logging output in this situation.
  * <p>
- * And it also implies that logging filtering can no longer be applied
- * to subcomponents of the Digester, because all logging is done via
- * a single Log object (a single Category). C'est la vie...
- *
+ * And it also implies that logging filtering can no longer be applied to subcomponents of the Digester, because all
+ * logging is done via a single Log object (a single Category). C'est la vie...
+ * 
  * @since 1.6
  */
 
-class LogUtils {
-    
-  /**
-   * Get the Log object associated with the specified Digester instance,
-   * or a "no-op" logging object if the digester reference is null.
-   * <p>
-   * You should use this method instead of digester.getLogger() in
-   * any situation where the digester might be null.
-   */
-  static Log getLogger(Digester digester) {
-    if (digester == null) {
-        return new org.apache.commons.logging.impl.NoOpLog();
+class LogUtils
+{
+
+    /**
+     * Get the Log object associated with the specified Digester instance, or a "no-op" logging object if the digester
+     * reference is null.
+     * <p>
+     * You should use this method instead of digester.getLogger() in any situation where the digester might be null.
+     */
+    static Log getLogger( Digester digester )
+    {
+        if ( digester == null )
+        {
+            return new org.apache.commons.logging.impl.NoOpLog();
+        }
+
+        return digester.getLogger();
     }
-    
-    return digester.getLogger();
-  }
 }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginAssertionFailure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginAssertionFailure.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginAssertionFailure.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginAssertionFailure.java Thu May 12 18:03:26 2011
@@ -21,67 +21,70 @@ package org.apache.commons.digester3.plu
 /**
  * Thrown when a bug is detected in the plugins code.
  * <p>
- * This class is intended to be used in assertion statements, similar to
- * the way that java 1.4's native assertion mechanism is used. However there
- * is a difference: when a java 1.4 assertion fails, an AssertionError
- * is thrown, which is a subclass of Error; here, the PluginAssertionFailure
- * class extends RuntimeException rather than Error.
+ * This class is intended to be used in assertion statements, similar to the way that java 1.4's native assertion
+ * mechanism is used. However there is a difference: when a java 1.4 assertion fails, an AssertionError is thrown, which
+ * is a subclass of Error; here, the PluginAssertionFailure class extends RuntimeException rather than Error.
  * <p>
- * This difference in design is because throwing Error objects is not
- * good in a container-based architecture.
+ * This difference in design is because throwing Error objects is not good in a container-based architecture.
  * <p>
  * Example:
+ * 
  * <pre>
- *   if (impossibleCondition) {
- *     throw new PluginAssertionFailure(
- *       "internal error: impossible condition is true");
- *   }
- * </pre> 
+ * if ( impossibleCondition )
+ * {
+ *     throw new PluginAssertionFailure( &quot;internal error: impossible condition is true&quot; );
+ * }
+ * </pre>
  * <p>
- * Note that PluginAssertionFailure should <i>not</i> be thrown when user 
- * input is bad, or when code external to the Digester module passes invalid 
- * parameters to a plugins method. It should be used only in checks for 
- * problems which indicate internal bugs within the plugins module.
- *
+ * Note that PluginAssertionFailure should <i>not</i> be thrown when user input is bad, or when code external to the
+ * Digester module passes invalid parameters to a plugins method. It should be used only in checks for problems which
+ * indicate internal bugs within the plugins module.
+ * 
  * @since 1.6
  */
-public class PluginAssertionFailure extends RuntimeException {
+public class PluginAssertionFailure
+    extends RuntimeException
+{
 
     private static final long serialVersionUID = 1L;
+
     private Throwable cause = null;
 
     /**
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginAssertionFailure(Throwable cause) {
-        this(cause.getMessage());
+    public PluginAssertionFailure( Throwable cause )
+    {
+        this( cause.getMessage() );
         this.cause = cause;
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      */
-    public PluginAssertionFailure(String msg) {
-        super(msg);
+    public PluginAssertionFailure( String msg )
+    {
+        super( msg );
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginAssertionFailure(String msg, Throwable cause) {
-        this(msg);
+    public PluginAssertionFailure( String msg, Throwable cause )
+    {
+        this( msg );
         this.cause = cause;
     }
-    
+
     /**
-     * Return the cause of this exception (if any) as specified in the
-     * exception constructor.
+     * Return the cause of this exception (if any) as specified in the exception constructor.
      * 
      * @since 1.8
      */
     @Override
-    public Throwable getCause() {
+    public Throwable getCause()
+    {
         return cause;
     }
 }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginConfigurationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginConfigurationException.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginConfigurationException.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginConfigurationException.java Thu May 12 18:03:26 2011
@@ -19,52 +19,56 @@
 package org.apache.commons.digester3.plugins;
 
 /**
- * Thrown when an error occurs due to the way the calling application uses
- * the plugins module. Because the pre-existing Digester API doesn't provide
- * any option for throwing checked exceptions at some points where Plugins
- * can potentially fail, this exception extends RuntimeException so that it
- * can "tunnel" through these points.
- *
+ * Thrown when an error occurs due to the way the calling application uses the plugins module. Because the pre-existing
+ * Digester API doesn't provide any option for throwing checked exceptions at some points where Plugins can potentially
+ * fail, this exception extends RuntimeException so that it can "tunnel" through these points.
+ * 
  * @since 1.6
  */
 
-public class PluginConfigurationException extends RuntimeException {
+public class PluginConfigurationException
+    extends RuntimeException
+{
 
     private static final long serialVersionUID = 1L;
+
     private Throwable cause = null;
 
     /**
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginConfigurationException(Throwable cause) {
-        this(cause.getMessage());
+    public PluginConfigurationException( Throwable cause )
+    {
+        this( cause.getMessage() );
         this.cause = cause;
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      */
-    public PluginConfigurationException(String msg) {
-        super(msg);
+    public PluginConfigurationException( String msg )
+    {
+        super( msg );
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginConfigurationException(String msg, Throwable cause) {
-        this(msg);
+    public PluginConfigurationException( String msg, Throwable cause )
+    {
+        this( msg );
         this.cause = cause;
     }
 
     /**
-     * Return the cause of this exception (if any) as specified in the
-     * exception constructor.
+     * Return the cause of this exception (if any) as specified in the exception constructor.
      * 
      * @since 1.8
      */
     @Override
-    public Throwable getCause() {
+    public Throwable getCause()
+    {
         return cause;
     }
 }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginContext.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginContext.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginContext.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginContext.java Thu May 12 18:03:26 2011
@@ -32,33 +32,34 @@ import org.apache.commons.digester3.plug
 /**
  * Provides data and services which should exist only once per digester.
  * <p>
- * This class holds a number of useful items which should be shared by all
- * plugin objects. Such data cannot be stored on the PluginRules or 
- * PluginManager classes, as there can be multiple instances of these at 
- * various times during a parse. 
+ * This class holds a number of useful items which should be shared by all plugin objects. Such data cannot be stored on
+ * the PluginRules or PluginManager classes, as there can be multiple instances of these at various times during a
+ * parse.
  * <p>
- * The name "Context" refers to the similarity between this class and a
- * ServletContext class in a servlet engine. A ServletContext object provides
- * access to the container's services such as obtaining global configuration
- * parameters for the container, or getting access to logging services. For
- * plugins, a Digester instance can be regarded as "the container".
- *
+ * The name "Context" refers to the similarity between this class and a ServletContext class in a servlet engine. A
+ * ServletContext object provides access to the container's services such as obtaining global configuration parameters
+ * for the container, or getting access to logging services. For plugins, a Digester instance can be regarded as
+ * "the container".
+ * 
  * @since 1.6
  */
 
-public class PluginContext {
+public class PluginContext
+{
 
     // TODO: Consider making following four constants static in 2.0
     // the xml attribute the user uses on an xml element to specify
     // the plugin's class
     public final String DFLT_PLUGIN_CLASS_ATTR_NS = null;
+
     public final String DFLT_PLUGIN_CLASS_ATTR = "plugin-class";
 
     // the xml attribute the user uses on an xml element to specify
     // the plugin's class
     public final String DFLT_PLUGIN_ID_ATTR_NS = null;
+
     public final String DFLT_PLUGIN_ID_ATTR = "plugin-id";
-    
+
     /** See {@link #setPluginClassAttribute}. */
     private String pluginClassAttrNs = DFLT_PLUGIN_CLASS_ATTR_NS;
 
@@ -70,178 +71,182 @@ public class PluginContext {
 
     /** See {@link #setPluginClassAttribute}. */
     private String pluginIdAttr = DFLT_PLUGIN_ID_ATTR;
-    
-    /** 
-     * A list of RuleFinder objects used by all Declarations (and thus
-     * indirectly by all PluginCreateRules to locate the custom rules
-     * for plugin classes.
+
+    /**
+     * A list of RuleFinder objects used by all Declarations (and thus indirectly by all PluginCreateRules to locate the
+     * custom rules for plugin classes.
      */
     private List<RuleFinder> ruleFinders;
 
-    //------------------- constructors ---------------------------------------
-    
-    public PluginContext() {
+    // ------------------- constructors ---------------------------------------
+
+    public PluginContext()
+    {
     }
-    
-    //------------------- methods ---------------------------------------
+
+    // ------------------- methods ---------------------------------------
 
     /**
-     * Return the list of RuleFinder objects. Under normal circumstances
-     * this method creates a default list of these objects when first called
-     * (ie "on-demand" or "lazy initialization"). However if setRuleFinders
-     * has been called first, then the list specified there is returned.
+     * Return the list of RuleFinder objects. Under normal circumstances this method creates a default list of these
+     * objects when first called (ie "on-demand" or "lazy initialization"). However if setRuleFinders has been called
+     * first, then the list specified there is returned.
      * <p>
-     * It is explicitly permitted for the caller to modify this list
-     * by inserting or removing RuleFinder objects.
+     * It is explicitly permitted for the caller to modify this list by inserting or removing RuleFinder objects.
      */
-    public List<RuleFinder> getRuleFinders() {
-        if (ruleFinders == null) {
+    public List<RuleFinder> getRuleFinders()
+    {
+        if ( ruleFinders == null )
+        {
             // when processing a plugin declaration, attempts are made to
             // find custom rules in the order in which the Finder objects
             // are added below. However this list can be modified
             ruleFinders = new LinkedList<RuleFinder>();
-            ruleFinders.add(new FinderFromFile());
-            ruleFinders.add(new FinderFromResource());
-            ruleFinders.add(new FinderFromClass());
-            ruleFinders.add(new FinderFromMethod());
-            ruleFinders.add(new FinderFromDfltMethod());
-            ruleFinders.add(new FinderFromDfltClass());
-            ruleFinders.add(new FinderFromDfltResource());
-            ruleFinders.add(new FinderFromDfltResource(".xml"));
-            ruleFinders.add(new FinderSetProperties());
+            ruleFinders.add( new FinderFromFile() );
+            ruleFinders.add( new FinderFromResource() );
+            ruleFinders.add( new FinderFromClass() );
+            ruleFinders.add( new FinderFromMethod() );
+            ruleFinders.add( new FinderFromDfltMethod() );
+            ruleFinders.add( new FinderFromDfltClass() );
+            ruleFinders.add( new FinderFromDfltResource() );
+            ruleFinders.add( new FinderFromDfltResource( ".xml" ) );
+            ruleFinders.add( new FinderSetProperties() );
         }
         return ruleFinders;
     }
-    
+
     /**
-     * Set the list of RuleFinder objects. This may be useful if working
-     * in a non-english language, allowing the application developer to
-     * replace the standard list with a list of objects which look for xml 
-     * attributes in the local language.
-     * <p>
-     * If the intent is just to add an additional rule-finding algorithm, then
-     * it may be better to call #getRuleFinders, and insert a new object into 
-     * the start of the list.
+     * Set the list of RuleFinder objects. This may be useful if working in a non-english language, allowing the
+     * application developer to replace the standard list with a list of objects which look for xml attributes in the
+     * local language.
+     * <p>
+     * If the intent is just to add an additional rule-finding algorithm, then it may be better to call #getRuleFinders,
+     * and insert a new object into the start of the list.
      */
-    public void setRuleFinders(List<RuleFinder> ruleFinders) {
+    public void setRuleFinders( List<RuleFinder> ruleFinders )
+    {
         this.ruleFinders = ruleFinders;
     }
 
     /**
-     * Sets the xml attribute which the input xml uses to indicate to a 
-     * PluginCreateRule which class should be instantiated.
+     * Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which class should be
+     * instantiated.
      * <p>
      * Example:
+     * 
      * <pre>
-     * setPluginClassAttribute(null, "class");
+     * setPluginClassAttribute( null, &quot;class&quot; );
      * </pre>
+     * 
      * will allow this in the input xml:
+     * 
      * <pre>
      *  &lt;root&gt;
      *    &lt;some-plugin class="com.acme.widget"&gt; ......
      * </pre>
+     * 
      * instead of the default syntax:
+     * 
      * <pre>
      *  &lt;root&gt;
      *    &lt;some-plugin plugin-class="com.acme.widget"&gt; ......
      * </pre>
-     * This is particularly useful if the input xml document is not in
-     * English.
+     * 
+     * This is particularly useful if the input xml document is not in English.
      * <p>
-     * Note that the xml attributes used by PluginDeclarationRules are not
-     * affected by this method.
-     *
-     * @param namespaceUri is the namespace uri that the specified attribute
-     * is in. If the attribute is in no namespace, then this should be null.
-     * Note that if a namespace is used, the attrName value should <i>not</i>
-     * contain any kind of namespace-prefix. Note also that if you are using
-     * a non-namespace-aware parser, this parameter <i>must</i> be null.
-     *
-     * @param attrName is the attribute whose value contains the name of the
-     * class to be instantiated.
+     * Note that the xml attributes used by PluginDeclarationRules are not affected by this method.
+     * 
+     * @param namespaceUri is the namespace uri that the specified attribute is in. If the attribute is in no namespace,
+     *            then this should be null. Note that if a namespace is used, the attrName value should <i>not</i>
+     *            contain any kind of namespace-prefix. Note also that if you are using a non-namespace-aware parser,
+     *            this parameter <i>must</i> be null.
+     * @param attrName is the attribute whose value contains the name of the class to be instantiated.
      */
-    public void setPluginClassAttribute(String namespaceUri, 
-                                        String attrName) {
+    public void setPluginClassAttribute( String namespaceUri, String attrName )
+    {
         pluginClassAttrNs = namespaceUri;
         pluginClassAttr = attrName;
     }
 
     /**
-     * Sets the xml attribute which the input xml uses to indicate to a 
-     * PluginCreateRule which plugin declaration is being referenced.
+     * Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which plugin declaration is
+     * being referenced.
      * <p>
      * Example:
+     * 
      * <pre>
-     * setPluginIdAttribute(null, "id");
+     * setPluginIdAttribute( null, &quot;id&quot; );
      * </pre>
+     * 
      * will allow this in the input xml:
+     * 
      * <pre>
      *  &lt;root&gt;
      *    &lt;some-plugin id="widget"&gt; ......
      * </pre>
+     * 
      * rather than the default behaviour:
+     * 
      * <pre>
      *  &lt;root&gt;
      *    &lt;some-plugin plugin-id="widget"&gt; ......
      * </pre>
-     * This is particularly useful if the input xml document is not in
-     * English.
+     * 
+     * This is particularly useful if the input xml document is not in English.
      * <p>
-     * Note that the xml attributes used by PluginDeclarationRules are not
-     * affected by this method.
-     *
-     * @param namespaceUri is the namespace uri that the specified attribute
-     * is in. If the attribute is in no namespace, then this should be null.
-     * Note that if a namespace is used, the attrName value should <i>not</i>
-     * contain any kind of namespace-prefix. Note also that if you are using
-     * a non-namespace-aware parser, this parameter <i>must</i> be null.
-     *
-     * @param attrName is the attribute whose value contains the id of the
-     * plugin declaration to be used when instantiating an object.
+     * Note that the xml attributes used by PluginDeclarationRules are not affected by this method.
+     * 
+     * @param namespaceUri is the namespace uri that the specified attribute is in. If the attribute is in no namespace,
+     *            then this should be null. Note that if a namespace is used, the attrName value should <i>not</i>
+     *            contain any kind of namespace-prefix. Note also that if you are using a non-namespace-aware parser,
+     *            this parameter <i>must</i> be null.
+     * @param attrName is the attribute whose value contains the id of the plugin declaration to be used when
+     *            instantiating an object.
      */
-    public void setPluginIdAttribute(String namespaceUri, 
-                                     String attrName) {
+    public void setPluginIdAttribute( String namespaceUri, String attrName )
+    {
         pluginIdAttrNs = namespaceUri;
         pluginIdAttr = attrName;
     }
 
     /**
-     * Get the namespace for the xml attribute which indicates to a 
-     * PluginCreateRule which class is to be plugged in.
+     * Get the namespace for the xml attribute which indicates to a PluginCreateRule which class is to be plugged in.
      * <p>
      * May be null (in fact, normally will be).
      */
-    public String getPluginClassAttrNs() {
+    public String getPluginClassAttrNs()
+    {
         return pluginClassAttrNs;
     }
-    
+
     /**
-     * Get the namespace for the xml attribute which indicates to a 
-     * PluginCreateRule which class is to be plugged in.
+     * Get the namespace for the xml attribute which indicates to a PluginCreateRule which class is to be plugged in.
      * <p>
      * The return value is never null.
      */
-    public String getPluginClassAttr() {
+    public String getPluginClassAttr()
+    {
         return pluginClassAttr;
     }
-    
+
     /**
-     * Get the namespace for the xml attribute which indicates to a 
-     * PluginCreateRule which previous plugin declaration should be used.
+     * Get the namespace for the xml attribute which indicates to a PluginCreateRule which previous plugin declaration
+     * should be used.
      * <p>
      * May be null (in fact, normally will be).
      */
-    public String getPluginIdAttrNs() {
+    public String getPluginIdAttrNs()
+    {
         return pluginIdAttrNs;
     }
-    
+
     /**
-     * Get the namespace for the xml attribute which indicates to a 
-     * PluginCreateRule which previous plugin declaration should be used.
+     * Get the namespace for the xml attribute which indicates to a PluginCreateRule which previous plugin declaration
+     * should be used.
      * <p>
      * The return value is never null.
      */
-    public String getPluginIdAttr() {
+    public String getPluginIdAttr()
+    {
         return pluginIdAttr;
     }
 }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginCreateRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginCreateRule.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginCreateRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginCreateRule.java Thu May 12 18:03:26 2011
@@ -23,25 +23,29 @@ import org.apache.commons.digester3.Rule
 import org.apache.commons.logging.Log;
 
 /**
- * Allows the original rules for parsing the configuration file to define
- * points at which plugins are allowed, by configuring a PluginCreateRule
- * with the appropriate pattern.
- *
+ * Allows the original rules for parsing the configuration file to define points at which plugins are allowed, by
+ * configuring a PluginCreateRule with the appropriate pattern.
+ * 
  * @since 1.6
  */
-public class PluginCreateRule extends Rule implements InitializableRule {
+public class PluginCreateRule
+    extends Rule
+    implements InitializableRule
+{
 
     // see setPluginClassAttribute
     private String pluginClassAttrNs = null;
+
     private String pluginClassAttr = null;
-    
+
     // see setPluginIdAttribute
     private String pluginIdAttrNs = null;
+
     private String pluginIdAttr = null;
-    
+
     /**
-     * In order to invoke the addRules method on the plugin class correctly,
-     * we need to know the pattern which this rule is matched by.
+     * In order to invoke the addRules method on the plugin class correctly, we need to know the pattern which this rule
+     * is matched by.
      */
     private String pattern;
 
@@ -49,144 +53,140 @@ public class PluginCreateRule extends Ru
     private Class<?> baseClass = null;
 
     /**
-     * Info about optional default plugin to be used if no plugin-id is
-     * specified in the input data. This can simplify the syntax where one
-     * particular plugin is usually used.
+     * Info about optional default plugin to be used if no plugin-id is specified in the input data. This can simplify
+     * the syntax where one particular plugin is usually used.
      */
     private Declaration defaultPlugin;
 
     /**
-     * Currently, none of the Rules methods allow exceptions to be thrown.
-     * Therefore if this class cannot initialise itself properly, it cannot
-     * cause the digester to stop. Instead, we cache the exception and throw
-     * it the first time the begin() method is called.
+     * Currently, none of the Rules methods allow exceptions to be thrown. Therefore if this class cannot initialise
+     * itself properly, it cannot cause the digester to stop. Instead, we cache the exception and throw it the first
+     * time the begin() method is called.
      */
     private PluginConfigurationException initException;
 
-    //-------------------- constructors -------------------------------------
+    // -------------------- constructors -------------------------------------
 
     /**
-     * Create a plugin rule where the user <i>must</i> specify a plugin-class
-     * or plugin-id.
+     * Create a plugin rule where the user <i>must</i> specify a plugin-class or plugin-id.
      * 
-     * @param baseClass is the class which any specified plugin <i>must</i> be
-     * descended from.
+     * @param baseClass is the class which any specified plugin <i>must</i> be descended from.
      */
-    public PluginCreateRule(Class<?> baseClass) {
+    public PluginCreateRule( Class<?> baseClass )
+    {
         this.baseClass = baseClass;
     }
 
     /**
-     * Create a plugin rule where the user <i>may</i> specify a plugin.
-     * If the user doesn't specify a plugin, then the default class specified 
-     * in this constructor is used.
+     * Create a plugin rule where the user <i>may</i> specify a plugin. If the user doesn't specify a plugin, then the
+     * default class specified in this constructor is used.
      * 
-     * @param baseClass is the class which any specified plugin <i>must</i> be
-     * descended from.
-     * @param dfltPluginClass is the class which will be used if the user
-     * doesn't specify any plugin-class or plugin-id. This class will have
-     * custom rules installed for it just like a declared plugin.
+     * @param baseClass is the class which any specified plugin <i>must</i> be descended from.
+     * @param dfltPluginClass is the class which will be used if the user doesn't specify any plugin-class or plugin-id.
+     *            This class will have custom rules installed for it just like a declared plugin.
      */
-    public PluginCreateRule(Class<?> baseClass, Class<?> dfltPluginClass) {
+    public PluginCreateRule( Class<?> baseClass, Class<?> dfltPluginClass )
+    {
         this.baseClass = baseClass;
-        if (dfltPluginClass != null) {
-            defaultPlugin = new Declaration(dfltPluginClass);
+        if ( dfltPluginClass != null )
+        {
+            defaultPlugin = new Declaration( dfltPluginClass );
         }
     }
 
     /**
-     * Create a plugin rule where the user <i>may</i> specify a plugin.
-     * If the user doesn't specify a plugin, then the default class specified 
-     * in this constructor is used.
+     * Create a plugin rule where the user <i>may</i> specify a plugin. If the user doesn't specify a plugin, then the
+     * default class specified in this constructor is used.
      * 
-     * @param baseClass is the class which any specified plugin <i>must</i> be
-     * descended from.
-     * @param dfltPluginClass is the class which will be used if the user
-     * doesn't specify any plugin-class or plugin-id. This class will have
-     * custom rules installed for it just like a declared plugin.
-     * @param dfltPluginRuleLoader is a RuleLoader instance which knows how
-     * to load the custom rules associated with this default plugin.
+     * @param baseClass is the class which any specified plugin <i>must</i> be descended from.
+     * @param dfltPluginClass is the class which will be used if the user doesn't specify any plugin-class or plugin-id.
+     *            This class will have custom rules installed for it just like a declared plugin.
+     * @param dfltPluginRuleLoader is a RuleLoader instance which knows how to load the custom rules associated with
+     *            this default plugin.
      */
-    public PluginCreateRule(Class<?> baseClass, Class<?> dfltPluginClass,
-                    RuleLoader dfltPluginRuleLoader) {
+    public PluginCreateRule( Class<?> baseClass, Class<?> dfltPluginClass, RuleLoader dfltPluginRuleLoader )
+    {
 
         this.baseClass = baseClass;
-        if (dfltPluginClass != null) {
-            defaultPlugin = 
-                new Declaration(dfltPluginClass, dfltPluginRuleLoader);
+        if ( dfltPluginClass != null )
+        {
+            defaultPlugin = new Declaration( dfltPluginClass, dfltPluginRuleLoader );
         }
     }
 
-    //------------------- properties ---------------------------------------
-    
+    // ------------------- properties ---------------------------------------
+
     /**
-     * Sets the xml attribute which the input xml uses to indicate to a 
-     * PluginCreateRule which class should be instantiated.
+     * Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which class should be
+     * instantiated.
      * <p>
      * See {@link PluginRules#setPluginClassAttribute} for more info.
      */
-    public void setPluginClassAttribute(String namespaceUri, String attrName) {
+    public void setPluginClassAttribute( String namespaceUri, String attrName )
+    {
         pluginClassAttrNs = namespaceUri;
         pluginClassAttr = attrName;
     }
 
     /**
-     * Sets the xml attribute which the input xml uses to indicate to a 
-     * PluginCreateRule which plugin declaration is being referenced.
+     * Sets the xml attribute which the input xml uses to indicate to a PluginCreateRule which plugin declaration is
+     * being referenced.
      * <p>
      * See {@link PluginRules#setPluginIdAttribute} for more info.
      */
-    public void setPluginIdAttribute(String namespaceUri, String attrName) {
+    public void setPluginIdAttribute( String namespaceUri, String attrName )
+    {
         pluginIdAttrNs = namespaceUri;
         pluginIdAttr = attrName;
     }
 
-    //------------------- methods --------------------------------------------
+    // ------------------- methods --------------------------------------------
 
     /**
-     * Invoked after this rule has been added to the set of digester rules,
-     * associated with the specified pattern. Check all configuration data is
-     * valid and remember the pattern for later.
+     * Invoked after this rule has been added to the set of digester rules, associated with the specified pattern. Check
+     * all configuration data is valid and remember the pattern for later.
      * 
-     * @param matchPattern is the digester match pattern that is associated 
-     * with this rule instance, eg "root/widget".
+     * @param matchPattern is the digester match pattern that is associated with this rule instance, eg "root/widget".
      * @exception PluginConfigurationException
      */
-    public void postRegisterInit(String matchPattern)
-                                 throws PluginConfigurationException {
-        Log log = LogUtils.getLogger(getDigester());
+    public void postRegisterInit( String matchPattern )
+        throws PluginConfigurationException
+    {
+        Log log = LogUtils.getLogger( getDigester() );
         boolean debug = log.isDebugEnabled();
-        if (debug) {
-            log.debug("PluginCreateRule.postRegisterInit" + 
-                      ": rule registered for pattern [" + matchPattern + "]");
+        if ( debug )
+        {
+            log.debug( "PluginCreateRule.postRegisterInit" + ": rule registered for pattern [" + matchPattern + "]" );
         }
 
-        if (getDigester() == null) {
+        if ( getDigester() == null )
+        {
             // We require setDigester to be called before this method.
             // Note that this means that PluginCreateRule cannot be added
             // to a Rules object which has not yet been added to a
             // Digester object.
-            initException = new PluginConfigurationException(
-                 "Invalid invocation of postRegisterInit" + 
-                 ": digester not set.");
+            initException =
+                new PluginConfigurationException( "Invalid invocation of postRegisterInit" + ": digester not set." );
             throw initException;
         }
 
-        if (pattern != null) {
+        if ( pattern != null )
+        {
             // We have been called twice, ie a single instance has been
             // associated with multiple patterns.
             //
-            // Generally, Digester Rule instances can be associated with 
-            // multiple patterns. However for plugins, this creates some 
-            // complications. Some day this may be supported; however for 
+            // Generally, Digester Rule instances can be associated with
+            // multiple patterns. However for plugins, this creates some
+            // complications. Some day this may be supported; however for
             // now we just reject this situation.
-            initException = new PluginConfigurationException(
-               "A single PluginCreateRule instance has been mapped to" + 
-                 " multiple patterns; this is not supported.");
+            initException =
+                new PluginConfigurationException( "A single PluginCreateRule instance has been mapped to"
+                    + " multiple patterns; this is not supported." );
             throw initException;
         }
 
-        if (matchPattern.indexOf('*') != -1) {
+        if ( matchPattern.indexOf( '*' ) != -1 )
+        {
             // having wildcards in patterns is extremely difficult to
             // deal with. For now, we refuse to allow this.
             //
@@ -196,86 +196,90 @@ public class PluginCreateRule extends Ru
             // Reasons include:
             // (a) handling recursive plugins, and
             // (b) determining whether one pattern is "below" another,
-            //     as done by PluginRules. Without wildcards, "below"
-            //     just means startsWith, which is easy to check.
-            initException = new PluginConfigurationException(
-                 "A PluginCreateRule instance has been mapped to" + 
-                 " pattern [" + matchPattern + "]." + 
-                 " This pattern includes a wildcard character." + 
-                 " This is not supported by the plugin architecture.");
+            // as done by PluginRules. Without wildcards, "below"
+            // just means startsWith, which is easy to check.
+            initException =
+                new PluginConfigurationException( "A PluginCreateRule instance has been mapped to" + " pattern ["
+                    + matchPattern + "]." + " This pattern includes a wildcard character."
+                    + " This is not supported by the plugin architecture." );
             throw initException;
         }
 
-        if (baseClass == null) {
+        if ( baseClass == null )
+        {
             baseClass = Object.class;
         }
-        
+
         PluginRules rules = (PluginRules) getDigester().getRules();
         PluginManager pm = rules.getPluginManager();
 
         // check default class is valid
-        if (defaultPlugin != null) {
-            if (!baseClass.isAssignableFrom(defaultPlugin.getPluginClass())) {
-                initException = new PluginConfigurationException(
-                     "Default class [" + 
-                     defaultPlugin.getPluginClass().getName() + 
-                     "] does not inherit from [" + 
-                     baseClass.getName() + "].");
+        if ( defaultPlugin != null )
+        {
+            if ( !baseClass.isAssignableFrom( defaultPlugin.getPluginClass() ) )
+            {
+                initException =
+                    new PluginConfigurationException( "Default class [" + defaultPlugin.getPluginClass().getName()
+                        + "] does not inherit from [" + baseClass.getName() + "]." );
                 throw initException;
             }
 
-            try {
-                defaultPlugin.init(getDigester(), pm);
-                
-            } catch(PluginException pwe) {
-            
-                throw new PluginConfigurationException(
-                    pwe.getMessage(), pwe.getCause());
+            try
+            {
+                defaultPlugin.init( getDigester(), pm );
+
+            }
+            catch ( PluginException pwe )
+            {
+
+                throw new PluginConfigurationException( pwe.getMessage(), pwe.getCause() );
             }
         }
 
         // remember the pattern for later
         pattern = matchPattern;
-        
-        if (pluginClassAttr ==  null) {
+
+        if ( pluginClassAttr == null )
+        {
             // the user hasn't set explicit xml attr names on this rule,
             // so fetch the default values
             pluginClassAttrNs = rules.getPluginClassAttrNs();
             pluginClassAttr = rules.getPluginClassAttr();
-            
-            if (debug) {
-                log.debug(
-                    "init: pluginClassAttr set to per-digester values ["
-                    + "ns=" + pluginClassAttrNs 
-                    + ", name=" + pluginClassAttr + "]");
-            }
-        } else {
-            if (debug) {
-                log.debug(
-                    "init: pluginClassAttr set to rule-specific values ["
-                    + "ns=" + pluginClassAttrNs 
-                    + ", name=" + pluginClassAttr + "]");
+
+            if ( debug )
+            {
+                log.debug( "init: pluginClassAttr set to per-digester values [" + "ns=" + pluginClassAttrNs + ", name="
+                    + pluginClassAttr + "]" );
+            }
+        }
+        else
+        {
+            if ( debug )
+            {
+                log.debug( "init: pluginClassAttr set to rule-specific values [" + "ns=" + pluginClassAttrNs
+                    + ", name=" + pluginClassAttr + "]" );
             }
         }
-        
-        if (pluginIdAttr ==  null) {
+
+        if ( pluginIdAttr == null )
+        {
             // the user hasn't set explicit xml attr names on this rule,
             // so fetch the default values
             pluginIdAttrNs = rules.getPluginIdAttrNs();
             pluginIdAttr = rules.getPluginIdAttr();
-            
-            if (debug) {
-                log.debug(
-                    "init: pluginIdAttr set to per-digester values ["
-                    + "ns=" + pluginIdAttrNs 
-                    + ", name=" + pluginIdAttr + "]");
-            }
-        } else {
-            if (debug) {
-                log.debug(
-                    "init: pluginIdAttr set to rule-specific values ["
-                    + "ns=" + pluginIdAttrNs 
-                    + ", name=" + pluginIdAttr + "]");
+
+            if ( debug )
+            {
+                log.debug( "init: pluginIdAttr set to per-digester values [" + "ns=" + pluginIdAttrNs + ", name="
+                    + pluginIdAttr + "]" );
+            }
+        }
+        else
+        {
+            if ( debug )
+            {
+                log.debug( "init: pluginIdAttr set to rule-specific values [" + "ns=" + pluginIdAttrNs + ", name="
+                    + pluginIdAttr + "]" );
             }
         }
     }
@@ -283,104 +287,114 @@ public class PluginCreateRule extends Ru
     /**
      * Invoked when the Digester matches this rule against an xml element.
      * <p>
-     * A new instance of the target class is created, and pushed onto the
-     * stack. A new "private" PluginRules object is then created and set as
-     * the digester's default Rules object. Any custom rules associated with
-     * the plugin class are then loaded into that new Rules object.
-     * Finally, any custom rules that are associated with the current pattern
-     * (such as SetPropertiesRules) have their begin methods executed.
+     * A new instance of the target class is created, and pushed onto the stack. A new "private" PluginRules object is
+     * then created and set as the digester's default Rules object. Any custom rules associated with the plugin class
+     * are then loaded into that new Rules object. Finally, any custom rules that are associated with the current
+     * pattern (such as SetPropertiesRules) have their begin methods executed.
      * 
-     * @param namespace 
-     * @param name 
+     * @param namespace
+     * @param name
      * @param attributes
-     *
      * @throws ClassNotFoundException
      * @throws PluginInvalidInputException
      * @throws PluginConfigurationException
      */
     @Override
-    public void begin(String namespace, String name,
-                      org.xml.sax.Attributes attributes)
-                      throws java.lang.Exception {
+    public void begin( String namespace, String name, org.xml.sax.Attributes attributes )
+        throws java.lang.Exception
+    {
         Log log = getDigester().getLogger();
         boolean debug = log.isDebugEnabled();
-        if (debug) {
-            log.debug("PluginCreateRule.begin" + ": pattern=[" + pattern + "]" + 
-                  " match=[" + getDigester().getMatch() + "]");
+        if ( debug )
+        {
+            log.debug( "PluginCreateRule.begin" + ": pattern=[" + pattern + "]" + " match=[" + getDigester().getMatch()
+                + "]" );
         }
 
-        if (initException != null) {
+        if ( initException != null )
+        {
             // we had a problem during initialisation that we could
             // not report then; report it now.
             throw initException;
         }
-        
+
         // load any custom rules associated with the plugin
         PluginRules oldRules = (PluginRules) getDigester().getRules();
         PluginManager pluginManager = oldRules.getPluginManager();
         Declaration currDeclaration = null;
-            
-        String pluginClassName; 
-        if (pluginClassAttrNs == null) {
+
+        String pluginClassName;
+        if ( pluginClassAttrNs == null )
+        {
             // Yep, this is ugly.
             //
-            // In a namespace-aware parser, the one-param version will 
+            // In a namespace-aware parser, the one-param version will
             // return attributes with no namespace.
             //
-            // In a non-namespace-aware parser, the two-param version will 
+            // In a non-namespace-aware parser, the two-param version will
             // never return any attributes, ever.
-            pluginClassName = attributes.getValue(pluginClassAttr);
-        } else {
-            pluginClassName = 
-                attributes.getValue(pluginClassAttrNs, pluginClassAttr);
+            pluginClassName = attributes.getValue( pluginClassAttr );
+        }
+        else
+        {
+            pluginClassName = attributes.getValue( pluginClassAttrNs, pluginClassAttr );
         }
 
-        String pluginId; 
-        if (pluginIdAttrNs == null) {
-            pluginId = attributes.getValue(pluginIdAttr);
-        } else {
-            pluginId = 
-                attributes.getValue(pluginIdAttrNs, pluginIdAttr);
+        String pluginId;
+        if ( pluginIdAttrNs == null )
+        {
+            pluginId = attributes.getValue( pluginIdAttr );
         }
-        
-        if (pluginClassName != null) {
+        else
+        {
+            pluginId = attributes.getValue( pluginIdAttrNs, pluginIdAttr );
+        }
+
+        if ( pluginClassName != null )
+        {
             // The user is using a plugin "inline", ie without a previous
             // explicit declaration. If they have used the same plugin class
-            // before, we have already gone to the effort of creating a 
+            // before, we have already gone to the effort of creating a
             // Declaration object, so retrieve it. If there is no existing
             // declaration object for this class, then create one.
 
-            currDeclaration = pluginManager.getDeclarationByClass(
-                pluginClassName);
+            currDeclaration = pluginManager.getDeclarationByClass( pluginClassName );
 
-            if (currDeclaration == null) {
-                currDeclaration = new Declaration(pluginClassName);
-                try {
-                    currDeclaration.init(getDigester(), pluginManager);
-                } catch(PluginException pwe) {
-                    throw new PluginInvalidInputException(
-                        pwe.getMessage(), pwe.getCause());
-                }
-                pluginManager.addDeclaration(currDeclaration);
-            }
-        } else if (pluginId != null) {
-            currDeclaration = pluginManager.getDeclarationById(pluginId);
-                
-            if (currDeclaration == null) {
-                throw new PluginInvalidInputException(
-                    "Plugin id [" + pluginId + "] is not defined.");
+            if ( currDeclaration == null )
+            {
+                currDeclaration = new Declaration( pluginClassName );
+                try
+                {
+                    currDeclaration.init( getDigester(), pluginManager );
+                }
+                catch ( PluginException pwe )
+                {
+                    throw new PluginInvalidInputException( pwe.getMessage(), pwe.getCause() );
+                }
+                pluginManager.addDeclaration( currDeclaration );
             }
-        } else if (defaultPlugin != null) {
+        }
+        else if ( pluginId != null )
+        {
+            currDeclaration = pluginManager.getDeclarationById( pluginId );
+
+            if ( currDeclaration == null )
+            {
+                throw new PluginInvalidInputException( "Plugin id [" + pluginId + "] is not defined." );
+            }
+        }
+        else if ( defaultPlugin != null )
+        {
             currDeclaration = defaultPlugin;
-        } else {
-            throw new PluginInvalidInputException(
-                "No plugin class specified for element " +
-                pattern);
         }
-            
+        else
+        {
+            throw new PluginInvalidInputException( "No plugin class specified for element " + pattern );
+        }
+
         // get the class of the user plugged-in type
         Class<?> pluginClass = currDeclaration.getPluginClass();
-        
+
         String path = getDigester().getMatch();
 
         // create a new Rules object and effectively push it onto a stack of
@@ -388,43 +402,43 @@ public class PluginCreateRule extends Ru
         // PluginRules constructor below causes the new instance to link
         // to the previous head-of-stack, then the Digester.setRules() makes
         // the new instance the new head-of-stack.
-        PluginRules newRules = new PluginRules(getDigester(), path, oldRules, pluginClass);
-        getDigester().setRules(newRules);
-        
-        if (debug) {
-            log.debug("PluginCreateRule.begin: installing new plugin: " +
-                "oldrules=" + oldRules.toString() +
-                ", newrules=" + newRules.toString());
+        PluginRules newRules = new PluginRules( getDigester(), path, oldRules, pluginClass );
+        getDigester().setRules( newRules );
+
+        if ( debug )
+        {
+            log.debug( "PluginCreateRule.begin: installing new plugin: " + "oldrules=" + oldRules.toString()
+                + ", newrules=" + newRules.toString() );
         }
-              
+
         // load up the custom rules
-        currDeclaration.configure(getDigester(), pattern);
+        currDeclaration.configure( getDigester(), pattern );
 
         // create an instance of the plugin class
         Object instance = pluginClass.newInstance();
-        getDigester().push(instance);
-        if (debug) {
-            log.debug(
-                "PluginCreateRule.begin" + ": pattern=[" + pattern + "]" + 
-                " match=[" + getDigester().getMatch() + "]" + 
-                " pushed instance of plugin [" + pluginClass.getName() + "]");
+        getDigester().push( instance );
+        if ( debug )
+        {
+            log.debug( "PluginCreateRule.begin" + ": pattern=[" + pattern + "]" + " match=[" + getDigester().getMatch()
+                + "]" + " pushed instance of plugin [" + pluginClass.getName() + "]" );
         }
-        
+
         // and now we have to fire any custom rules which would have
         // been matched by the same path that matched this rule, had
         // they been loaded at that time.
-        List<Rule> rules = newRules.getDecoratedRules().match(namespace, path);
-        fireBeginMethods(rules, namespace, name, attributes); 
+        List<Rule> rules = newRules.getDecoratedRules().match( namespace, path );
+        fireBeginMethods( rules, namespace, name, attributes );
     }
 
     /**
      * Process the body text of this element.
-     *
+     * 
      * @param text The body text of this element
      */
     @Override
-    public void body(String namespace, String name, String text)
-        throws Exception {
+    public void body( String namespace, String name, String text )
+        throws Exception
+    {
 
         // While this class itself has no work to do in the body method,
         // we do need to fire the body methods of all dynamically-added
@@ -437,40 +451,37 @@ public class PluginCreateRule extends Ru
         // object to execute them at the appropriate time.
         //
         // Note that this applies only to rules matching exactly the path
-        // which is also matched by this PluginCreateRule. 
+        // which is also matched by this PluginCreateRule.
 
         String path = getDigester().getMatch();
         PluginRules newRules = (PluginRules) getDigester().getRules();
-        List<Rule> rules = newRules.getDecoratedRules().match(namespace, path);
-        fireBodyMethods(rules, namespace, name, text);
+        List<Rule> rules = newRules.getDecoratedRules().match( namespace, path );
+        fireBodyMethods( rules, namespace, name, text );
     }
 
     /**
-     * Invoked by the digester when the closing tag matching this Rule's
-     * pattern is encountered.
-     * </p>
+     * Invoked by the digester when the closing tag matching this Rule's pattern is encountered. </p>
      * 
      * @param namespace Description of the Parameter
      * @param name Description of the Parameter
      * @exception Exception Description of the Exception
-     *
      * @see #begin
      */
     @Override
-    public void end(String namespace, String name)
-                    throws Exception {
-
+    public void end( String namespace, String name )
+        throws Exception
+    {
 
         // see body method for more info
         String path = getDigester().getMatch();
         PluginRules newRules = (PluginRules) getDigester().getRules();
-        List<Rule> rules = newRules.getDecoratedRules().match(namespace, path);
-        fireEndMethods(rules, namespace, name);
-        
+        List<Rule> rules = newRules.getDecoratedRules().match( namespace, path );
+        fireEndMethods( rules, namespace, name );
+
         // pop the stack of PluginRules instances, which
         // discards all custom rules associated with this plugin
-        getDigester().setRules(newRules.getParent());
-        
+        getDigester().setRules( newRules.getParent() );
+
         // and get rid of the instance of the plugin class from the
         // digester object stack.
         getDigester().pop();
@@ -479,43 +490,47 @@ public class PluginCreateRule extends Ru
     /**
      * Return the pattern that this Rule is associated with.
      * <p>
-     * In general, Rule instances <i>can</i> be associated with multiple
-     * patterns. A PluginCreateRule, however, will only function correctly
-     * when associated with a single pattern. It is possible to fix this, but
-     * I can't be bothered just now because this feature is unlikely to be
-     * used.
+     * In general, Rule instances <i>can</i> be associated with multiple patterns. A PluginCreateRule, however, will
+     * only function correctly when associated with a single pattern. It is possible to fix this, but I can't be
+     * bothered just now because this feature is unlikely to be used.
      * </p>
      * 
      * @return The pattern value
      */
-    public String getPattern() {
+    public String getPattern()
+    {
         return pattern;
     }
-    
+
     /**
-     * Duplicate the processing that the Digester does when firing the
-     * begin methods of rules. It would be really nice if the Digester
-     * class provided a way for this functionality to just be invoked
-     * directly.
-     */
-    public void fireBeginMethods(List<Rule> rules,
-                      String namespace, String name,
-                      org.xml.sax.Attributes list)
-                      throws java.lang.Exception {
-        
-        if ((rules != null) && (rules.size() > 0)) {
+     * Duplicate the processing that the Digester does when firing the begin methods of rules. It would be really nice
+     * if the Digester class provided a way for this functionality to just be invoked directly.
+     */
+    public void fireBeginMethods( List<Rule> rules, String namespace, String name, org.xml.sax.Attributes list )
+        throws java.lang.Exception
+    {
+
+        if ( ( rules != null ) && ( rules.size() > 0 ) )
+        {
             Log log = getDigester().getLogger();
             boolean debug = log.isDebugEnabled();
-            for (int i = 0; i < rules.size(); i++) {
-                try {
-                    Rule rule = rules.get(i);
-                    if (debug) {
-                        log.debug("  Fire begin() for " + rule);
+            for ( int i = 0; i < rules.size(); i++ )
+            {
+                try
+                {
+                    Rule rule = rules.get( i );
+                    if ( debug )
+                    {
+                        log.debug( "  Fire begin() for " + rule );
                     }
-                    rule.begin(namespace, name, list);
-                } catch (Exception e) {
-                    throw getDigester().createSAXException(e);
-                } catch (Error e) {
+                    rule.begin( namespace, name, list );
+                }
+                catch ( Exception e )
+                {
+                    throw getDigester().createSAXException( e );
+                }
+                catch ( Error e )
+                {
                     throw e;
                 }
             }
@@ -523,59 +538,71 @@ public class PluginCreateRule extends Ru
     }
 
     /**
-     * Duplicate the processing that the Digester does when firing the
-     * body methods of rules. It would be really nice if the Digester
-     * class provided a way for this functionality to just be invoked
-     * directly.
-     */
-    private void fireBodyMethods(List<Rule> rules,
-                    String namespaceURI, String name,
-                    String text) throws Exception {
+     * Duplicate the processing that the Digester does when firing the body methods of rules. It would be really nice if
+     * the Digester class provided a way for this functionality to just be invoked directly.
+     */
+    private void fireBodyMethods( List<Rule> rules, String namespaceURI, String name, String text )
+        throws Exception
+    {
 
-        if ((rules != null) && (rules.size() > 0)) {
+        if ( ( rules != null ) && ( rules.size() > 0 ) )
+        {
             Log log = getDigester().getLogger();
             boolean debug = log.isDebugEnabled();
-            for (int i = 0; i < rules.size(); i++) {
-                try {
-                    Rule rule = rules.get(i);
-                    if (debug) {
-                        log.debug("  Fire body() for " + rule);
+            for ( int i = 0; i < rules.size(); i++ )
+            {
+                try
+                {
+                    Rule rule = rules.get( i );
+                    if ( debug )
+                    {
+                        log.debug( "  Fire body() for " + rule );
                     }
-                    rule.body(namespaceURI, name, text);
-                } catch (Exception e) {
-                    throw getDigester().createSAXException(e);
-                } catch (Error e) {
+                    rule.body( namespaceURI, name, text );
+                }
+                catch ( Exception e )
+                {
+                    throw getDigester().createSAXException( e );
+                }
+                catch ( Error e )
+                {
                     throw e;
                 }
             }
         }
     }
-    
+
     /**
-     * Duplicate the processing that the Digester does when firing the
-     * end methods of rules. It would be really nice if the Digester
-     * class provided a way for this functionality to just be invoked
-     * directly.
-     */
-    public void fireEndMethods(List<Rule> rules,
-                    String namespaceURI, String name)
-                    throws Exception {
+     * Duplicate the processing that the Digester does when firing the end methods of rules. It would be really nice if
+     * the Digester class provided a way for this functionality to just be invoked directly.
+     */
+    public void fireEndMethods( List<Rule> rules, String namespaceURI, String name )
+        throws Exception
+    {
 
         // Fire "end" events for all relevant rules in reverse order
-        if (rules != null) {
+        if ( rules != null )
+        {
             Log log = getDigester().getLogger();
             boolean debug = log.isDebugEnabled();
-            for (int i = 0; i < rules.size(); i++) {
-                int j = (rules.size() - i) - 1;
-                try {
-                    Rule rule = rules.get(j);
-                    if (debug) {
-                        log.debug("  Fire end() for " + rule);
+            for ( int i = 0; i < rules.size(); i++ )
+            {
+                int j = ( rules.size() - i ) - 1;
+                try
+                {
+                    Rule rule = rules.get( j );
+                    if ( debug )
+                    {
+                        log.debug( "  Fire end() for " + rule );
                     }
-                    rule.end(namespaceURI, name);
-                } catch (Exception e) {
-                    throw getDigester().createSAXException(e);
-                } catch (Error e) {
+                    rule.end( namespaceURI, name );
+                }
+                catch ( Exception e )
+                {
+                    throw getDigester().createSAXException( e );
+                }
+                catch ( Error e )
+                {
                     throw e;
                 }
             }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginDeclarationRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginDeclarationRule.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginDeclarationRule.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginDeclarationRule.java Thu May 12 18:03:26 2011
@@ -24,98 +24,101 @@ import org.apache.commons.digester3.Dige
 import org.apache.commons.digester3.Rule;
 
 /**
- * A Digester rule which allows the user to pre-declare a class which is to
- * be referenced later at a plugin point by a PluginCreateRule.
+ * A Digester rule which allows the user to pre-declare a class which is to be referenced later at a plugin point by a
+ * PluginCreateRule.
  * <p>
- * Normally, a PluginDeclarationRule is added to a Digester instance with
- * the pattern "{root}/plugin" or "* /plugin" where {root} is the name of 
- * the root tag in the input document.
- *
+ * Normally, a PluginDeclarationRule is added to a Digester instance with the pattern "{root}/plugin" or "* /plugin"
+ * where {root} is the name of the root tag in the input document.
+ * 
  * @since 1.6
  */
 
-public class PluginDeclarationRule extends Rule {
-
-    //------------------- constructors ---------------------------------------
-
-    /** constructor  */
-    public PluginDeclarationRule() {
+public class PluginDeclarationRule
+    extends Rule
+{
+
+    // ------------------- constructors ---------------------------------------
+
+    /** constructor */
+    public PluginDeclarationRule()
+    {
         super();
     }
 
-    //------------------- methods --------------------------------------------
+    // ------------------- methods --------------------------------------------
 
     /**
-     * Invoked upon reading a tag defining a plugin declaration. The tag
-     * must have the following mandatory attributes:
+     * Invoked upon reading a tag defining a plugin declaration. The tag must have the following mandatory attributes:
      * <ul>
-     *   <li> id </li>
-     *   <li> class </li>
+     * <li>id</li>
+     * <li>class</li>
      * </ul>
-     *
-     *@param namespace The xml namespace in which the xml element which
-     * triggered this rule resides.
-     *@param name The name of the xml element which triggered this rule.
-     *@param attributes The set of attributes on the xml element which
-     * triggered this rule.
-     *@exception java.lang.Exception
+     * 
+     * @param namespace The xml namespace in which the xml element which triggered this rule resides.
+     * @param name The name of the xml element which triggered this rule.
+     * @param attributes The set of attributes on the xml element which triggered this rule.
+     * @exception java.lang.Exception
      */
 
     @Override
-    public void begin(String namespace, String name,
-                      org.xml.sax.Attributes attributes)
-                      throws java.lang.Exception {
-                 
+    public void begin( String namespace, String name, org.xml.sax.Attributes attributes )
+        throws java.lang.Exception
+    {
+
         int nAttrs = attributes.getLength();
         Properties props = new Properties();
-        for(int i=0; i<nAttrs; ++i) {
-            String key = attributes.getLocalName(i);
-            if ((key == null) || (key.length() == 0)) {
-                key = attributes.getQName(i);
+        for ( int i = 0; i < nAttrs; ++i )
+        {
+            String key = attributes.getLocalName( i );
+            if ( ( key == null ) || ( key.length() == 0 ) )
+            {
+                key = attributes.getQName( i );
             }
-            String value = attributes.getValue(i);
-            props.setProperty(key, value);
+            String value = attributes.getValue( i );
+            props.setProperty( key, value );
+        }
+
+        try
+        {
+            declarePlugin( getDigester(), props );
         }
-        
-        try {
-            declarePlugin(getDigester(), props);
-        } catch(PluginInvalidInputException ex) {
-            throw new PluginInvalidInputException(
-                "Error on element [" + getDigester().getMatch() + 
-                "]: " + ex.getMessage());
+        catch ( PluginInvalidInputException ex )
+        {
+            throw new PluginInvalidInputException( "Error on element [" + getDigester().getMatch() + "]: "
+                + ex.getMessage() );
         }
     }
-    
-    public static void declarePlugin(Digester digester, Properties props)
-    throws PluginException {
-        
-        String id = props.getProperty("id");
-        String pluginClassName = props.getProperty("class");
-        
-        if (id == null) {
-            throw new PluginInvalidInputException(
-                "mandatory attribute id not present on plugin declaration");
+
+    public static void declarePlugin( Digester digester, Properties props )
+        throws PluginException
+    {
+
+        String id = props.getProperty( "id" );
+        String pluginClassName = props.getProperty( "class" );
+
+        if ( id == null )
+        {
+            throw new PluginInvalidInputException( "mandatory attribute id not present on plugin declaration" );
         }
 
-        if (pluginClassName == null) {
-            throw new PluginInvalidInputException(
-                "mandatory attribute class not present on plugin declaration");
+        if ( pluginClassName == null )
+        {
+            throw new PluginInvalidInputException( "mandatory attribute class not present on plugin declaration" );
         }
 
-        Declaration newDecl = new Declaration(pluginClassName);
-        newDecl.setId(id);
-        newDecl.setProperties(props);
+        Declaration newDecl = new Declaration( pluginClassName );
+        newDecl.setId( id );
+        newDecl.setProperties( props );
 
         PluginRules rc = (PluginRules) digester.getRules();
         PluginManager pm = rc.getPluginManager();
 
-        newDecl.init(digester, pm);
-        pm.addDeclaration(newDecl);
-        
+        newDecl.init( digester, pm );
+        pm.addDeclaration( newDecl );
+
         // Note that it is perfectly safe to redeclare a plugin, because
         // the declaration doesn't add any rules to digester; all it does
         // is create a RuleLoader instance whch is *capable* of adding the
         // rules to the digester.
     }
 }
-

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginException.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginException.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginException.java Thu May 12 18:03:26 2011
@@ -19,46 +19,52 @@
 package org.apache.commons.digester3.plugins;
 
 /**
- * Thrown when some plugin-related error has occurred, and none of the
- * other exception types are appropriate.
- *
+ * Thrown when some plugin-related error has occurred, and none of the other exception types are appropriate.
+ * 
  * @since 1.6
  */
 
-public class PluginException extends Exception {
+public class PluginException
+    extends Exception
+{
 
     private static final long serialVersionUID = 1L;
+
     private Throwable cause = null;
 
     /**
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginException(Throwable cause) {
-        this(cause.getMessage());
+    public PluginException( Throwable cause )
+    {
+        this( cause.getMessage() );
         this.cause = cause;
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      */
-    public PluginException(String msg) {
-        super(msg);
+    public PluginException( String msg )
+    {
+        super( msg );
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginException(String msg, Throwable cause) {
-        this(msg);
+    public PluginException( String msg, Throwable cause )
+    {
+        this( msg );
         this.cause = cause;
     }
-    
+
     /**
      * @return the underlying exception that caused this to be thrown
      */
     @Override
-    public Throwable getCause() {
+    public Throwable getCause()
+    {
         return cause;
     }
 }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginInvalidInputException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginInvalidInputException.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginInvalidInputException.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginInvalidInputException.java Thu May 12 18:03:26 2011
@@ -20,46 +20,52 @@ package org.apache.commons.digester3.plu
 
 /**
  * Thrown when an error occurs due to bad data in the file being parsed.
- *
+ * 
  * @since 1.6
  */
-public class PluginInvalidInputException extends PluginException {
+public class PluginInvalidInputException
+    extends PluginException
+{
 
     private static final long serialVersionUID = 1L;
+
     private Throwable cause = null;
 
     /**
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginInvalidInputException(Throwable cause) {
-        this(cause.getMessage());
+    public PluginInvalidInputException( Throwable cause )
+    {
+        this( cause.getMessage() );
         this.cause = cause;
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      */
-    public PluginInvalidInputException(String msg) {
-        super(msg);
+    public PluginInvalidInputException( String msg )
+    {
+        super( msg );
     }
 
     /**
      * @param msg describes the reason this exception is being thrown.
      * @param cause underlying exception that caused this to be thrown
      */
-    public PluginInvalidInputException(String msg, Throwable cause) {
-        this(msg);
+    public PluginInvalidInputException( String msg, Throwable cause )
+    {
+        this( msg );
         this.cause = cause;
     }
-    
+
     /**
-     * Return the cause of this exception (if any) as specified in the
-     * exception constructor.
+     * Return the cause of this exception (if any) as specified in the exception constructor.
      * 
      * @since 1.8
      */
     @Override
-    public Throwable getCause() {
+    public Throwable getCause()
+    {
         return cause;
     }
 }

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginManager.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginManager.java?rev=1102402&r1=1102401&r2=1102402&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginManager.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/plugins/PluginManager.java Thu May 12 18:03:26 2011
@@ -28,156 +28,157 @@ import org.apache.commons.digester3.Dige
 import org.apache.commons.logging.Log;
 
 /**
- * Coordinates between PluginDeclarationRule and PluginCreateRule objects,
- * providing a place to share data between instances of these rules.
+ * Coordinates between PluginDeclarationRule and PluginCreateRule objects, providing a place to share data between
+ * instances of these rules.
  * <p>
  * One instance of this class exists per PluginRules instance.
- *
+ * 
  * @since 1.6
  */
 
-public class PluginManager {
+public class PluginManager
+{
 
     /** Map of classname->Declaration */
     private HashMap<String, Declaration> declarationsByClass = new HashMap<String, Declaration>();
 
-    /** Map of id->Declaration  */
+    /** Map of id->Declaration */
     private HashMap<String, Declaration> declarationsById = new HashMap<String, Declaration>();
 
     /** the parent manager to which this one may delegate lookups. */
     private PluginManager parent;
-    
-    /** 
-     * The object containing data that should only exist once for each
-     * Digester instance.
+
+    /**
+     * The object containing data that should only exist once for each Digester instance.
      */
     private PluginContext pluginContext;
-    
-    //------------------- constructors ---------------------------------------
-    
+
+    // ------------------- constructors ---------------------------------------
+
     /** Construct a "root" PluginManager, ie one with no parent. */
-    public PluginManager(PluginContext r) {
+    public PluginManager( PluginContext r )
+    {
         pluginContext = r;
     }
 
-    /** 
-     * Construct a "child" PluginManager. When declarations are added to
-     * a "child", they are stored within the child and do not modify the
-     * parent, so when the child goes out of scope, those declarations
-     * disappear. When asking a "child" to retrieve a declaration, it 
-     * delegates the search to its parent if it does not hold a matching
-     * entry itself.
+    /**
+     * Construct a "child" PluginManager. When declarations are added to a "child", they are stored within the child and
+     * do not modify the parent, so when the child goes out of scope, those declarations disappear. When asking a
+     * "child" to retrieve a declaration, it delegates the search to its parent if it does not hold a matching entry
+     * itself.
      * <p>
+     * 
      * @param parent must be non-null.
      */
-    public PluginManager(PluginManager parent) {
+    public PluginManager( PluginManager parent )
+    {
         this.parent = parent;
         this.pluginContext = parent.pluginContext;
     }
-    
-    //------------------- methods --------------------------------------------
+
+    // ------------------- methods --------------------------------------------
 
     /**
      * Add the declaration to the set of known declarations.
      * <p>
-     * TODO: somehow get a reference to a Digester object
-     * so that we can really log here. Currently, all
-     * logging is disabled from this method.
-     *
-     *@param decl an object representing a plugin class.
-     */
-    public void addDeclaration(Declaration decl) {
-        Log log = LogUtils.getLogger(null);
+     * TODO: somehow get a reference to a Digester object so that we can really log here. Currently, all logging is
+     * disabled from this method.
+     * 
+     * @param decl an object representing a plugin class.
+     */
+    public void addDeclaration( Declaration decl )
+    {
+        Log log = LogUtils.getLogger( null );
         boolean debug = log.isDebugEnabled();
-        
+
         Class<?> pluginClass = decl.getPluginClass();
         String id = decl.getId();
-        
-        declarationsByClass.put(pluginClass.getName(), decl);
-            
-        if (id != null) {
-            declarationsById.put(id, decl);
-            if (debug) {
-                log.debug(
-                    "Indexing plugin-id [" + id + "]" +
-                    " -> class [" + pluginClass.getName() + "]");
+
+        declarationsByClass.put( pluginClass.getName(), decl );
+
+        if ( id != null )
+        {
+            declarationsById.put( id, decl );
+            if ( debug )
+            {
+                log.debug( "Indexing plugin-id [" + id + "]" + " -> class [" + pluginClass.getName() + "]" );
             }
         }
     }
 
     /**
-     * Return the declaration object with the specified class.
-     * If no such plugin is known, null is returned.
+     * Return the declaration object with the specified class. If no such plugin is known, null is returned.
      */
-    public Declaration getDeclarationByClass(String className) {
-        Declaration decl = 
-            declarationsByClass.get(className);
-            
-        if ((decl == null) && (parent != null)) {
-            decl = parent.getDeclarationByClass(className);
+    public Declaration getDeclarationByClass( String className )
+    {
+        Declaration decl = declarationsByClass.get( className );
+
+        if ( ( decl == null ) && ( parent != null ) )
+        {
+            decl = parent.getDeclarationByClass( className );
         }
 
         return decl;
     }
 
     /**
-     * Return the declaration object with the specified id.
-     * If no such plugin is known, null is returned.
-     *
-     *@param id Description of the Parameter
-     *@return The declaration value
-     */
-    public Declaration getDeclarationById(String id) {
-        Declaration decl = declarationsById.get(id);
-
-        if ((decl == null) && (parent != null)) {
-            decl = parent.getDeclarationById(id);
+     * Return the declaration object with the specified id. If no such plugin is known, null is returned.
+     * 
+     * @param id Description of the Parameter
+     * @return The declaration value
+     */
+    public Declaration getDeclarationById( String id )
+    {
+        Declaration decl = declarationsById.get( id );
+
+        if ( ( decl == null ) && ( parent != null ) )
+        {
+            decl = parent.getDeclarationById( id );
         }
 
         return decl;
     }
 
     /**
-     * Given a plugin class and some associated properties, scan the
-     * list of known RuleFinder instances until one detects a source of
-     * custom rules for this plugin (aka a RuleLoader).
+     * Given a plugin class and some associated properties, scan the list of known RuleFinder instances until one
+     * detects a source of custom rules for this plugin (aka a RuleLoader).
      * <p>
      * If no source of custom rules can be found, null is returned.
      */
-    public RuleLoader findLoader(Digester digester, String id, 
-                        Class<?> pluginClass, Properties props) 
-                        throws PluginException {    
+    public RuleLoader findLoader( Digester digester, String id, Class<?> pluginClass, Properties props )
+        throws PluginException
+    {
 
-        // iterate over the list of RuleFinders, trying each one 
+        // iterate over the list of RuleFinders, trying each one
         // until one of them locates a source of dynamic rules given
-        // this specific plugin class and the associated declaration 
+        // this specific plugin class and the associated declaration
         // properties.
-        Log log = LogUtils.getLogger(digester);
+        Log log = LogUtils.getLogger( digester );
         boolean debug = log.isDebugEnabled();
-        log.debug("scanning ruleFinders to locate loader..");
-        
+        log.debug( "scanning ruleFinders to locate loader.." );
+
         List<RuleFinder> ruleFinders = pluginContext.getRuleFinders();
         RuleLoader ruleLoader = null;
-        try {
-            for(Iterator<RuleFinder> i = ruleFinders.iterator(); 
-                i.hasNext() && ruleLoader == null; ) {
-                    
+        try
+        {
+            for ( Iterator<RuleFinder> i = ruleFinders.iterator(); i.hasNext() && ruleLoader == null; )
+            {
+
                 RuleFinder finder = i.next();
-                if (debug) {
-                    log.debug("checking finder of type " + finder.getClass().getName());
+                if ( debug )
+                {
+                    log.debug( "checking finder of type " + finder.getClass().getName() );
                 }
-                ruleLoader = finder.findLoader(digester, pluginClass, props);
+                ruleLoader = finder.findLoader( digester, pluginClass, props );
             }
         }
-        catch(PluginException e) {
-            throw new PluginException(
-                "Unable to locate plugin rules for plugin"
-                + " with id [" + id + "]"
-                + ", and class [" + pluginClass.getName() + "]"
-                + ":" + e.getMessage(), e.getCause());
+        catch ( PluginException e )
+        {
+            throw new PluginException( "Unable to locate plugin rules for plugin" + " with id [" + id + "]"
+                + ", and class [" + pluginClass.getName() + "]" + ":" + e.getMessage(), e.getCause() );
         }
-        log.debug("scanned ruleFinders.");
-        
+        log.debug( "scanned ruleFinders." );
+
         return ruleLoader;
     }
 }



Mime
View raw message