You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 20:42:41 UTC

svn commit: r376812 [1/2] - /struts/extras/trunk/src/java/org/apache/struts/actions/

Author: husted
Date: Fri Feb 10 11:42:38 2006
New Revision: 376812

URL: http://svn.apache.org/viewcvs?rev=376812&view=rev
Log:
Checkstyle Roundup 
* Extra package reformatted with latest Jalopy settings. Stylistic changes only.


Modified:
    struts/extras/trunk/src/java/org/apache/struts/actions/ActionDispatcher.java
    struts/extras/trunk/src/java/org/apache/struts/actions/BaseAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/DownloadAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/ForwardAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/IncludeAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/LocaleAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/MappingDispatchAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/SwitchAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/package.html

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/ActionDispatcher.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/ActionDispatcher.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/ActionDispatcher.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/ActionDispatcher.java Fri Feb 10 11:42:38 2006
@@ -15,39 +15,35 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.actions;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.struts.Globals;
 import org.apache.struts.action.Action;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 import org.apache.struts.util.MessageResources;
-import org.apache.struts.Globals;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.util.HashMap;
 
 /**
  * <p>Action <i>helper</i> class that dispatches to a public method in an
- * Action.</p>
- * <p/>
- * <p>This class is provided as an alternative mechanism to using DispatchAction
- * and its various flavours and means <i>Dispatch</i> behaviour can be
- * easily implemented into any <code>Action</code> without having to
- * inherit from a particular super <code>Action</code>.</p>
- * <p/>
- * <p>To implement <i>dispatch</i> behaviour in an <code>Action</code>
- * class, create your custom Action as follows, along with the methods you
- * require (and optionally "cancelled" and "unspecified" methods):</p>
- * <p/>
+ * Action.</p> <p/> <p>This class is provided as an alternative mechanism to
+ * using DispatchAction and its various flavours and means <i>Dispatch</i>
+ * behaviour can be easily implemented into any <code>Action</code> without
+ * having to inherit from a particular super <code>Action</code>.</p> <p/>
+ * <p>To implement <i>dispatch</i> behaviour in an <code>Action</code> class,
+ * create your custom Action as follows, along with the methods you require
+ * (and optionally "cancelled" and "unspecified" methods):</p> <p/>
  * <pre>
  *   public class MyCustomAction extends Action {
  *
@@ -64,31 +60,32 @@
  *   }
  * </pre>
  * <p/>
+ *
  * <p>It provides three flavours of determing the name of the method:</p>
- * <p/>
+ *
  * <ul>
- * <li><strong>{@link #DEFAULT_FLAVOR}</strong> - uses the parameter specified
- * in the struts-config.xml to get the method name from the Request
- * (equivalent to <code>DispatchAction</code> <b>except</b> uses "method"
- * as a default if the <code>parameter</code> is not specified
- * in the struts-config.xml).</li>
- * <p/>
- * <li><strong>{@link #DISPATCH_FLAVOR}</strong> - uses the parameter specified
- * in the struts-config.xml to get the method name from the Request
- * (equivalent to <code>DispatchAction</code>).</li>
- * <p/>
- * <li><strong>{@link #MAPPING_FLAVOR}</strong> - uses the parameter specified
- * in the struts-config.xml as the method name
- * (equivalent to <code>MappingDispatchAction</code>).</li>
- * <p/>
+ *
+ * <li><strong>{@link #DEFAULT_FLAVOR}</strong> - uses the parameter
+ * specified in the struts-config.xml to get the method name from the Request
+ * (equivalent to <code>DispatchAction</code> <b>except</b> uses "method" as a
+ * default if the <code>parameter</code> is not specified in the
+ * struts-config.xml).</li>
+ *
+ * <li><strong>{@link #DISPATCH_FLAVOR}</strong>
+ * - uses the parameter specified in the struts-config.xml to get the method
+ * name from the Request (equivalent to <code>DispatchAction</code>).</li>
+ *
+ * <li><strong>{@link #MAPPING_FLAVOR}</strong> - uses the parameter
+ * specified in the struts-config.xml as the method name (equivalent to
+ * <code>MappingDispatchAction</code>).</li>
+
  * </ul>
  *
+ * @version $Rev$ $Date: 2005-05-14 21:27:02 -0400 (Sat, 14 May 2005)
+ *          $
  * @since Struts 1.2.7
- * @version $Rev$ $Date$
  */
 public class ActionDispatcher {
-
-
     // ----------------------------------------------------- Instance Variables
 
     /**
@@ -106,6 +103,17 @@
      */
     public static final int DISPATCH_FLAVOR = 2;
 
+    /**
+     * Commons Logging instance.
+     */
+    protected static Log log = LogFactory.getLog(ActionDispatcher.class);
+
+    /**
+     * The message resources for this package.
+     */
+    protected static MessageResources messages =
+        MessageResources.getMessageResources(
+            "org.apache.struts.actions.LocalStrings");
 
     /**
      * The associated Action to dispatch to.
@@ -123,24 +131,10 @@
     protected Class clazz;
 
     /**
-     * Commons Logging instance.
-     */
-    protected static Log log = LogFactory.getLog(ActionDispatcher.class);
-
-
-    /**
-     * The message resources for this package.
-     */
-    protected static MessageResources messages =
-            MessageResources.getMessageResources
-            ("org.apache.struts.actions.LocalStrings");
-
-
-    /**
-     * The set of Method objects we have introspected for this class,
-     * keyed by method name.  This collection is populated as different
-     * methods are called, so that introspection needs to occur only
-     * once per method name.
+     * The set of Method objects we have introspected for this class, keyed by
+     * method name.  This collection is populated as different methods are
+     * called, so that introspection needs to occur only once per method
+     * name.
      */
     protected HashMap methods = new HashMap();
 
@@ -148,11 +142,11 @@
      * The set of argument type classes for the reflected method call.  These
      * are the same for all calls, so calculate them only once.
      */
-    protected Class[] types = {
-        ActionMapping.class,
-        ActionForm.class,
-        HttpServletRequest.class,
-        HttpServletResponse.class};
+    protected Class[] types =
+        {
+            ActionMapping.class, ActionForm.class, HttpServletRequest.class,
+            HttpServletResponse.class
+        };
 
     // ----------------------------------------------------- Constructors
 
@@ -165,26 +159,21 @@
         this(actionInstance, DEFAULT_FLAVOR);
     }
 
-
     /**
      * Construct an instance of this class from the supplied parameters.
      *
      * @param actionInstance The action instance to be invoked.
-     * @param flavor The flavor of dispatch to use.
+     * @param flavor         The flavor of dispatch to use.
      */
     public ActionDispatcher(Action actionInstance, int flavor) {
-
         this.actionInstance = actionInstance;
         this.flavor = flavor;
 
         clazz = actionInstance.getClass();
-
     }
 
-
     // --------------------------------------------------------- Public Methods
 
-
     /**
      * Process the specified HTTP request, and create the corresponding HTTP
      * response (or forward to another web component that will create it).
@@ -196,83 +185,70 @@
      * @param form     The optional ActionForm bean for this request (if any)
      * @param request  The HTTP request we are processing
      * @param response The HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
      * @throws Exception if an exception occurs
      */
-    public ActionForward execute(ActionMapping mapping,
-                                 ActionForm form,
-                                 HttpServletRequest request,
-                                 HttpServletResponse response)
-            throws Exception {
-
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         // Process "cancelled"
         if (isCancelled(request)) {
             ActionForward af = cancelled(mapping, form, request, response);
+
             if (af != null) {
                 return af;
             }
         }
+
         // Identify the request parameter containing the method name
         String parameter = getParameter(mapping, form, request, response);
 
         // Get the method's name. This could be overridden in subclasses.
-        String name = getMethodName(mapping, form, request, response,
-                parameter);
-
+        String name =
+            getMethodName(mapping, form, request, response, parameter);
 
         // Prevent recursive calls
         if ("execute".equals(name) || "perform".equals(name)) {
-            String message = messages.getMessage("dispatch.recursive",
-                    mapping.getPath());
+            String message =
+                messages.getMessage("dispatch.recursive", mapping.getPath());
 
             log.error(message);
             throw new ServletException(message);
         }
 
-
         // Invoke the named method, and return the result
         return dispatchMethod(mapping, form, request, response, name);
-
     }
 
-
     /**
-     * <p>Dispatches to the target class' <code>unspecified</code> method,
-     * if present, otherwise throws a ServletException. Classes utilizing
+     * <p>Dispatches to the target class' <code>unspecified</code> method, if
+     * present, otherwise throws a ServletException. Classes utilizing
      * <code>ActionDispatcher</code> should provide an <code>unspecified</code>
-     * method if they wish to provide behavior different than
-     * throwing a ServletException.</p>
+     * method if they wish to provide behavior different than throwing a
+     * ServletException.</p>
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      */
-    protected ActionForward unspecified(ActionMapping mapping,
-                                        ActionForm form,
-                                        HttpServletRequest request,
-                                        HttpServletResponse response)
-            throws Exception {
-
-
+    protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         // Identify if there is an "unspecified" method to be dispatched to
         String name = "unspecified";
         Method method = null;
+
         try {
             method = getMethod(name);
-
         } catch (NoSuchMethodException e) {
-            String message = messages.getMessage("dispatch.parameter",
-                    mapping.getPath(),
+            String message =
+                messages.getMessage("dispatch.parameter", mapping.getPath(),
                     mapping.getParameter());
 
             log.error(message);
@@ -281,7 +257,6 @@
         }
 
         return dispatchMethod(mapping, form, request, response, name, method);
-
     }
 
     /**
@@ -290,61 +265,50 @@
      * should provide a <code>cancelled</code> method if they wish to provide
      * behavior different than returning null.</p>
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      */
-    protected ActionForward cancelled(ActionMapping mapping,
-                                      ActionForm form,
-                                      HttpServletRequest request,
-                                      HttpServletResponse response)
-            throws Exception {
-
+    protected ActionForward cancelled(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         // Identify if there is an "cancelled" method to be dispatched to
         String name = "cancelled";
         Method method = null;
+
         try {
             method = getMethod(name);
-
         } catch (NoSuchMethodException e) {
             return null;
         }
 
         return dispatchMethod(mapping, form, request, response, name, method);
-
     }
 
     // ----------------------------------------------------- Protected Methods
 
-
     /**
      * Dispatch to the specified method.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     * @param name The name of the method to invoke
-     *
+     * @param name     The name of the method to invoke
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      */
     protected ActionForward dispatchMethod(ActionMapping mapping,
-                                           ActionForm form,
-                                           HttpServletRequest request,
-                                           HttpServletResponse response,
-                                           String name) throws Exception {
-
+        ActionForm form, HttpServletRequest request,
+        HttpServletResponse response, String name)
+        throws Exception {
         // Make sure we have a valid method name to call.
         // This may be null if the user hacks the query string.
         if (name == null) {
@@ -353,69 +317,68 @@
 
         // Identify the method object to be dispatched to
         Method method = null;
+
         try {
             method = getMethod(name);
-
         } catch (NoSuchMethodException e) {
-            String message = messages.getMessage("dispatch.method",
-                    mapping.getPath(), name);
+            String message =
+                messages.getMessage("dispatch.method", mapping.getPath(), name);
+
             log.error(message, e);
             throw e;
         }
 
         return dispatchMethod(mapping, form, request, response, name, method);
-
     }
 
     /**
      * Dispatch to the specified method.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     * @param name The name of the method to invoke
-     * @param method The method to invoke
-     *
+     * @param name     The name of the method to invoke
+     * @param method   The method to invoke
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      */
     protected ActionForward dispatchMethod(ActionMapping mapping,
-                                           ActionForm form,
-                                           HttpServletRequest request,
-                                           HttpServletResponse response,
-                                           String name,
-                                           Method method) throws Exception {
-
+        ActionForm form, HttpServletRequest request,
+        HttpServletResponse response, String name, Method method)
+        throws Exception {
         ActionForward forward = null;
+
         try {
-            Object[] args = {mapping, form, request, response};
-            forward = (ActionForward) method.invoke(actionInstance, args);
+            Object[] args = { mapping, form, request, response };
 
+            forward = (ActionForward) method.invoke(actionInstance, args);
         } catch (ClassCastException e) {
-            String message = messages.getMessage("dispatch.return",
-                    mapping.getPath(), name);
+            String message =
+                messages.getMessage("dispatch.return", mapping.getPath(), name);
+
             log.error(message, e);
             throw e;
-
         } catch (IllegalAccessException e) {
-            String message = messages.getMessage("dispatch.error",
-                    mapping.getPath(), name);
+            String message =
+                messages.getMessage("dispatch.error", mapping.getPath(), name);
+
             log.error(message, e);
             throw e;
-
         } catch (InvocationTargetException e) {
             // Rethrow the target exception if possible so that the
             // exception handling machinery can deal with it
             Throwable t = e.getTargetException();
+
             if (t instanceof Exception) {
                 throw ((Exception) t);
             } else {
-                String message = messages.getMessage("dispatch.error",
-                        mapping.getPath(), name);
+                String message =
+                    messages.getMessage("dispatch.error", mapping.getPath(),
+                        name);
+
                 log.error(message, e);
                 throw new ServletException(t);
             }
@@ -425,10 +388,9 @@
         return (forward);
     }
 
-
     /**
-     * Introspect the current class to identify a method of the specified
-     * name that accepts the same parameter types as the <code>execute</code>
+     * Introspect the current class to identify a method of the specified name
+     * that accepts the same parameter types as the <code>execute</code>
      * method does.
      *
      * @param name Name of the method to be introspected
@@ -436,22 +398,22 @@
      * @throws NoSuchMethodException if no such method can be found
      */
     protected Method getMethod(String name)
-            throws NoSuchMethodException {
-
+        throws NoSuchMethodException {
         synchronized (methods) {
             Method method = (Method) methods.get(name);
+
             if (method == null) {
                 method = clazz.getMethod(name, types);
                 methods.put(name, method);
             }
+
             return (method);
         }
-
     }
 
     /**
-     * <p>Returns the parameter value as influenced by the selected
-     * {@link #flavor} specified for this <code>ActionDispatcher</code>.</p>
+     * <p>Returns the parameter value as influenced by the selected {@link
+     * #flavor} specified for this <code>ActionDispatcher</code>.</p>
      *
      * @param mapping  The ActionMapping used to select this instance
      * @param form     The optional ActionForm bean for this request (if any)
@@ -460,13 +422,11 @@
      * @return The <code>ActionMapping</code> parameter's value
      * @throws Exception if an error occurs.
      */
-    protected String getParameter(ActionMapping mapping,
-                                  ActionForm form,
-                                  HttpServletRequest request,
-                                  HttpServletResponse response)
-            throws Exception {
-
+    protected String getParameter(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         String parameter = mapping.getParameter();
+
         if ("".equals(parameter)) {
             parameter = null;
         }
@@ -477,9 +437,9 @@
         }
 
         if ((parameter == null)
-                && ((flavor == MAPPING_FLAVOR || flavor == DISPATCH_FLAVOR))) {
+            && ((flavor == MAPPING_FLAVOR) || (flavor == DISPATCH_FLAVOR))) {
             String message =
-                    messages.getMessage("dispatch.handler", mapping.getPath());
+                messages.getMessage("dispatch.handler", mapping.getPath());
 
             log.error(message);
 
@@ -487,28 +447,23 @@
         }
 
         return parameter;
-
     }
 
     /**
      * Returns the method name, given a parameter's value.
      *
      * @param mapping   The ActionMapping used to select this instance
-     * @param form      The optional ActionForm bean for this request (if any)
+     * @param form      The optional ActionForm bean for this request (if
+     *                  any)
      * @param request   The HTTP request we are processing
      * @param response  The HTTP response we are creating
      * @param parameter The <code>ActionMapping</code> parameter's name
      * @return The method's name.
      * @throws Exception if an error occurs.
      */
-    protected String getMethodName(ActionMapping mapping,
-                                   ActionForm form,
-                                   HttpServletRequest request,
-                                   HttpServletResponse response,
-                                   String parameter)
-            throws Exception {
-
-
+    protected String getMethodName(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response,
+        String parameter) throws Exception {
         // "Mapping" flavor, defaults to "method"
         if (flavor == MAPPING_FLAVOR) {
             return parameter;
@@ -523,22 +478,16 @@
      * pressed.  This method will check if the <code>Globals.CANCEL_KEY</code>
      * request attribute has been set, which normally occurs if the cancel
      * button generated by <strong>CancelTag</strong> was pressed by the user
-     * in the current request.  If <code>true</code>, validation performed
-     * by an <strong>ActionForm</strong>'s <code>validate()</code> method
-     * will have been skipped by the controller servlet.</p>
+     * in the current request.  If <code>true</code>, validation performed by
+     * an <strong>ActionForm</strong>'s <code>validate()</code> method will
+     * have been skipped by the controller servlet.</p>
      *
      * @param request The servlet request we are processing
-     *
      * @return <code>true</code> if the current form's cancel button was
      *         pressed; <code>false</code> otherwise.
-     *
      * @see org.apache.struts.taglib.html.CancelTag
      */
     protected boolean isCancelled(HttpServletRequest request) {
-
         return (request.getAttribute(Globals.CANCEL_KEY) != null);
-
     }
-
 }
-

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/BaseAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/BaseAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/BaseAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/BaseAction.java Fri Feb 10 11:42:38 2006
@@ -15,30 +15,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.actions;
 
 import org.apache.struts.action.Action;
 import org.apache.struts.util.MessageResources;
 
 /**
- * <p>BaseAction is provided as an intermediate class for
- * shared funtionality between <code>Action</code> and any
- * stock implementation provided in this package.</p>
+ * <p>BaseAction is provided as an intermediate class for shared funtionality
+ * between <code>Action</code> and any stock implementation provided in this
+ * package.</p>
  *
  * @version $Rev$ $Date$
  * @since Struts 1.3
  */
-
 public abstract class BaseAction extends Action {
-
     /**
      * The message resources for this package.
      */
     protected static MessageResources messages =
-            MessageResources.getMessageResources(
-                    "org.apache.struts.actions.LocalStrings");
-
-
+        MessageResources.getMessageResources(
+            "org.apache.struts.actions.LocalStrings");
 }

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java Fri Feb 10 11:42:38 2006
@@ -15,122 +15,113 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.actions;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import java.util.HashMap;
+
 /**
- * <p>An abstract <strong>Action</strong> that dispatches to a public
- * method that is named by the request parameter whose name is specified
- * by the <code>parameter</code> property of the corresponding
- * ActionMapping.  This Action is useful for developers who prefer to
- * combine many similar actions into a single Action class, in order to
- * simplify their application design.</p>
- *
- * <p>To configure the use of this action in your
- * <code>struts-config.xml</code> file, create an entry like this:</p>
- *
- * <code>
- *   &lt;action path="/saveSubscription"
- *           type="org.apache.struts.actions.DispatchAction"
- *           name="subscriptionForm"
- *          scope="request"
- *          input="/subscription.jsp"
- *      parameter="method"/&gt;
- * </code>
- *
- * <p>which will use the value of the request parameter named "method"
- * to pick the appropriate "execute" method, which must have the same
- * signature (other than method name) of the standard Action.execute
- * method.  For example, you might have the following three methods in the
- * same action:</p>
+ * <p>An abstract <strong>Action</strong> that dispatches to a public method
+ * that is named by the request parameter whose name is specified by the
+ * <code>parameter</code> property of the corresponding ActionMapping.  This
+ * Action is useful for developers who prefer to combine many similar actions
+ * into a single Action class, in order to simplify their application
+ * design.</p>
+ *
+ * <p>To configure the use of this action in your <code>struts-config.xml</code>
+ * file, create an entry like this:</p>
+ *
+ * <code> &lt;action path="/saveSubscription" type="org.apache.struts.actions.DispatchAction"
+ * name="subscriptionForm" scope="request" input="/subscription.jsp"
+ * parameter="method"/&gt; </code>
+ *
+ * <p>which will use the value of the request parameter named "method" to pick
+ * the appropriate "execute" method, which must have the same signature (other
+ * than method name) of the standard Action.execute method.  For example, you
+ * might have the following three methods in the same action:</p>
+ *
  * <ul>
+ *
  * <li>public ActionForward delete(ActionMapping mapping, ActionForm form,
- *     HttpServletRequest request, HttpServletResponse response)
- *     throws Exception</li>
+ * HttpServletRequest request, HttpServletResponse response) throws
+ * Exception</li>
+ *
  * <li>public ActionForward insert(ActionMapping mapping, ActionForm form,
- *     HttpServletRequest request, HttpServletResponse response)
- *     throws Exception</li>
+ * HttpServletRequest request, HttpServletResponse response) throws
+ * Exception</li>
+ *
  * <li>public ActionForward update(ActionMapping mapping, ActionForm form,
- *     HttpServletRequest request, HttpServletResponse response)
- *     throws Exception</li>
+ * HttpServletRequest request, HttpServletResponse response) throws
+ * Exception</li>
+ *
  * </ul>
+ *
  * <p>and call one of the methods with a URL like this:</p>
- * <code>
- *   http://localhost:8080/myapp/saveSubscription.do?method=update
- * </code>
- *
- * <p><strong>NOTE</strong> - All of the other mapping characteristics of
- * this action must be shared by the various handlers.  This places some
- * constraints over what types of handlers may reasonably be packaged into
- * the same <code>DispatchAction</code> subclass.</p>
+ *
+ * <p> <code> http://localhost:8080/myapp/saveSubscription.do?method=update
+ * </code></p>
+ *
+ * <p><strong>NOTE</strong> - All of the other mapping characteristics of this
+ * action must be shared by the various handlers.  This places some
+ * constraints over what types of handlers may reasonably be packaged into the
+ * same <code>DispatchAction</code> subclass.</p>
  *
  * <p><strong>NOTE</strong> - If the value of the request parameter is empty,
- * a method named <code>unspecified</code> is called. The default action is
- * to throw an exception. If the request was cancelled (a
+ * a method named <code>unspecified</code> is called. The default action is to
+ * throw an exception. If the request was cancelled (a
  * <code>html:cancel</code> button was pressed), the custom handler
  * <code>cancelled</code> will be used instead. You can also override the
  * <code>getMethodName</code> method to override the action's default handler
  * selection.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-14 21:27:02 -0400 (Sat, 14 May 2005)
+ *          $
  */
 public abstract class DispatchAction extends BaseAction {
-
+    /**
+     * Commons Logging instance.
+     */
+    protected static Log log = LogFactory.getLog(DispatchAction.class);
 
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * The Class instance of this <code>DispatchAction</code> class.
      */
     protected Class clazz = this.getClass();
 
-
     /**
-     * Commons Logging instance.
-     */
-    protected static Log log = LogFactory.getLog(DispatchAction.class);
-
-
-    /**
-     * The set of Method objects we have introspected for this class,
-     * keyed by method name.  This collection is populated as different
-     * methods are called, so that introspection needs to occur only
-     * once per method name.
+     * The set of Method objects we have introspected for this class, keyed by
+     * method name.  This collection is populated as different methods are
+     * called, so that introspection needs to occur only once per method
+     * name.
      */
     protected HashMap methods = new HashMap();
 
-
     /**
      * The set of argument type classes for the reflected method call.  These
      * are the same for all calls, so calculate them only once.
      */
     protected Class[] types =
-            {
-                ActionMapping.class,
-                ActionForm.class,
-                HttpServletRequest.class,
-                HttpServletResponse.class};
-
-
+        {
+            ActionMapping.class, ActionForm.class, HttpServletRequest.class,
+            HttpServletResponse.class
+        };
 
     // --------------------------------------------------------- Public Methods
 
-
     /**
      * Process the specified HTTP request, and create the corresponding HTTP
      * response (or forward to another web component that will create it).
@@ -138,32 +129,31 @@
      * control should be forwarded, or <code>null</code> if the response has
      * already been completed.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The HTTP request we are processing
      * @param response The HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if an exception occurs
+     * @throws Exception if an exception occurs
      */
-    public ActionForward execute(ActionMapping mapping,
-                                 ActionForm form,
-                                 HttpServletRequest request,
-                                 HttpServletResponse response)
-            throws Exception {
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         if (isCancelled(request)) {
             ActionForward af = cancelled(mapping, form, request, response);
+
             if (af != null) {
                 return af;
             }
         }
+
         // Identify the request parameter containing the method name
         String parameter = mapping.getParameter();
+
         if (parameter == null) {
-            String message = messages.getMessage("dispatch.handler",
-                    mapping.getPath());
+            String message =
+                messages.getMessage("dispatch.handler", mapping.getPath());
 
             log.error(message);
 
@@ -171,57 +161,43 @@
         }
 
         // Get the method's name. This could be overridden in subclasses.
-        String name = getMethodName(mapping, form, request, response,
-                parameter);
+        String name =
+            getMethodName(mapping, form, request, response, parameter);
 
+        // Prevent recursive calls
+        if ("execute".equals(name) || "perform".equals(name)) {
+            String message =
+                messages.getMessage("dispatch.recursive", mapping.getPath());
 
-    // Prevent recursive calls
-    if ("execute".equals(name) || "perform".equals(name)) {
-        String message =
-            messages.getMessage("dispatch.recursive", mapping.getPath());
-
-        log.error(message);
-        throw new ServletException(message);
-    }
-
+            log.error(message);
+            throw new ServletException(message);
+        }
 
         // Invoke the named method, and return the result
         return dispatchMethod(mapping, form, request, response, name);
-
     }
 
-
-
-
     /**
      * Method which is dispatched to when there is no value for specified
      * request parameter included in the request.  Subclasses of
-     * <code>DispatchAction</code> should override this method if they wish
-     * to provide default behavior different than throwing a ServletException.
+     * <code>DispatchAction</code> should override this method if they wish to
+     * provide default behavior different than throwing a ServletException.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      */
-    protected ActionForward unspecified(
-            ActionMapping mapping,
-            ActionForm form,
-            HttpServletRequest request,
-            HttpServletResponse response)
-            throws Exception {
-
+    protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         String message =
-                messages.getMessage(
-                        "dispatch.parameter",
-                        mapping.getPath(),
-                        mapping.getParameter());
+            messages.getMessage("dispatch.parameter", mapping.getPath(),
+                mapping.getParameter());
 
         log.error(message);
 
@@ -229,58 +205,47 @@
     }
 
     /**
-     * Method which is dispatched to when the request is a cancel button submit.
-     * Subclasses of <code>DispatchAction</code> should override this method if
-     * they wish to provide default behavior different than returning null.
-     *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * Method which is dispatched to when the request is a cancel button
+     * submit. Subclasses of <code>DispatchAction</code> should override this
+     * method if they wish to provide default behavior different than
+     * returning null.
+     *
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
-     *
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      * @since Struts 1.2.0
      */
-    protected ActionForward cancelled(ActionMapping mapping,
-                                      ActionForm form,
-                                      HttpServletRequest request,
-                                      HttpServletResponse response)
-            throws Exception {
-
+    protected ActionForward cancelled(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         return null;
     }
 
     // ----------------------------------------------------- Protected Methods
 
-
     /**
      * Dispatch to the specified method.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The non-HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The non-HTTP request we are processing
      * @param response The non-HTTP response we are creating
-     * @param name The name of the method to invoke
-     *
+     * @param name     The name of the method to invoke
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if the application business logic throws an
-     *                      exception.
-     *
+     * @throws Exception if the application business logic throws an
+     *                   exception.
      * @since Struts 1.1
      */
     protected ActionForward dispatchMethod(ActionMapping mapping,
-                                           ActionForm form,
-                                           HttpServletRequest request,
-                                           HttpServletResponse response,
-                                           String name) throws Exception {
-
+        ActionForm form, HttpServletRequest request,
+        HttpServletResponse response, String name)
+        throws Exception {
         // Make sure we have a valid method name to call.
         // This may be null if the user hacks the query string.
         if (name == null) {
@@ -289,42 +254,47 @@
 
         // Identify the method object to be dispatched to
         Method method = null;
+
         try {
             method = getMethod(name);
-
         } catch (NoSuchMethodException e) {
-            String message = messages.getMessage("dispatch.method",
-                    mapping.getPath(), name);
+            String message =
+                messages.getMessage("dispatch.method", mapping.getPath(), name);
+
             log.error(message, e);
             throw e;
         }
 
         ActionForward forward = null;
+
         try {
-            Object[] args = {mapping, form, request, response};
-            forward = (ActionForward) method.invoke(this, args);
+            Object[] args = { mapping, form, request, response };
 
+            forward = (ActionForward) method.invoke(this, args);
         } catch (ClassCastException e) {
-            String message = messages.getMessage("dispatch.return",
-                    mapping.getPath(), name);
+            String message =
+                messages.getMessage("dispatch.return", mapping.getPath(), name);
+
             log.error(message, e);
             throw e;
-
         } catch (IllegalAccessException e) {
-            String message = messages.getMessage("dispatch.error",
-                    mapping.getPath(), name);
+            String message =
+                messages.getMessage("dispatch.error", mapping.getPath(), name);
+
             log.error(message, e);
             throw e;
-
         } catch (InvocationTargetException e) {
             // Rethrow the target exception if possible so that the
             // exception handling machinery can deal with it
             Throwable t = e.getTargetException();
+
             if (t instanceof Exception) {
                 throw ((Exception) t);
             } else {
-                String message = messages.getMessage("dispatch.error",
-                        mapping.getPath(), name);
+                String message =
+                    messages.getMessage("dispatch.error", mapping.getPath(),
+                        name);
+
                 log.error(message, e);
                 throw new ServletException(t);
             }
@@ -334,57 +304,47 @@
         return (forward);
     }
 
-
     /**
-     * Introspect the current class to identify a method of the specified
-     * name that accepts the same parameter types as the <code>execute</code>
+     * Introspect the current class to identify a method of the specified name
+     * that accepts the same parameter types as the <code>execute</code>
      * method does.
      *
      * @param name Name of the method to be introspected
-     *
      * @return The method with the specified name.
-     *
-     * @exception NoSuchMethodException if no such method can be found
+     * @throws NoSuchMethodException if no such method can be found
      */
     protected Method getMethod(String name)
-            throws NoSuchMethodException {
-
+        throws NoSuchMethodException {
         synchronized (methods) {
             Method method = (Method) methods.get(name);
+
             if (method == null) {
                 method = clazz.getMethod(name, types);
                 methods.put(name, method);
             }
+
             return (method);
         }
-
     }
 
     /**
      * Returns the method name, given a parameter's value.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The HTTP request we are processing
-     * @param response The HTTP response we are creating
+     * @param mapping   The ActionMapping used to select this instance
+     * @param form      The optional ActionForm bean for this request (if
+     *                  any)
+     * @param request   The HTTP request we are processing
+     * @param response  The HTTP response we are creating
      * @param parameter The <code>ActionMapping</code> parameter's name
-     *
      * @return The method's name.
-     *
      * @throws Exception if an error occurs.
-     *
      * @since Struts 1.2.0
      */
-    protected String getMethodName(ActionMapping mapping,
-                                   ActionForm form,
-                                   HttpServletRequest request,
-                                   HttpServletResponse response,
-                                   String parameter)
-            throws Exception {
-
+    protected String getMethodName(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response,
+        String parameter) throws Exception {
         // Identify the method name to be dispatched to.
         // dispatchMethod() will call unspecified() if name is null
         return request.getParameter(parameter);
     }
-
 }

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/DownloadAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/DownloadAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/DownloadAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/DownloadAction.java Fri Feb 10 11:42:38 2006
@@ -15,9 +15,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.struts.actions;
 
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
 
-package org.apache.struts.actions;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import java.io.BufferedInputStream;
 import java.io.File;
@@ -26,15 +32,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
-
 /**
  * This is an abstract base class that minimizes the amount of special coding
  * that needs to be written to download a file. All that is required to use
@@ -47,7 +44,6 @@
  * @since Struts 1.2.6
  */
 public abstract class DownloadAction extends BaseAction {
-
     /**
      * If the <code>getBufferSize()</code> method is not overridden, this is
      * the buffer size that will be used to transfer the data to the servlet
@@ -60,23 +56,22 @@
      * by this action. This method must be implemented by an extending class.
      *
      * @param mapping  The ActionMapping used to select this instance.
-     * @param form     The optional ActionForm bean for this request (if any).
+     * @param form     The optional ActionForm bean for this request (if
+     *                 any).
      * @param request  The HTTP request we are processing.
      * @param response The HTTP response we are creating.
-     *
      * @return The information for the file to be downloaded.
-     *
      * @throws Exception if an exception occurs.
      */
     protected abstract StreamInfo getStreamInfo(ActionMapping mapping,
-            ActionForm form, HttpServletRequest request,
-            HttpServletResponse response)
-            throws Exception;
+        ActionForm form, HttpServletRequest request,
+        HttpServletResponse response)
+        throws Exception;
 
     /**
      * Returns the size of the buffer to be used in transferring the data to
-     * the servlet output stream. This method may be overridden by an extending
-     * class in order to customize the buffer size.
+     * the servlet output stream. This method may be overridden by an
+     * extending class in order to customize the buffer size.
      *
      * @return The size of the transfer buffer, in bytes.
      */
@@ -92,19 +87,17 @@
      * already been completed.
      *
      * @param mapping  The ActionMapping used to select this instance.
-     * @param form     The optional ActionForm bean for this request (if any).
+     * @param form     The optional ActionForm bean for this request (if
+     *                 any).
      * @param request  The HTTP request we are processing.
      * @param response The HTTP response we are creating.
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
      * @throws Exception if an exception occurs.
      */
     public ActionForward execute(ActionMapping mapping, ActionForm form,
-            HttpServletRequest request, HttpServletResponse response)
-            throws Exception {
-
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
         StreamInfo info = getStreamInfo(mapping, form, request, response);
         String contentType = info.getContentType();
         InputStream stream = info.getInputStream();
@@ -128,20 +121,20 @@
      *
      * @param input  The <code>InputStream</code> to read from.
      * @param output The <code>OutputStream</code> to write to.
-     *
      * @return the number of bytes copied
-     *
      * @throws IOException In case of an I/O problem
      */
     public int copy(InputStream input, OutputStream output)
-            throws IOException {
+        throws IOException {
         byte[] buffer = new byte[getBufferSize()];
         int count = 0;
         int n = 0;
+
         while (-1 != (n = input.read(buffer))) {
             output.write(buffer, 0, n);
             count += n;
         }
+
         return count;
     }
 
@@ -150,7 +143,6 @@
      * <code>DownloadAction</code>.
      */
     public static interface StreamInfo {
-
         /**
          * Returns the content type of the stream to be downloaded.
          *
@@ -159,22 +151,21 @@
         String getContentType();
 
         /**
-         * Returns an input stream on the content to be downloaded. This stream
-         * will be closed by the <code>DownloadAction</code>.
+         * Returns an input stream on the content to be downloaded. This
+         * stream will be closed by the <code>DownloadAction</code>.
          *
          * @return The input stream for the content to be downloaded.
-         *
          * @throws IOException if an error occurs
          */
-        InputStream getInputStream() throws IOException;
+        InputStream getInputStream()
+            throws IOException;
     }
 
     /**
-     * A concrete implementation of the <code>StreamInfo</code> interface which
-     * simplifies the downloading of a file from the disk.
+     * A concrete implementation of the <code>StreamInfo</code> interface
+     * which simplifies the downloading of a file from the disk.
      */
     public static class FileStreamInfo implements StreamInfo {
-
         /**
          * The content type for this stream.
          */
@@ -211,22 +202,22 @@
          * will be closed by the <code>DownloadAction</code>.
          *
          * @return The input stream for the file to be downloaded.
-         *
          * @throws IOException if an error occurs
          */
-        public InputStream getInputStream() throws IOException {
+        public InputStream getInputStream()
+            throws IOException {
             FileInputStream fis = new FileInputStream(file);
             BufferedInputStream bis = new BufferedInputStream(fis);
+
             return bis;
         }
     }
 
     /**
-     * A concrete implementation of the <code>StreamInfo</code> interface which
-     * simplifies the downloading of a web application resource.
+     * A concrete implementation of the <code>StreamInfo</code> interface
+     * which simplifies the downloading of a web application resource.
      */
     public static class ResourceStreamInfo implements StreamInfo {
-
         /**
          * The content type for this stream.
          */
@@ -251,7 +242,7 @@
          * @param path        The path to the resource to be downloaded.
          */
         public ResourceStreamInfo(String contentType, ServletContext context,
-                String path) {
+            String path) {
             this.contentType = contentType;
             this.context = context;
             this.path = path;
@@ -267,14 +258,14 @@
         }
 
         /**
-         * Returns an input stream on the resource to be downloaded. This stream
-         * will be closed by the <code>DownloadAction</code>.
+         * Returns an input stream on the resource to be downloaded. This
+         * stream will be closed by the <code>DownloadAction</code>.
          *
          * @return The input stream for the resource to be downloaded.
-         *
          * @throws IOException if an error occurs
          */
-        public InputStream getInputStream() throws IOException {
+        public InputStream getInputStream()
+            throws IOException {
             return context.getResourceAsStream(path);
         }
     }

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/ForwardAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/ForwardAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/ForwardAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/ForwardAction.java Fri Feb 10 11:42:38 2006
@@ -15,48 +15,40 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.actions;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 /**
- * <p>An <strong>Action</strong> that forwards to the context-relative
- * URI specified by the <code>parameter</code> property of our associated
+ * <p>An <strong>Action</strong> that forwards to the context-relative URI
+ * specified by the <code>parameter</code> property of our associated
  * <code>ActionMapping</code>.  This can be used to integrate Struts with
  * other business logic components that are implemented as servlets (or JSP
  * pages), but still take advantage of the Struts controller servlet's
  * functionality (such as processing of form beans).</p>
  *
- * <p>To configure the use of this Action in your
- * <code>struts-config.xml</code> file, create an entry like this:</p>
+ * <p>To configure the use of this Action in your <code>struts-config.xml</code>
+ * file, create an entry like this:</p>
  *
- * <code>
- *   &lt;action path="/saveSubscription"
- *           type="org.apache.struts.actions.ForwardAction"
- *           name="subscriptionForm"
- *          scope="request"
- *          input="/subscription.jsp"
- *      parameter="/path/to/processing/servlet"/&gt;
- * </code>
+ * <code> &lt;action path="/saveSubscription" type="org.apache.struts.actions.ForwardAction"
+ * name="subscriptionForm" scope="request" input="/subscription.jsp"
+ * parameter="/path/to/processing/servlet"/&gt; </code>
  *
  * <p>which will forward control to the context-relative URI specified by the
  * <code>parameter</code> attribute.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-14 17:24:39 -0400 (Sun, 14 Aug 2005)
+ *          $
  */
 public class ForwardAction extends BaseAction {
-
-
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * Process the specified HTTP request, and create the corresponding HTTP
      * response (or forward to another web component that will create it).
@@ -64,23 +56,17 @@
      * control should be forwarded, or <code>null</code> if the response has
      * already been completed.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The HTTP request we are processing
      * @param response The HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if an error occurs
+     * @throws Exception if an error occurs
      */
-    public ActionForward execute(
-        ActionMapping mapping,
-        ActionForm form,
-        HttpServletRequest request,
-        HttpServletResponse response)
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
         throws Exception {
-
         // Create a RequestDispatcher the corresponding resource
         String path = mapping.getParameter();
 
@@ -93,7 +79,4 @@
 
         return retVal;
     }
-
-
 }
-

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/IncludeAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/IncludeAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/IncludeAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/IncludeAction.java Fri Feb 10 11:42:38 2006
@@ -15,49 +15,41 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.actions;
 
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-
 /**
- * <p>An <strong>Action</strong> that includes the context-relative
- * URI specified by the <code>parameter</code> property of our associated
+ * <p>An <strong>Action</strong> that includes the context-relative URI
+ * specified by the <code>parameter</code> property of our associated
  * <code>ActionMapping</code>.  This can be used to integrate Struts with
  * other business logic components that are implemented as servlets (or JSP
  * pages), but still take advantage of the Struts controller servlet's
  * functionality (such as processing of form beans).</p>
  *
- * <p>To configure the use of this Action in your
- * <code>struts-config.xml</code> file, create an entry like this:</p>
+ * <p>To configure the use of this Action in your <code>struts-config.xml</code>
+ * file, create an entry like this:</p>
  *
- * <code>
- *   &lt;action path="/saveSubscription"
- *           type="org.apache.struts.actions.IncludeAction"
- *           name="subscriptionForm"
- *          scope="request"
- *          input="/subscription.jsp"
- *      parameter="/path/to/processing/servlet"&gt;
- * </code>
+ * <code> &lt;action path="/saveSubscription" type="org.apache.struts.actions.IncludeAction"
+ * name="subscriptionForm" scope="request" input="/subscription.jsp"
+ * parameter="/path/to/processing/servlet"&gt; </code>
  *
  * <p>which will include the context-relative URI specified by the
  * <code>parameter</code> attribute.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-11-09 00:11:45 -0500 (Wed, 09 Nov 2005)
+ *          $
  */
 public class IncludeAction extends BaseAction {
-
-
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * Process the specified HTTP request, and create the corresponding HTTP
      * response (or forward to another web component that will create it).
@@ -65,25 +57,20 @@
      * control should be forwarded, or <code>null</code> if the response has
      * already been completed.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The HTTP request we are processing
      * @param response The HTTP response we are creating
-     *
      * @return The forward to which control should be transferred, or
      *         <code>null</code> if the response has been completed.
-     *
-     * @exception Exception if an error occurs
+     * @throws Exception if an error occurs
      */
-    public ActionForward execute(
-        ActionMapping mapping,
-        ActionForm form,
-        HttpServletRequest request,
-        HttpServletResponse response)
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
         throws Exception {
-
         // Create a RequestDispatcher the corresponding resource
         String path = mapping.getParameter();
+
         if (path == null) {
             throw new ServletException(messages.getMessage("include.path"));
         }
@@ -100,9 +87,5 @@
 
         // Tell the controller servlet that the response has been created
         return (null);
-
     }
-
-
 }
-

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/LocaleAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/LocaleAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/LocaleAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/LocaleAction.java Fri Feb 10 11:42:38 2006
@@ -15,16 +15,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.actions;
 
-import java.util.Locale;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,81 +25,70 @@
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import java.util.Locale;
 
 /**
- * Implementation of <strong>Action</strong> that changes the user's
- * {@link java.util.Locale} and forwards to a page, based on request level
- * parameters that are set  (language, country, &amp; page).
- *
-*/
+ * Implementation of <strong>Action</strong> that changes the user's {@link
+ * java.util.Locale} and forwards to a page, based on request level parameters
+ * that are set  (language, country, &amp; page).
+ */
 public final class LocaleAction extends BaseAction {
-
     /**
      * Commons Logging instance.
      */
-    private Log log = LogFactory.getFactory().getInstance(
-            this.getClass().getName());
+    private Log log =
+        LogFactory.getFactory().getInstance(this.getClass().getName());
 
     /**
-     * <p>
-     * Change the user's {@link java.util.Locale} based on {@link ActionForm}
-     * properties.
-     * </p>
-     * <p>
-     * This <code>Action</code> looks for <code>language</code> and
-     * <code>country</code> properties on the given form, constructs an
-     * appropriate Locale object, and sets it as the Struts Locale for this
-     * user's session.
-     * Any <code>ActionForm</code>, including a
-     * {@link org.apache.struts.action.DynaActionForm}, may be used.
-     * </p>
-     * <p>
-     * If a <code>page</code> property is also provided, then after
-     * setting the Locale, control is forwarded to that URI path.
-     * Otherwise, control is forwarded to "success".
-     * </p>
+     * <p> Change the user's {@link java.util.Locale} based on {@link
+     * ActionForm} properties. </p> <p> This <code>Action</code> looks for
+     * <code>language</code> and <code>country</code> properties on the given
+     * form, constructs an appropriate Locale object, and sets it as the
+     * Struts Locale for this user's session. Any <code>ActionForm</code>,
+     * including a {@link org.apache.struts.action.DynaActionForm}, may be
+     * used. </p> <p> If a <code>page</code> property is also provided, then
+     * after setting the Locale, control is forwarded to that URI path.
+     * Otherwise, control is forwarded to "success". </p>
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The HTTP request we are processing
      * @param response The HTTP response we are creating
-     *
      * @return Action to forward to
-     * @exception Exception if an input/output error or servlet exception occurs
+     * @throws Exception if an input/output error or servlet exception occurs
      */
-    public ActionForward execute(ActionMapping mapping,
-                 ActionForm form,
-                 HttpServletRequest request,
-                 HttpServletResponse response)
-    throws Exception {
-
-    // Extract attributes we will need
-    HttpSession session = request.getSession();
-    Locale locale = getLocale(request);
-
-    String language = null;
-    String country = null;
-    String page = null;
-
-    try {
-            language = (String)
-              PropertyUtils.getSimpleProperty(form, "language");
-            country = (String)
-              PropertyUtils.getSimpleProperty(form, "country");
-            page = (String)
-              PropertyUtils.getSimpleProperty(form, "page");
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
+        // Extract attributes we will need
+        HttpSession session = request.getSession();
+        Locale locale = getLocale(request);
+
+        String language = null;
+        String country = null;
+        String page = null;
+
+        try {
+            language =
+                (String) PropertyUtils.getSimpleProperty(form, "language");
+            country = (String) PropertyUtils.getSimpleProperty(form, "country");
+            page = (String) PropertyUtils.getSimpleProperty(form, "page");
         } catch (Exception e) {
-           log.error(e.getMessage(), e);
+            log.error(e.getMessage(), e);
         }
 
-        boolean isLanguage = (language != null && language.length() > 0);
-        boolean isCountry = (country != null && country.length() > 0);
+        boolean isLanguage = ((language != null) && (language.length() > 0));
+        boolean isCountry = ((country != null) && (country.length() > 0));
 
         if ((isLanguage) && (isCountry)) {
-           locale = new java.util.Locale(language, country);
+            locale = new java.util.Locale(language, country);
         } else if (isLanguage) {
-           locale = new java.util.Locale(language, "");
-    }
+            locale = new java.util.Locale(language, "");
+        }
 
         session.setAttribute(Globals.LOCALE_KEY, locale);
 
@@ -116,7 +97,5 @@
         } else {
             return new ActionForward(page);
         }
-
     }
-
 }

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java?rev=376812&r1=376811&r2=376812&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java Fri Feb 10 11:42:38 2006
@@ -15,18 +15,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.actions;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.struts.Globals;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
@@ -35,14 +25,22 @@
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.util.MessageResources;
 
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
 /**
- *  <p>
- *  An abstract <strong>Action</strong> that dispatches to the subclass mapped
- *  <code>execute</code> method. This is useful in
- *  cases where an HTML form has multiple submit buttons with the same name. The
- *  button name is specified by the <code>parameter</code> property of the
- *  corresponding ActionMapping. To configure the use of this action in your
- *  <code>struts-config.xml</code> file, create an entry like this:</p> <pre>
+ * <p> An abstract <strong>Action</strong> that dispatches to the subclass
+ * mapped <code>execute</code> method. This is useful in cases where an HTML
+ * form has multiple submit buttons with the same name. The button name is
+ * specified by the <code>parameter</code> property of the corresponding
+ * ActionMapping. To configure the use of this action in your
+ * <code>struts-config.xml</code> file, create an entry like this:</p> <pre>
  *   &lt;action path="/test"
  *           type="org.example.MyAction"
  *           name="MyForm"
@@ -51,14 +49,14 @@
  *      parameter="method"/&gt;
  * </pre> <p>
  *
- *  which will use the value of the request parameter named "method" to locate
- *  the corresponding key in ApplicationResources. For example, you might have
- *  the following ApplicationResources.properties:</p> <pre>
+ * which will use the value of the request parameter named "method" to locate
+ * the corresponding key in ApplicationResources. For example, you might have
+ * the following ApplicationResources.properties:</p> <pre>
  *    button.add=Add Record
  *    button.delete=Delete Record
  *  </pre><p>
  *
- *  And your JSP would have the following format for submit buttons:</p> <pre>
+ * And your JSP would have the following format for submit buttons:</p> <pre>
  *   &lt;html:form action="/test"&gt;
  *    &lt;html:submit property="method"&gt;
  *      &lt;bean:message key="button.add"/&gt;
@@ -69,8 +67,8 @@
  *  &lt;/html:form&gt;
  *  </pre> <p>
  *
- *  Your subclass must implement both getKeyMethodMap and the
- *  methods defined in the map. An example of such implementations are:</p>
+ * Your subclass must implement both getKeyMethodMap and the methods defined
+ * in the map. An example of such implementations are:</p>
  * <pre>
  *  protected Map getKeyMethodMap() {
  *      Map map = new HashMap();
@@ -97,17 +95,14 @@
  *      return mapping.findForward("success");
  *  }
  * </pre>
- * <p>
- *  <strong>Notes</strong> - If duplicate values exist for the keys returned by
- *  getKeys, only the first one found will be returned. If no corresponding key
- *  is found then an exception will be thrown. You can override the
- *  method <code>unspecified</code> to provide a custom handler. If the submit
- *  was cancelled (a <code>html:cancel</code> button was pressed), the custom
- *  handler <code>cancelled</code> will be used instead.
- *
+ * <p> <strong>Notes</strong> - If duplicate values exist for the keys
+ * returned by getKeys, only the first one found will be returned. If no
+ * corresponding key is found then an exception will be thrown. You can
+ * override the method <code>unspecified</code> to provide a custom handler.
+ * If the submit was cancelled (a <code>html:cancel</code> button was
+ * pressed), the custom handler <code>cancelled</code> will be used instead.
  */
 public abstract class LookupDispatchAction extends DispatchAction {
-
     /**
      * Reverse lookup map from resource value to resource key.
      */
@@ -121,75 +116,75 @@
     // ---------------------------------------------------------- Public Methods
 
     /**
-     *  Process the specified HTTP request, and create the corresponding HTTP
-     *  response (or forward to another web component that will create it).
-     *  Return an <code>ActionForward</code> instance describing where and how
-     *  control should be forwarded, or <code>null</code> if the response has
-     *  already been completed.
+     * Process the specified HTTP request, and create the corresponding HTTP
+     * response (or forward to another web component that will create it).
+     * Return an <code>ActionForward</code> instance describing where and how
+     * control should be forwarded, or <code>null</code> if the response has
+     * already been completed.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param request The HTTP request we are processing
+     * @param mapping  The ActionMapping used to select this instance
+     * @param request  The HTTP request we are processing
      * @param response The HTTP response we are creating
-     * @param form The optional ActionForm bean for this request (if any)
+     * @param form     The optional ActionForm bean for this request (if any)
      * @return Describes where and how control should be forwarded.
-     * @exception Exception if an error occurs
+     * @throws Exception if an error occurs
      */
-    public ActionForward execute(
-        ActionMapping mapping,
-        ActionForm form,
-        HttpServletRequest request,
-        HttpServletResponse response)
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
         throws Exception {
-
         if (isCancelled(request)) {
             ActionForward af = cancelled(mapping, form, request, response);
+
             if (af != null) {
                 return af;
             }
         }
+
         // Identify the request parameter containing the method name
         String parameter = mapping.getParameter();
+
         if (parameter == null) {
-            String message = messages.getMessage("dispatch.handler",
-                    mapping.getPath());
+            String message =
+                messages.getMessage("dispatch.handler", mapping.getPath());
+
             throw new ServletException(message);
         }
 
         // Identify the string to lookup
-        String methodName = getMethodName(mapping, form, request, response,
-                parameter);
+        String methodName =
+            getMethodName(mapping, form, request, response, parameter);
 
         return dispatchMethod(mapping, form, request, response, methodName);
-
     }
 
     /**
      * This is the first time this Locale is used so build the reverse lookup
-     * Map. Search for message keys in all configured MessageResources for
-     * the current module.
+     * Map. Search for message keys in all configured MessageResources for the
+     * current module.
      *
-     * @param request The HTTP request we are processing
+     * @param request    The HTTP request we are processing
      * @param userLocale The locale for this request
-     *
      * @return The reverse lookup map for the specified locale.
      */
     private Map initLookupMap(HttpServletRequest request, Locale userLocale) {
         Map lookupMap = new HashMap();
+
         this.keyMethodMap = this.getKeyMethodMap();
 
         ModuleConfig moduleConfig =
-                (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
+            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
 
         MessageResourcesConfig[] mrc =
-                moduleConfig.findMessageResourcesConfigs();
+            moduleConfig.findMessageResourcesConfigs();
 
         // Look through all module's MessageResources
         for (int i = 0; i < mrc.length; i++) {
-            MessageResources resources = this.getResources(request,
-                    mrc[i].getKey());
+            MessageResources resources =
+                this.getResources(request, mrc[i].getKey());
 
             // Look for key in MessageResources
             Iterator iter = this.keyMethodMap.keySet().iterator();
+
             while (iter.hasNext()) {
                 String key = (String) iter.next();
                 String text = resources.getMessage(userLocale, key);
@@ -217,22 +212,19 @@
      * @param request The HTTP request we are processing
      * @param keyName The parameter name to use as the properties key
      * @param mapping The ActionMapping used to select this instance
-     *
      * @return The method's localized name.
      * @throws ServletException if keyName cannot be resolved
      * @since Struts 1.2.0
      */
-    protected String getLookupMapName(
-        HttpServletRequest request,
-        String keyName,
-        ActionMapping mapping)
+    protected String getLookupMapName(HttpServletRequest request,
+        String keyName, ActionMapping mapping)
         throws ServletException {
-
         // Based on this request's Locale get the lookupMap
         Map lookupMap = null;
 
         synchronized (localeMap) {
             Locale userLocale = this.getLocale(request);
+
             lookupMap = (Map) this.localeMap.get(userLocale);
 
             if (lookupMap == null) {
@@ -243,17 +235,22 @@
 
         // Find the key for the resource
         String key = (String) lookupMap.get(keyName);
+
         if (key == null) {
-            String message = messages.getMessage(
-                    "dispatch.resource", mapping.getPath(), keyName);
+            String message =
+                messages.getMessage("dispatch.resource", mapping.getPath(),
+                    keyName);
+
             throw new ServletException(message);
         }
 
         // Find the method name
         String methodName = (String) keyMethodMap.get(key);
+
         if (methodName == null) {
-            String message = messages.getMessage(
-                    "dispatch.lookup", mapping.getPath(), key);
+            String message =
+                messages.getMessage("dispatch.lookup", mapping.getPath(), key);
+
             throw new ServletException(message);
         }
 
@@ -263,30 +260,24 @@
     /**
      * Returns the method name, given a parameter's value.
      *
-     * @param mapping The ActionMapping used to select this instance
-     * @param form The optional ActionForm bean for this request (if any)
-     * @param request The HTTP request we are processing
-     * @param response The HTTP response we are creating
+     * @param mapping   The ActionMapping used to select this instance
+     * @param form      The optional ActionForm bean for this request (if
+     *                  any)
+     * @param request   The HTTP request we are processing
+     * @param response  The HTTP response we are creating
      * @param parameter The <code>ActionMapping</code> parameter's name
-     *
      * @return The method's name.
-     *
      * @throws Exception if an error occurs
-     *
      * @since Struts 1.2.0
      */
-    protected String getMethodName(
-        ActionMapping mapping,
-        ActionForm form,
-        HttpServletRequest request,
-        HttpServletResponse response,
-        String parameter)
-        throws Exception {
-
+    protected String getMethodName(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response,
+        String parameter) throws Exception {
         // Identify the method name to be dispatched to.
         // dispatchMethod() will call unspecified() if name is null
         String keyName = request.getParameter(parameter);
-        if (keyName == null || keyName.length() == 0) {
+
+        if ((keyName == null) || (keyName.length() == 0)) {
             return null;
         }
 
@@ -294,6 +285,4 @@
 
         return methodName;
     }
-
-
 }



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