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/09 15:11:14 UTC

svn commit: r376300 [5/6] - in /struts/action/trunk/src/java/org/apache/struts: ./ action/ chain/ chain/commands/ chain/commands/generic/ chain/commands/servlet/ chain/commands/util/ chain/contexts/ config/ config/impl/ mock/ upload/ util/ validator/ v...

Modified: struts/action/trunk/src/java/org/apache/struts/util/RequestUtils.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/RequestUtils.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/RequestUtils.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/RequestUtils.java Thu Feb  9 06:11:07 2006
@@ -35,8 +35,10 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
+
 import java.net.MalformedURLException;
 import java.net.URL;
+
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -72,7 +74,7 @@
      * @throws MalformedURLException if we cannot create an absolute URL
      */
     public static URL absoluteURL(HttpServletRequest request, String path)
-            throws MalformedURLException {
+        throws MalformedURLException {
         return (new URL(serverURL(request), request.getContextPath() + path));
     }
 
@@ -85,7 +87,7 @@
      * @throws ClassNotFoundException if the class cannot be found
      */
     public static Class applicationClass(String className)
-            throws ClassNotFoundException {
+        throws ClassNotFoundException {
         return applicationClass(className, null);
     }
 
@@ -99,8 +101,8 @@
      * @throws ClassNotFoundException if the class cannot be found
      */
     public static Class applicationClass(String className,
-                                         ClassLoader classLoader)
-            throws ClassNotFoundException {
+        ClassLoader classLoader)
+        throws ClassNotFoundException {
         if (classLoader == null) {
             // Look up the class loader to be used
             classLoader = Thread.currentThread().getContextClassLoader();
@@ -132,7 +134,7 @@
      *                                constructor
      */
     public static Object applicationInstance(String className)
-            throws ClassNotFoundException, IllegalAccessException,
+        throws ClassNotFoundException, IllegalAccessException, 
             InstantiationException {
         return applicationInstance(className, null);
     }
@@ -156,8 +158,8 @@
      *                                constructor
      */
     public static Object applicationInstance(String className,
-                                             ClassLoader classLoader)
-            throws ClassNotFoundException, IllegalAccessException,
+        ClassLoader classLoader)
+        throws ClassNotFoundException, IllegalAccessException, 
             InstantiationException {
         return (applicationClass(className, classLoader).newInstance());
     }
@@ -174,9 +176,7 @@
      * @return ActionForm instance associated with this request
      */
     public static ActionForm createActionForm(HttpServletRequest request,
-                                              ActionMapping mapping,
-                                              ModuleConfig moduleConfig,
-                                              ActionServlet servlet) {
+        ActionMapping mapping, ModuleConfig moduleConfig, ActionServlet servlet) {
         // Is there a form bean associated with this mapping?
         String attribute = mapping.getAttribute();
 
@@ -194,8 +194,8 @@
             return (null);
         }
 
-        ActionForm instance = lookupActionForm(request, attribute,
-                mapping.getScope());
+        ActionForm instance =
+            lookupActionForm(request, attribute, mapping.getScope());
 
         // Can we recycle the existing form bean instance (if there is one)?
         if ((instance != null) && config.canReuse(instance)) {
@@ -206,12 +206,11 @@
     }
 
     private static ActionForm lookupActionForm(HttpServletRequest request,
-                                               String attribute,
-                                               String scope) {
+        String attribute, String scope) {
         // Look up any existing form bean instance
         if (log.isDebugEnabled()) {
             log.debug(" Looking for ActionForm bean instance in scope '"
-                    + scope + "' under attribute key '" + attribute + "'");
+                + scope + "' under attribute key '" + attribute + "'");
         }
 
         ActionForm instance = null;
@@ -240,7 +239,7 @@
      * @return ActionForm instance associated with this request
      */
     public static ActionForm createActionForm(FormBeanConfig config,
-                                              ActionServlet servlet) {
+        ActionServlet servlet) {
         if (config == null) {
             return (null);
         }
@@ -253,13 +252,11 @@
 
             if (log.isDebugEnabled()) {
                 log.debug(" Creating new "
-                        + (config.getDynamic() ? "DynaActionForm" :
-                        "ActionForm")
-                        + " instance of type '" + config.getType() + "'");
+                    + (config.getDynamic() ? "DynaActionForm" : "ActionForm")
+                    + " instance of type '" + config.getType() + "'");
                 log.trace(" --> " + instance);
             }
-        }
-        catch (Throwable t) {
+        } catch (Throwable t) {
             log.error(servlet.getInternal().getMessage("formBean",
                     config.getType()), t);
         }
@@ -278,8 +275,7 @@
      * @return current user locale
      * @since Struts 1.2
      */
-    public static Locale getUserLocale(HttpServletRequest request,
-                                       String locale) {
+    public static Locale getUserLocale(HttpServletRequest request, String locale) {
         Locale userLocale = null;
         HttpSession session = request.getSession(false);
 
@@ -314,7 +310,7 @@
      *                          property values
      */
     public static void populate(Object bean, HttpServletRequest request)
-            throws ServletException {
+        throws ServletException {
         populate(bean, null, null, request);
     }
 
@@ -344,8 +340,8 @@
      *                          property values
      */
     public static void populate(Object bean, String prefix, String suffix,
-                                HttpServletRequest request)
-            throws ServletException {
+        HttpServletRequest request)
+        throws ServletException {
         // Build a list of relevant request parameters from this request
         HashMap properties = new HashMap();
 
@@ -360,8 +356,8 @@
         boolean isMultipart = false;
 
         if ((contentType != null)
-                && (contentType.startsWith("multipart/form-data"))
-                && (method.equalsIgnoreCase("POST"))) {
+            && (contentType.startsWith("multipart/form-data"))
+            && (method.equalsIgnoreCase("POST"))) {
             // Get the ActionServletWrapper from the form bean
             ActionServletWrapper servlet;
 
@@ -369,14 +365,14 @@
                 servlet = ((ActionForm) bean).getServletWrapper();
             } else {
                 throw new ServletException("bean that's supposed to be "
-                        + "populated from a multipart request is not of type "
-                        + "\"org.apache.struts.action.ActionForm\", but type "
-                        + "\"" + bean.getClass().getName() + "\"");
+                    + "populated from a multipart request is not of type "
+                    + "\"org.apache.struts.action.ActionForm\", but type "
+                    + "\"" + bean.getClass().getName() + "\"");
             }
 
             // Obtain a MultipartRequestHandler
             MultipartRequestHandler multipartHandler =
-                    getMultipartHandler(request);
+                getMultipartHandler(request);
 
             // Set the multipart request handler for our ActionForm.
             // If the bean isn't an ActionForm, an exception would have been
@@ -390,24 +386,24 @@
                 // Set servlet and mapping info
                 servlet.setServletFor(multipartHandler);
                 multipartHandler.setMapping((ActionMapping) request
-                        .getAttribute(Globals.MAPPING_KEY));
+                    .getAttribute(Globals.MAPPING_KEY));
 
                 // Initialize multipart request class handler
                 multipartHandler.handleRequest(request);
 
                 //stop here if the maximum length has been exceeded
-                Boolean maxLengthExceeded = (Boolean) request
-                        .getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
+                Boolean maxLengthExceeded =
+                    (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
 
                 if ((maxLengthExceeded != null)
-                        && (maxLengthExceeded.booleanValue())) {
+                    && (maxLengthExceeded.booleanValue())) {
                     return;
                 }
 
                 //retrieve form values and put into properties
                 multipartParameters =
-                        getAllParametersForMultipartRequest(request,
-                                multipartHandler);
+                    getAllParametersForMultipartRequest(request,
+                        multipartHandler);
                 names = Collections.enumeration(multipartParameters.keySet());
             }
         }
@@ -433,8 +429,8 @@
                     continue;
                 }
 
-                stripped = stripped.substring(0,
-                        stripped.length() - suffix.length());
+                stripped =
+                    stripped.substring(0, stripped.length() - suffix.length());
             }
 
             Object parameterValue = null;
@@ -455,8 +451,7 @@
         // Set the corresponding properties of our bean
         try {
             BeanUtils.populate(bean, properties);
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             throw new ServletException("BeanUtils.populate", e);
         }
     }
@@ -474,11 +469,11 @@
      *                          locate the multipart handler.
      */
     private static MultipartRequestHandler getMultipartHandler(
-            HttpServletRequest request)
-            throws ServletException {
+        HttpServletRequest request)
+        throws ServletException {
         MultipartRequestHandler multipartHandler = null;
         String multipartClass =
-                (String) request.getAttribute(Globals.MULTIPART_KEY);
+            (String) request.getAttribute(Globals.MULTIPART_KEY);
 
         request.removeAttribute(Globals.MULTIPART_KEY);
 
@@ -486,27 +481,21 @@
         if (multipartClass != null) {
             try {
                 multipartHandler =
-                        (MultipartRequestHandler) applicationInstance(
-                                multipartClass);
-            }
-            catch (ClassNotFoundException cnfe) {
+                    (MultipartRequestHandler) applicationInstance(multipartClass);
+            } catch (ClassNotFoundException cnfe) {
                 log.error("MultipartRequestHandler class \"" + multipartClass
-                        + "\" in mapping class not found, "
-                        + "defaulting to global multipart class");
-            }
-            catch (InstantiationException ie) {
+                    + "\" in mapping class not found, "
+                    + "defaulting to global multipart class");
+            } catch (InstantiationException ie) {
                 log.error("InstantiationException when instantiating "
-                        + "MultipartRequestHandler \"" + multipartClass
-                        + "\", "
-                        + "defaulting to global multipart class, exception: "
-                        + ie.getMessage());
-            }
-            catch (IllegalAccessException iae) {
+                    + "MultipartRequestHandler \"" + multipartClass + "\", "
+                    + "defaulting to global multipart class, exception: "
+                    + ie.getMessage());
+            } catch (IllegalAccessException iae) {
                 log.error("IllegalAccessException when instantiating "
-                        + "MultipartRequestHandler \"" + multipartClass
-                        + "\", "
-                        + "defaulting to global multipart class, exception: "
-                        + iae.getMessage());
+                    + "MultipartRequestHandler \"" + multipartClass + "\", "
+                    + "defaulting to global multipart class, exception: "
+                    + iae.getMessage());
             }
 
             if (multipartHandler != null) {
@@ -515,36 +504,29 @@
         }
 
         ModuleConfig moduleConfig =
-                ModuleUtils.getInstance().getModuleConfig(request);
+            ModuleUtils.getInstance().getModuleConfig(request);
 
-        multipartClass =
-                moduleConfig.getControllerConfig().getMultipartClass();
+        multipartClass = moduleConfig.getControllerConfig().getMultipartClass();
 
         // Try to initialize the global request handler
         if (multipartClass != null) {
             try {
                 multipartHandler =
-                        (MultipartRequestHandler) applicationInstance(
-                                multipartClass);
-            }
-            catch (ClassNotFoundException cnfe) {
+                    (MultipartRequestHandler) applicationInstance(multipartClass);
+            } catch (ClassNotFoundException cnfe) {
                 throw new ServletException("Cannot find multipart class \""
-                        + multipartClass + "\"" + ", exception: "
-                        + cnfe.getMessage());
-            }
-            catch (InstantiationException ie) {
+                    + multipartClass + "\"" + ", exception: "
+                    + cnfe.getMessage());
+            } catch (InstantiationException ie) {
                 throw new ServletException(
-                        "InstantiationException when instantiating "
-                                + "multipart class \"" + multipartClass
-                                + "\", exception: "
-                                + ie.getMessage());
-            }
-            catch (IllegalAccessException iae) {
+                    "InstantiationException when instantiating "
+                    + "multipart class \"" + multipartClass + "\", exception: "
+                    + ie.getMessage());
+            } catch (IllegalAccessException iae) {
                 throw new ServletException(
-                        "IllegalAccessException when instantiating "
-                                + "multipart class \"" + multipartClass
-                                + "\", exception: "
-                                + iae.getMessage());
+                    "IllegalAccessException when instantiating "
+                    + "multipart class \"" + multipartClass + "\", exception: "
+                    + iae.getMessage());
             }
 
             if (multipartHandler != null) {
@@ -568,8 +550,7 @@
      * @return the map containing all parameters for this multipart request.
      */
     private static Map getAllParametersForMultipartRequest(
-            HttpServletRequest request,
-            MultipartRequestHandler multipartHandler) {
+        HttpServletRequest request, MultipartRequestHandler multipartHandler) {
         Map parameters = new HashMap();
         Hashtable elements = multipartHandler.getAllElements();
         Enumeration e = elements.keys();
@@ -581,8 +562,9 @@
         }
 
         if (request instanceof MultipartRequestWrapper) {
-            request = (HttpServletRequest) ((MultipartRequestWrapper) request)
-                    .getRequest();
+            request =
+                (HttpServletRequest) ((MultipartRequestWrapper) request)
+                .getRequest();
             e = request.getParameterNames();
 
             while (e.hasMoreElements()) {
@@ -638,7 +620,7 @@
      * @since Struts 1.1
      */
     public static String actionURL(HttpServletRequest request,
-                                   ActionConfig action, String pattern) {
+        ActionConfig action, String pattern) {
         StringBuffer sb = new StringBuffer();
 
         if (pattern.endsWith("/*")) {
@@ -646,7 +628,7 @@
             sb.append(action.getPath());
         } else if (pattern.startsWith("*.")) {
             ModuleConfig appConfig =
-                    ModuleUtils.getInstance().getModuleConfig(request);
+                ModuleUtils.getInstance().getModuleConfig(request);
 
             sb.append(appConfig.getPrefix());
             sb.append(action.getPath());
@@ -661,27 +643,52 @@
     /**
      * <p>Return the context-relative URL that corresponds to the specified
      * <code>ForwardConfig</code>. The URL is calculated based on the
-     * properties of the {@link ForwardConfig} instance as follows:</p> <ul>
+     * properties of the {@link ForwardConfig} instance as follows:</p>
+     *
+     * <ul>
+     *
+     *
      * <li>If the <code>contextRelative</code> property is set, it is assumed
      * that the <code>path</code> property contains a path that is already
-     * context-relative: <ul> <li>If the <code>path</code> property value
-     * starts with a slash, it is returned unmodified.</li> <li>If the
-     * <code>path</code> property value does not start with a slash, a slash
-     * is prepended.</li> </ul></li> <li>Acquire the <code>forwardPattern</code>
-     * property from the <code>ControllerConfig</code> for the application
-     * module used to process this request. If no pattern was configured,
-     * default to a pattern of <code>$M$P</code>, which is compatible with the
-     * hard-coded mapping behavior in Struts 1.0.</li> <li>Process the
-     * acquired <code>forwardPattern</code>, performing the following
-     * substitutions: <ul> <li><strong>$M</strong> - Replaced by the module
-     * prefix for the application module processing this request.</li>
+     * context-relative:
+     *
+     * <ul>
+     *
+     * <li>If the <code>path</code> property value starts with a slash, it is
+     * returned unmodified.</li> <li>If the <code>path</code> property value
+     * does not start with a slash, a slash is prepended.</li>
+     *
+     * </ul></li>
+     *
+     * <li>Acquire the <code>forwardPattern</code> property from the
+     * <code>ControllerConfig</code> for the application module used to
+     * process this request. If no pattern was configured, default to a
+     * pattern of <code>$M$P</code>, which is compatible with the hard-coded
+     * mapping behavior in Struts 1.0.</li>
+     *
+     * <li>Process the acquired <code>forwardPattern</code>, performing the
+     * following substitutions:
+     *
+     * <ul>
+     *
+     * <li><strong>$M</strong> - Replaced by the
+     * module prefix for the application module processing this request.</li>
+     *
      * <li><strong>$P</strong> - Replaced by the <code>path</code> property of
      * the specified {@link ForwardConfig}, prepended with a slash if it does
-     * not start with one.</li> <li><strong>$$</strong> - Replaced by a single
-     * dollar sign character.</li> <li><strong>$x</strong> (where "x" is any
-     * charater not listed above) - Silently omit these two characters from
-     * the result value.  (This has the side effect of causing all other
-     * $+letter combinations to be reserved.)</li> </ul></li> </ul>
+     * not start with one.</li>
+     *
+     * <li><strong>$$</strong> - Replaced by a single dollar sign
+     * character.</li>
+     *
+     * <li><strong>$x</strong> (where "x" is any charater not listed above) -
+     * Silently omit these two characters from the result value.  (This has
+     * the side effect of causing all other $+letter combinations to be
+     * reserved.)</li>
+     *
+     * </ul></li>
+     *
+     * </ul>
      *
      * @param request The servlet request we are processing
      * @param forward ForwardConfig to be evaluated
@@ -689,34 +696,52 @@
      * @since Struts 1.1
      */
     public static String forwardURL(HttpServletRequest request,
-                                    ForwardConfig forward) {
+        ForwardConfig forward) {
         return forwardURL(request, forward, null);
     }
 
     /**
      * <p>Return the context-relative URL that corresponds to the specified
      * <code>ForwardConfig</code>. The URL is calculated based on the
-     * properties of the {@link ForwardConfig} instance as follows:</p> <ul>
+     * properties of the {@link ForwardConfig} instance as follows:</p>
+     *
+     * <ul>
+     *
      * <li>If the <code>contextRelative</code> property is set, it is assumed
      * that the <code>path</code> property contains a path that is already
-     * context-relative: <ul> <li>If the <code>path</code> property value
+     * context-relative: <ul>
+
+     * <li>If the <code>path</code> property value
      * starts with a slash, it is returned unmodified.</li> <li>If the
      * <code>path</code> property value does not start with a slash, a slash
-     * is prepended.</li> </ul></li> <li>Acquire the <code>forwardPattern</code>
+     * is prepended.</li>
+     *
+     * </ul></li>
+     *
+     * <li>Acquire the <code>forwardPattern</code>
      * property from the <code>ControllerConfig</code> for the application
      * module used to process this request. If no pattern was configured,
      * default to a pattern of <code>$M$P</code>, which is compatible with the
-     * hard-coded mapping behavior in Struts 1.0.</li> <li>Process the
+     * hard-coded mapping behavior in Struts 1.0.</li>
+     *
+     * <li>Process the
      * acquired <code>forwardPattern</code>, performing the following
      * substitutions: <ul> <li><strong>$M</strong> - Replaced by the module
      * prefix for the application module processing this request.</li>
+     *
      * <li><strong>$P</strong> - Replaced by the <code>path</code> property of
      * the specified {@link ForwardConfig}, prepended with a slash if it does
-     * not start with one.</li> <li><strong>$$</strong> - Replaced by a single
-     * dollar sign character.</li> <li><strong>$x</strong> (where "x" is any
+     * not start with one.</li>
+     *
+     * <li><strong>$$</strong> - Replaced by a single
+     * dollar sign character.</li>
+     *
+     * <li><strong>$x</strong> (where "x" is any
      * charater not listed above) - Silently omit these two characters from
      * the result value.  (This has the side effect of causing all other
-     * $+letter combinations to be reserved.)</li> </ul></li> </ul>
+     * $+letter combinations to be reserved.)</li>
+     *
+     * </ul></li></ul>
      *
      * @param request      The servlet request we are processing
      * @param forward      ForwardConfig to be evaluated
@@ -725,8 +750,7 @@
      * @since Struts 1.2
      */
     public static String forwardURL(HttpServletRequest request,
-                                    ForwardConfig forward,
-                                    ModuleConfig moduleConfig) {
+        ForwardConfig forward, ModuleConfig moduleConfig) {
         //load the current moduleConfig, if null
         if (moduleConfig == null) {
             moduleConfig = ModuleUtils.getInstance().getModuleConfig(request);
@@ -749,8 +773,8 @@
         StringBuffer sb = new StringBuffer();
 
         // Calculate a context relative path for this ForwardConfig
-        String forwardPattern = moduleConfig.getControllerConfig()
-                .getForwardPattern();
+        String forwardPattern =
+            moduleConfig.getControllerConfig().getForwardPattern();
 
         if (forwardPattern == null) {
             // Performance optimization for previous default behavior
@@ -770,29 +794,29 @@
 
                 if (dollar) {
                     switch (ch) {
-                        case 'M':
-                            sb.append(prefix);
+                    case 'M':
+                        sb.append(prefix);
 
-                            break;
+                        break;
 
-                        case 'P':
+                    case 'P':
 
-                            // add '/' if needed
-                            if (!path.startsWith("/")) {
-                                sb.append("/");
-                            }
+                        // add '/' if needed
+                        if (!path.startsWith("/")) {
+                            sb.append("/");
+                        }
 
-                            sb.append(path);
+                        sb.append(path);
 
-                            break;
+                        break;
 
-                        case '$':
-                            sb.append('$');
+                    case '$':
+                        sb.append('$');
 
-                            break;
+                        break;
 
-                        default:
-                            ; // Silently swallow
+                    default:
+                        ; // Silently swallow
                     }
 
                     dollar = false;
@@ -818,7 +842,7 @@
      * @throws MalformedURLException if a URL cannot be created
      */
     public static URL requestURL(HttpServletRequest request)
-            throws MalformedURLException {
+        throws MalformedURLException {
         StringBuffer url = requestToServerUriStringBuffer(request);
 
         return (new URL(url.toString()));
@@ -835,7 +859,7 @@
      * @throws MalformedURLException if a URL cannot be created
      */
     public static URL serverURL(HttpServletRequest request)
-            throws MalformedURLException {
+        throws MalformedURLException {
         StringBuffer url = requestToServerStringBuffer(request);
 
         return (new URL(url.toString()));
@@ -852,11 +876,11 @@
      * @since Struts 1.2.0
      */
     public static StringBuffer requestToServerUriStringBuffer(
-            HttpServletRequest request) {
+        HttpServletRequest request) {
         StringBuffer serverUri =
-                createServerUriStringBuffer(request.getScheme(),
-                        request.getServerName(), request.getServerPort(),
-                        request.getRequestURI());
+            createServerUriStringBuffer(request.getScheme(),
+                request.getServerName(), request.getServerPort(),
+                request.getRequestURI());
 
         return serverUri;
     }
@@ -873,9 +897,9 @@
      * @since Struts 1.2.0
      */
     public static StringBuffer requestToServerStringBuffer(
-            HttpServletRequest request) {
+        HttpServletRequest request) {
         return createServerStringBuffer(request.getScheme(),
-                request.getServerName(), request.getServerPort());
+            request.getServerName(), request.getServerPort());
     }
 
     /**
@@ -889,8 +913,7 @@
      * @since Struts 1.2.0
      */
     public static StringBuffer createServerStringBuffer(String scheme,
-                                                        String server,
-                                                        int port) {
+        String server, int port) {
         StringBuffer url = new StringBuffer();
 
         if (port < 0) {
@@ -902,7 +925,7 @@
         url.append(server);
 
         if ((scheme.equals("http") && (port != 80))
-                || (scheme.equals("https") && (port != 443))) {
+            || (scheme.equals("https") && (port != 443))) {
             url.append(':');
             url.append(port);
         }
@@ -922,11 +945,8 @@
      * @since Struts 1.2.0
      */
     public static StringBuffer createServerUriStringBuffer(String scheme,
-                                                           String server,
-                                                           int port,
-                                                           String uri) {
-        StringBuffer serverUri =
-                createServerStringBuffer(scheme, server, port);
+        String server, int port, String uri) {
+        StringBuffer serverUri = createServerStringBuffer(scheme, server, port);
 
         serverUri.append(uri);
 

Modified: struts/action/trunk/src/java/org/apache/struts/util/ResponseUtils.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/ResponseUtils.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/ResponseUtils.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/ResponseUtils.java Thu Feb  9 06:11:07 2006
@@ -22,6 +22,7 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+
 import java.net.URLEncoder;
 
 /**
@@ -37,8 +38,9 @@
     /**
      * The message resources for this package.
      */
-    protected static MessageResources messages = MessageResources
-            .getMessageResources("org.apache.struts.util.LocalStrings");
+    protected static MessageResources messages =
+        MessageResources.getMessageResources(
+            "org.apache.struts.util.LocalStrings");
 
     /**
      * Java 1.4 encode method to use instead of deprecated 1.3 version.
@@ -57,14 +59,12 @@
     static {
         try {
             // get version of encode method with two String args
-            Class[] args = new Class[]{String.class, String.class};
+            Class[] args = new Class[] { String.class, String.class };
 
             encode = URLEncoder.class.getMethod("encode", args);
-        }
-        catch (NoSuchMethodException e) {
-            log.debug(
-                    "Could not find Java 1.4 encode method.  Using deprecated version.",
-                    e);
+        } catch (NoSuchMethodException e) {
+            log.debug("Could not find Java 1.4 encode method.  Using deprecated version.",
+                e);
         }
     }
 
@@ -89,30 +89,30 @@
             filtered = null;
 
             switch (value.charAt(i)) {
-                case '<':
-                    filtered = "&lt;";
+            case '<':
+                filtered = "&lt;";
 
-                    break;
+                break;
 
-                case '>':
-                    filtered = "&gt;";
+            case '>':
+                filtered = "&gt;";
 
-                    break;
+                break;
 
-                case '&':
-                    filtered = "&amp;";
+            case '&':
+                filtered = "&amp;";
 
-                    break;
+                break;
 
-                case '"':
-                    filtered = "&quot;";
+            case '"':
+                filtered = "&quot;";
 
-                    break;
+                break;
 
-                case '\'':
-                    filtered = "&#39;";
+            case '\'':
+                filtered = "&#39;";
 
-                    break;
+                break;
             }
 
             if (result == null) {
@@ -165,18 +165,14 @@
 
             // encode url with new 1.4 method and UTF-8 encoding
             if (encode != null) {
-                return (String) encode.invoke(null, new Object[]{url, enc});
+                return (String) encode.invoke(null, new Object[] { url, enc });
             }
-        }
-        catch (IllegalAccessException e) {
-            log.debug(
-                    "Could not find Java 1.4 encode method.  Using deprecated version.",
-                    e);
-        }
-        catch (InvocationTargetException e) {
-            log.debug(
-                    "Could not find Java 1.4 encode method. Using deprecated version.",
-                    e);
+        } catch (IllegalAccessException e) {
+            log.debug("Could not find Java 1.4 encode method.  Using deprecated version.",
+                e);
+        } catch (InvocationTargetException e) {
+            log.debug("Could not find Java 1.4 encode method. Using deprecated version.",
+                e);
         }
 
         return URLEncoder.encode(url);

Modified: struts/action/trunk/src/java/org/apache/struts/util/ServletContextWriter.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/ServletContextWriter.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/ServletContextWriter.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/ServletContextWriter.java Thu Feb  9 06:11:07 2006
@@ -18,6 +18,7 @@
 package org.apache.struts.util;
 
 import javax.servlet.ServletContext;
+
 import java.io.PrintWriter;
 import java.io.StringWriter;
 

Modified: struts/action/trunk/src/java/org/apache/struts/util/TokenProcessor.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/TokenProcessor.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/TokenProcessor.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/TokenProcessor.java Thu Feb  9 06:11:07 2006
@@ -21,6 +21,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
+
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
@@ -60,14 +61,23 @@
     }
 
     /**
-     * Return <code>true</code> if there is a transaction token stored in the
+     * <p>Return <code>true</code> if there is a transaction token stored in the
      * user's current session, and the value submitted as a request parameter
      * with this action matches it.  Returns <code>false</code> under any of
-     * the following circumstances: <ul> <li>No session associated with this
-     * request</li> <li>No transaction token saved in the session</li> <li>No
-     * transaction token included as a request parameter</li> <li>The included
-     * transaction token value does not match the transaction token in the
-     * user's session</li> </ul>
+     * the following circumstances:</p>
+     *
+     * <ul>
+     *
+     * <li>No session associated with this request</li>
+     *
+     * <li>No transaction token saved in the session</li>
+     *
+     * <li>No transaction token included as a request parameter</li>
+     *
+     * <li>The included transaction token value does not match the transaction
+     * token in the user's session</li>
+     *
+     * </ul>
      *
      * @param request The servlet request we are processing
      */
@@ -78,17 +88,25 @@
     /**
      * Return <code>true</code> if there is a transaction token stored in the
      * user's current session, and the value submitted as a request parameter
-     * with this action matches it.  Returns <code>false</code> <ul> <li>No
-     * session associated with this request</li> <li>No transaction token
-     * saved in the session</li> <li>No transaction token included as a
-     * request parameter</li> <li>The included transaction token value does
-     * not match the transaction token in the user's session</li> </ul>
+     * with this action matches it.  Returns <code>false</code>
+     *
+     * <ul>
+     *
+     * <li>No session associated with this request</li> <li>No transaction
+     * token saved in the session</li>
+     *
+     * <li>No transaction token included as a request parameter</li>
+     *
+     * <li>The included transaction token value does not match the transaction
+     * token in the user's session</li>
+     *
+     * </ul>
      *
      * @param request The servlet request we are processing
      * @param reset   Should we reset the token after checking it?
      */
     public synchronized boolean isTokenValid(HttpServletRequest request,
-                                             boolean reset) {
+        boolean reset) {
         // Retrieve the current session for this request
         HttpSession session = request.getSession(false);
 
@@ -99,7 +117,7 @@
         // Retrieve the transaction token from this session, and
         // reset it if requested
         String saved =
-                (String) session.getAttribute(Globals.TRANSACTION_TOKEN_KEY);
+            (String) session.getAttribute(Globals.TRANSACTION_TOKEN_KEY);
 
         if (saved == null) {
             return false;
@@ -187,8 +205,7 @@
             md.update(now);
 
             return toHex(md.digest());
-        }
-        catch (NoSuchAlgorithmException e) {
+        } catch (NoSuchAlgorithmException e) {
             return null;
         }
     }

Modified: struts/action/trunk/src/java/org/apache/struts/util/WildcardHelper.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/WildcardHelper.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/WildcardHelper.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/WildcardHelper.java Thu Feb  9 06:11:07 2006
@@ -54,22 +54,33 @@
     protected static final int MATCH_END = -3;
 
     /**
-     * Translate the given <code>String</code> into a <code>int []</code>
+     * <p> Translate the given <code>String</code> into a <code>int []</code>
      * representing the pattern matchable by this class. <br> This function
      * translates a <code>String</code> into an int array converting the
      * special '*' and '\' characters. <br> Here is how the conversion
-     * algorithm works: <ul> <li>The '*' character is converted to MATCH_FILE,
-     * meaning that zero or more characters (excluding the path separator '/')
-     * are to be matched.</li> <li>The '**' sequence is converted to
-     * MATCH_PATH, meaning that zero or more characters (including the path
-     * separator '/') are to be matched.</li> <li>The '\' character is used as
-     * an escape sequence ('\*' is translated in '*', not in MATCH_FILE). If
-     * an exact '\' character is to be matched the source string must contain
-     * a '\\'. sequence.</li> </ul> When more than two '*' characters, not
-     * separated by another character, are found their value is considered as
-     * '**' (MATCH_PATH). <br> The array is always terminated by a special
-     * value (MATCH_END). <br> All MATCH* values are less than zero, while
-     * normal characters are equal or greater.
+     * algorithm works:</p>
+     *
+     * <ul>
+     *
+     * <li>The '*' character is converted to MATCH_FILE, meaning that zero or
+     * more characters (excluding the path separator '/') are to be
+     * matched.</li>
+     *
+     * <li>The '**' sequence is converted to MATCH_PATH, meaning that zero or
+     * more characters (including the path separator '/') are to be
+     * matched.</li>
+     *
+     * <li>The '\' character is used as an escape sequence ('\*' is translated
+     * in '*', not in MATCH_FILE). If an exact '\' character is to be matched
+     * the source string must contain a '\\'. sequence.</li>
+     *
+     * </ul>
+     *
+     * <p>When more than two '*' characters, not separated by another
+     * character, are found their value is considered as '**' (MATCH_PATH).
+     * <br> The array is always terminated by a special value (MATCH_END).
+     * <br> All MATCH* values are less than zero, while normal characters are
+     * equal or greater.</p>
      *
      * @param data The string to translate.
      * @return The encoded string as an int array, terminated by the MATCH_END
@@ -226,7 +237,7 @@
             if (exprchr == MATCH_END) {
                 if (rsltpos > 0) {
                     map.put(Integer.toString(++mcount),
-                            new String(rslt, 0, rsltpos));
+                        new String(rslt, 0, rsltpos));
                 }
 
                 // Don't care about rest of input buffer
@@ -234,7 +245,7 @@
             } else if (exprchr == MATCH_THEEND) {
                 if (rsltpos > 0) {
                     map.put(Integer.toString(++mcount),
-                            new String(rslt, 0, rsltpos));
+                        new String(rslt, 0, rsltpos));
                 }
 
                 // Check that we reach buffer's end
@@ -253,9 +264,10 @@
             exprchr = expr[charpos];
 
             // We have here prevchr == * or **.
-            offset = (prevchr == MATCH_FILE)
-                    ? indexOfArray(expr, exprpos, charpos, buff, buffpos)
-                    : lastIndexOfArray(expr, exprpos, charpos, buff, buffpos);
+            offset =
+                (prevchr == MATCH_FILE)
+                ? indexOfArray(expr, exprpos, charpos, buff, buffpos)
+                : lastIndexOfArray(expr, exprpos, charpos, buff, buffpos);
 
             if (offset < 0) {
                 return (false);
@@ -298,8 +310,7 @@
      * @return The offset in d of the part of r matched in d or -1 if that was
      *         not found.
      */
-    protected int indexOfArray(int[] r, int rpos, int rend, char[] d,
-                               int dpos) {
+    protected int indexOfArray(int[] r, int rpos, int rend, char[] d, int dpos) {
         // Check if pos and len are legal
         if (rend < rpos) {
             throw new IllegalArgumentException("rend < rpos");
@@ -363,7 +374,7 @@
      *         that was not found.
      */
     protected int lastIndexOfArray(int[] r, int rpos, int rend, char[] d,
-                                   int dpos) {
+        int dpos) {
         // Check if pos and len are legal
         if (rend < rpos) {
             throw new IllegalArgumentException("rend < rpos");
@@ -427,8 +438,7 @@
      * @param dpos The starting offset in d for the matching.
      * @return true if array d starts from portion of array r.
      */
-    protected boolean matchArray(int[] r, int rpos, int rend, char[] d,
-                                 int dpos) {
+    protected boolean matchArray(int[] r, int rpos, int rend, char[] d, int dpos) {
         if ((d.length - dpos) < (rend - rpos)) {
             return (false);
         }

Modified: struts/action/trunk/src/java/org/apache/struts/validator/BeanValidatorForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/BeanValidatorForm.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/BeanValidatorForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/BeanValidatorForm.java Thu Feb  9 06:11:07 2006
@@ -24,8 +24,11 @@
 import org.apache.struts.action.ActionMapping;
 
 import javax.servlet.http.HttpServletRequest;
+
 import java.io.Serializable;
+
 import java.lang.reflect.Array;
+
 import java.util.List;
 import java.util.Map;
 
@@ -50,7 +53,7 @@
  * session scope.</p>
  */
 public class BeanValidatorForm extends ValidatorForm implements DynaBean,
-        Serializable {
+    Serializable {
     /**
      * Commons Logging
      */
@@ -161,7 +164,7 @@
      * @return validation key to use
      */
     public String getValidationKey(ActionMapping mapping,
-                                   HttpServletRequest request) {
+        HttpServletRequest request) {
         String validationKey = null;
 
         if (isPathValidation()) {
@@ -183,8 +186,8 @@
 
         if (logger.isDebugEnabled()) {
             logger.debug("Validating ActionForm '" + mapping.getName()
-                    + "' using key '" + validationKey + "' for mapping '"
-                    + mapping.getPath() + "'");
+                + "' using key '" + validationKey + "' for mapping '"
+                + mapping.getPath() + "'");
         }
 
         return validationKey;
@@ -245,10 +248,10 @@
                 page = ((Integer) value).intValue();
             } else {
                 try {
-                    page = ((Integer) ConvertUtils.convert(value.toString(),
+                    page =
+                        ((Integer) ConvertUtils.convert(value.toString(),
                             Integer.class)).intValue();
-                }
-                catch (Exception ignore) {
+                } catch (Exception ignore) {
                     page = 0;
                 }
             }

Modified: struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorActionForm.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorActionForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorActionForm.java Thu Feb  9 06:11:07 2006
@@ -21,6 +21,7 @@
 import org.apache.struts.action.ActionMapping;
 
 import javax.servlet.http.HttpServletRequest;
+
 import java.io.Serializable;
 
 /**
@@ -29,15 +30,19 @@
  * is the action element's 'path' attribute from the struts-config.xml which
  * should match the form element's name attribute in the validation.xml.</p>
  *
- * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
- * for validation rules.</li></ul>
+ * <ul>
+ *
+ * <li>See <code>ValidatorPlugin</code> definition in struts-config.xml for
+ * validation rules.</li>
+ *
+ * </ul>
  *
  * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
  *          $
  * @since Struts 1.1
  */
 public class DynaValidatorActionForm extends DynaValidatorForm
-        implements DynaBean, Serializable {
+    implements DynaBean, Serializable {
     /**
      * Returns the Validation key.
      *
@@ -47,7 +52,7 @@
      *         case
      */
     public String getValidationKey(ActionMapping mapping,
-                                   HttpServletRequest request) {
+        HttpServletRequest request) {
         return mapping.getPath();
     }
 }

Modified: struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorForm.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorForm.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/DynaValidatorForm.java Thu Feb  9 06:11:07 2006
@@ -29,7 +29,9 @@
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
+
 import java.io.Serializable;
+
 import java.util.Map;
 
 /**
@@ -38,8 +40,12 @@
  * is the action element's 'name' attribute from the struts-config.xml which
  * should match the form element's name attribute in the validation.xml.</p>
  *
- * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
- * for validation rules.</li></ul>
+ * <ul>
+ *
+ * <li>See <code>ValidatorPlugin</code> definition in struts-config.xml for
+ * validation rules.</li>
+ *
+ * </ul>
  *
  * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
  *          $
@@ -47,7 +53,7 @@
  * @since Struts 1.1
  */
 public class DynaValidatorForm extends DynaActionForm implements DynaBean,
-        Serializable {
+    Serializable {
     /**
      * Commons Logging instance.
      */
@@ -95,7 +101,7 @@
      *         validation errors.
      */
     public ActionErrors validate(ActionMapping mapping,
-                                 HttpServletRequest request) {
+        HttpServletRequest request) {
         this.setPageFromDynaProperty();
 
         ServletContext application = getServlet().getServletContext();
@@ -103,13 +109,13 @@
 
         String validationKey = getValidationKey(mapping, request);
 
-        Validator validator = Resources.initValidator(validationKey, this,
-                application, request, errors, page);
+        Validator validator =
+            Resources.initValidator(validationKey, this, application, request,
+                errors, page);
 
         try {
             validatorResults = validator.validate();
-        }
-        catch (ValidatorException e) {
+        } catch (ValidatorException e) {
             log.error(e.getMessage(), e);
         }
 
@@ -124,7 +130,7 @@
      * @return validation key - the form element's name in this case
      */
     public String getValidationKey(ActionMapping mapping,
-                                   HttpServletRequest request) {
+        HttpServletRequest request) {
         return mapping.getAttribute();
     }
 
@@ -143,18 +149,16 @@
 
             try {
                 p = (Integer) props.get("page");
-            }
-            catch (ClassCastException e) {
-                log.error(
-                        "Dyna 'page' property must be of type java.lang.Integer.",
-                        e);
+            } catch (ClassCastException e) {
+                log.error("Dyna 'page' property must be of type java.lang.Integer.",
+                    e);
                 throw e;
             }
 
             if (p == null) {
                 throw new NullPointerException(
-                        "Dyna 'page' property must not be null. "
-                                + " Either provide an initial value or set 'convertNull' to false. ");
+                    "Dyna 'page' property must not be null. "
+                    + " Either provide an initial value or set 'convertNull' to false. ");
             }
 
             this.page = p.intValue();
@@ -201,6 +205,6 @@
      */
     public Map getResultValueMap() {
         return ((validatorResults != null)
-                ? validatorResults.getResultValueMap() : null);
+        ? validatorResults.getResultValueMap() : null);
     }
 }

Modified: struts/action/trunk/src/java/org/apache/struts/validator/FieldChecks.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/validator/FieldChecks.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/validator/FieldChecks.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/validator/FieldChecks.java Thu Feb  9 06:11:07 2006
@@ -32,7 +32,9 @@
 import org.apache.struts.util.RequestUtils;
 
 import javax.servlet.http.HttpServletRequest;
+
 import java.io.Serializable;
+
 import java.util.Locale;
 import java.util.StringTokenizer;
 
@@ -53,8 +55,9 @@
     /**
      * The message resources for this package.
      */
-    private static MessageResources sysmsgs = MessageResources
-            .getMessageResources("org.apache.struts.validator.LocalStrings");
+    private static MessageResources sysmsgs =
+        MessageResources.getMessageResources(
+            "org.apache.struts.validator.LocalStrings");
     public static final String FIELD_TEST_NULL = "NULL";
     public static final String FIELD_TEST_NOTNULL = "NOTNULL";
     public static final String FIELD_TEST_EQUAL = "EQUAL";
@@ -76,19 +79,15 @@
      * @return true if meets stated requirements, false otherwise.
      */
     public static boolean validateRequired(Object bean, ValidatorAction va,
-                                           Field field, ActionMessages errors,
-                                           Validator validator,
-                                           HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (GenericValidator.isBlankOrNull(value)) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
 
             return false;
         } else {
@@ -112,12 +111,10 @@
      * @return true if meets stated requirements, false otherwise.
      */
     public static boolean validateRequiredIf(Object bean, ValidatorAction va,
-                                             Field field,
-                                             ActionMessages errors,
-                                             Validator validator,
-                                             HttpServletRequest request) {
-        Object form = validator
-                .getParameterValue(org.apache.commons.validator.Validator.BEAN_PARAM);
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
+        Object form =
+            validator.getParameterValue(org.apache.commons.validator.Validator.BEAN_PARAM);
         String value = null;
         boolean required = false;
 
@@ -135,13 +132,11 @@
         }
 
         while (!GenericValidator.isBlankOrNull(field.getVarValue("field[" + i
-                + "]"))) {
+                    + "]"))) {
             String dependProp = field.getVarValue("field[" + i + "]");
             String dependTest = field.getVarValue("fieldTest[" + i + "]");
-            String dependTestValue =
-                    field.getVarValue("fieldValue[" + i + "]");
-            String dependIndexed =
-                    field.getVarValue("fieldIndexed[" + i + "]");
+            String dependTestValue = field.getVarValue("fieldValue[" + i + "]");
+            String dependIndexed = field.getVarValue("fieldIndexed[" + i + "]");
 
             if (dependIndexed == null) {
                 dependIndexed = "false";
@@ -194,10 +189,7 @@
         if (required) {
             if (GenericValidator.isBlankOrNull(value)) {
                 errors.add(field.getKey(),
-                        Resources.getActionMessage(validator,
-                                request,
-                                va,
-                                field));
+                    Resources.getActionMessage(validator, request, va, field));
 
                 return false;
             } else {
@@ -225,31 +217,26 @@
      * @return true if field matches mask, false otherwise.
      */
     public static boolean validateMask(Object bean, ValidatorAction va,
-                                       Field field, ActionMessages errors,
-                                       Validator validator,
-                                       HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         try {
-            String mask = Resources.getVarValue("mask", field, validator,
-                    request, true);
+            String mask =
+                Resources.getVarValue("mask", field, validator, request, true);
 
             if (!GenericValidator.isBlankOrNull(value)
-                    && !GenericValidator.matchRegexp(value, mask)) {
+                && !GenericValidator.matchRegexp(value, mask)) {
                 errors.add(field.getKey(),
-                        Resources.getActionMessage(validator,
-                                request,
-                                va,
-                                field));
+                    Resources.getActionMessage(validator, request, va, field));
 
                 return false;
             } else {
                 return true;
             }
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             processFailure(errors, field, "mask", e);
 
             return false;
@@ -272,9 +259,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateByte(Object bean, ValidatorAction va,
-                                      Field field, ActionMessages errors,
-                                      Validator validator,
-                                      HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -288,10 +274,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -313,10 +296,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateByteLocale(Object bean, ValidatorAction va,
-                                            Field field,
-                                            ActionMessages errors,
-                                            Validator validator,
-                                            HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -332,10 +313,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -352,8 +330,7 @@
         if (isString(bean)) {
             value = (String) bean;
         } else {
-            value = ValidatorUtils
-                    .getValueAsString(bean, field.getProperty());
+            value = ValidatorUtils.getValueAsString(bean, field.getProperty());
         }
 
         return value;
@@ -375,9 +352,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateShort(Object bean, ValidatorAction va,
-                                       Field field, ActionMessages errors,
-                                       Validator validator,
-                                       HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -391,10 +367,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -416,10 +389,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateShortLocale(Object bean, ValidatorAction va,
-                                             Field field,
-                                             ActionMessages errors,
-                                             Validator validator,
-                                             HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -435,10 +406,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -460,9 +428,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateInteger(Object bean, ValidatorAction va,
-                                         Field field, ActionMessages errors,
-                                         Validator validator,
-                                         HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -476,10 +443,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -500,12 +464,9 @@
      * @param request   Current request object.
      * @return true if valid, false otherwise.
      */
-    public static Object validateIntegerLocale(Object bean,
-                                               ValidatorAction va,
-                                               Field field,
-                                               ActionMessages errors,
-                                               Validator validator,
-                                               HttpServletRequest request) {
+    public static Object validateIntegerLocale(Object bean, ValidatorAction va,
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -521,10 +482,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -546,9 +504,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateLong(Object bean, ValidatorAction va,
-                                      Field field, ActionMessages errors,
-                                      Validator validator,
-                                      HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -562,10 +519,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -587,10 +541,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateLongLocale(Object bean, ValidatorAction va,
-                                            Field field,
-                                            ActionMessages errors,
-                                            Validator validator,
-                                            HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -606,10 +558,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -631,9 +580,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateFloat(Object bean, ValidatorAction va,
-                                       Field field, ActionMessages errors,
-                                       Validator validator,
-                                       HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -647,10 +595,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -672,10 +617,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateFloatLocale(Object bean, ValidatorAction va,
-                                             Field field,
-                                             ActionMessages errors,
-                                             Validator validator,
-                                             HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -691,10 +634,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -716,9 +656,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateDouble(Object bean, ValidatorAction va,
-                                        Field field, ActionMessages errors,
-                                        Validator validator,
-                                        HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -732,10 +671,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -757,10 +693,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateDoubleLocale(Object bean, ValidatorAction va,
-                                              Field field,
-                                              ActionMessages errors,
-                                              Validator validator,
-                                              HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -776,10 +710,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -809,21 +740,22 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateDate(Object bean, ValidatorAction va,
-                                      Field field, ActionMessages errors,
-                                      Validator validator,
-                                      HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
         value = evaluateBean(bean, field);
 
         boolean isStrict = false;
-        String datePattern = Resources.getVarValue("datePattern", field,
-                validator, request, false);
+        String datePattern =
+            Resources.getVarValue("datePattern", field, validator, request,
+                false);
 
         if (GenericValidator.isBlankOrNull(datePattern)) {
-            datePattern = Resources.getVarValue("datePatternStrict", field,
-                    validator, request, false);
+            datePattern =
+                Resources.getVarValue("datePatternStrict", field, validator,
+                    request, false);
 
             if (!GenericValidator.isBlankOrNull(datePattern)) {
                 isStrict = true;
@@ -840,20 +772,16 @@
             if (GenericValidator.isBlankOrNull(datePattern)) {
                 result = GenericTypeValidator.formatDate(value, locale);
             } else {
-                result = GenericTypeValidator.formatDate(value, datePattern,
-                        isStrict);
+                result =
+                    GenericTypeValidator.formatDate(value, datePattern, isStrict);
             }
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -876,20 +804,18 @@
      * @return True if in range, false otherwise.
      */
     public static boolean validateLongRange(Object bean, ValidatorAction va,
-                                            Field field,
-                                            ActionMessages errors,
-                                            Validator validator,
-                                            HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (!GenericValidator.isBlankOrNull(value)) {
             try {
-                String minVar = Resources.getVarValue("min", field, validator,
-                        request, true);
-                String maxVar = Resources.getVarValue("max", field, validator,
-                        request, true);
+                String minVar =
+                    Resources.getVarValue("min", field, validator, request, true);
+                String maxVar =
+                    Resources.getVarValue("max", field, validator, request, true);
                 long longValue = Long.parseLong(value);
                 long min = Long.parseLong(minVar);
                 long max = Long.parseLong(maxVar);
@@ -901,15 +827,11 @@
 
                 if (!GenericValidator.isInRange(longValue, min, max)) {
                     errors.add(field.getKey(),
-                            Resources.getActionMessage(validator,
-                                    request,
-                                    va,
-                                    field));
+                        Resources.getActionMessage(validator, request, va, field));
 
                     return false;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 processFailure(errors, field, "longRange", e);
 
                 return false;
@@ -936,19 +858,18 @@
      * @return True if in range, false otherwise.
      */
     public static boolean validateIntRange(Object bean, ValidatorAction va,
-                                           Field field, ActionMessages errors,
-                                           Validator validator,
-                                           HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (!GenericValidator.isBlankOrNull(value)) {
             try {
-                String minVar = Resources.getVarValue("min", field, validator,
-                        request, true);
-                String maxVar = Resources.getVarValue("max", field, validator,
-                        request, true);
+                String minVar =
+                    Resources.getVarValue("min", field, validator, request, true);
+                String maxVar =
+                    Resources.getVarValue("max", field, validator, request, true);
                 int min = Integer.parseInt(minVar);
                 int max = Integer.parseInt(maxVar);
                 int intValue = Integer.parseInt(value);
@@ -960,15 +881,11 @@
 
                 if (!GenericValidator.isInRange(intValue, min, max)) {
                     errors.add(field.getKey(),
-                            Resources.getActionMessage(validator,
-                                    request,
-                                    va,
-                                    field));
+                        Resources.getActionMessage(validator, request, va, field));
 
                     return false;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 processFailure(errors, field, "intRange", e);
 
                 return false;
@@ -995,20 +912,18 @@
      * @return True if in range, false otherwise.
      */
     public static boolean validateDoubleRange(Object bean, ValidatorAction va,
-                                              Field field,
-                                              ActionMessages errors,
-                                              Validator validator,
-                                              HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (!GenericValidator.isBlankOrNull(value)) {
             try {
-                String minVar = Resources.getVarValue("min", field, validator,
-                        request, true);
-                String maxVar = Resources.getVarValue("max", field, validator,
-                        request, true);
+                String minVar =
+                    Resources.getVarValue("min", field, validator, request, true);
+                String maxVar =
+                    Resources.getVarValue("max", field, validator, request, true);
                 double doubleValue = Double.parseDouble(value);
                 double min = Double.parseDouble(minVar);
                 double max = Double.parseDouble(maxVar);
@@ -1020,15 +935,11 @@
 
                 if (!GenericValidator.isInRange(doubleValue, min, max)) {
                     errors.add(field.getKey(),
-                            Resources.getActionMessage(validator,
-                                    request,
-                                    va,
-                                    field));
+                        Resources.getActionMessage(validator, request, va, field));
 
                     return false;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 processFailure(errors, field, "doubleRange", e);
 
                 return false;
@@ -1055,20 +966,18 @@
      * @return True if in range, false otherwise.
      */
     public static boolean validateFloatRange(Object bean, ValidatorAction va,
-                                             Field field,
-                                             ActionMessages errors,
-                                             Validator validator,
-                                             HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (!GenericValidator.isBlankOrNull(value)) {
             try {
-                String minVar = Resources.getVarValue("min", field, validator,
-                        request, true);
-                String maxVar = Resources.getVarValue("max", field, validator,
-                        request, true);
+                String minVar =
+                    Resources.getVarValue("min", field, validator, request, true);
+                String maxVar =
+                    Resources.getVarValue("max", field, validator, request, true);
                 float floatValue = Float.parseFloat(value);
                 float min = Float.parseFloat(minVar);
                 float max = Float.parseFloat(maxVar);
@@ -1080,15 +989,11 @@
 
                 if (!GenericValidator.isInRange(floatValue, min, max)) {
                     errors.add(field.getKey(),
-                            Resources.getActionMessage(validator,
-                                    request,
-                                    va,
-                                    field));
+                        Resources.getActionMessage(validator, request, va, field));
 
                     return false;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 processFailure(errors, field, "floatRange", e);
 
                 return false;
@@ -1114,10 +1019,8 @@
      * @return true if valid, false otherwise.
      */
     public static Object validateCreditCard(Object bean, ValidatorAction va,
-                                            Field field,
-                                            ActionMessages errors,
-                                            Validator validator,
-                                            HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         Object result = null;
         String value = null;
 
@@ -1131,10 +1034,7 @@
 
         if (result == null) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
         }
 
         return (result == null) ? Boolean.FALSE : result;
@@ -1156,20 +1056,16 @@
      * @return True if valid, false otherwise.
      */
     public static boolean validateEmail(Object bean, ValidatorAction va,
-                                        Field field, ActionMessages errors,
-                                        Validator validator,
-                                        HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (!GenericValidator.isBlankOrNull(value)
-                && !GenericValidator.isEmail(value)) {
+            && !GenericValidator.isEmail(value)) {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
 
             return false;
         } else {
@@ -1194,31 +1090,26 @@
      * @return True if stated conditions met.
      */
     public static boolean validateMaxLength(Object bean, ValidatorAction va,
-                                            Field field,
-                                            ActionMessages errors,
-                                            Validator validator,
-                                            HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (value != null) {
             try {
-                String maxVar = Resources.getVarValue("maxlength", field,
-                        validator, request, true);
+                String maxVar =
+                    Resources.getVarValue("maxlength", field, validator,
+                        request, true);
                 int max = Integer.parseInt(maxVar);
 
                 if (!GenericValidator.maxLength(value, max)) {
                     errors.add(field.getKey(),
-                            Resources.getActionMessage(validator,
-                                    request,
-                                    va,
-                                    field));
+                        Resources.getActionMessage(validator, request, va, field));
 
                     return false;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 processFailure(errors, field, "floatRange", e);
 
                 return false;
@@ -1245,31 +1136,26 @@
      * @return True if stated conditions met.
      */
     public static boolean validateMinLength(Object bean, ValidatorAction va,
-                                            Field field,
-                                            ActionMessages errors,
-                                            Validator validator,
-                                            HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
 
         if (!GenericValidator.isBlankOrNull(value)) {
             try {
-                String minVar = Resources.getVarValue("minlength", field,
-                        validator, request, true);
+                String minVar =
+                    Resources.getVarValue("minlength", field, validator,
+                        request, true);
                 int min = Integer.parseInt(minVar);
 
                 if (!GenericValidator.minLength(value, min)) {
                     errors.add(field.getKey(),
-                            Resources.getActionMessage(validator,
-                                    request,
-                                    va,
-                                    field));
+                        Resources.getActionMessage(validator, request, va, field));
 
                     return false;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 processFailure(errors, field, "minlength", e);
 
                 return false;
@@ -1281,21 +1167,31 @@
 
     /**
      * Checks if a field has a valid url. Four optional variables can be
-     * specified to configure url validation. <ul> <li>Variable
+     * specified to configure url validation.
+     *
+     * <ul>
+     *
+     * <li>Variable
      * <code>allow2slashes</code> can be set to <code>true</code> or
      * <code>false</code> to control whether two slashes are allowed - default
      * is <code>false</code> (i.e. two slashes are NOT allowed).</li>
+     *
      * <li>Variable <code>nofragments</code> can be set to <code>true</code>
      * or <code>false</code> to control whether fragments are allowed -
      * default is <code>false</code> (i.e. fragments ARE allowed).</li>
+     *
      * <li>Variable <code>allowallschemes</code> can be set to
      * <code>true</code> or <code>false</code> to control if all schemes are
      * allowed - default is <code>false</code> (i.e. all schemes are NOT
-     * allowed).</li> <li>Variable <code>schemes</code> can be set to a comma
+     * allowed).</li>
+     *
+     * <li>Variable <code>schemes</code> can be set to a comma
      * delimited list of valid schemes. This value is ignored if
      * <code>allowallschemes</code> is set to <code>true</code>. Default
      * schemes allowed are "http", "https" and "ftp" if this variable is not
-     * specified.</li> </ul>
+     * specified.</li>
+     *
+     * </ul>
      *
      * @param bean      The bean validation is being performed on.
      * @param va        The <code>ValidatorAction</code> that is currently
@@ -1310,9 +1206,8 @@
      * @return True if valid, false otherwise.
      */
     public static boolean validateUrl(Object bean, ValidatorAction va,
-                                      Field field, ActionMessages errors,
-                                      Validator validator,
-                                      HttpServletRequest request) {
+        Field field, ActionMessages errors, Validator validator,
+        HttpServletRequest request) {
         String value = null;
 
         value = evaluateBean(bean, field);
@@ -1322,29 +1217,32 @@
         }
 
         // Get the options and schemes Vars
-        String allowallschemesVar = Resources.getVarValue("allowallschemes",
-                field, validator, request, false);
+        String allowallschemesVar =
+            Resources.getVarValue("allowallschemes", field, validator, request,
+                false);
         boolean allowallschemes = "true".equalsIgnoreCase(allowallschemesVar);
         int options = allowallschemes ? UrlValidator.ALLOW_ALL_SCHEMES : 0;
 
         String allow2slashesVar =
-                Resources.getVarValue("allow2slashes", field,
-                        validator, request, false);
+            Resources.getVarValue("allow2slashes", field, validator, request,
+                false);
 
         if ("true".equalsIgnoreCase(allow2slashesVar)) {
             options += UrlValidator.ALLOW_2_SLASHES;
         }
 
-        String nofragmentsVar = Resources.getVarValue("nofragments", field,
-                validator, request, false);
+        String nofragmentsVar =
+            Resources.getVarValue("nofragments", field, validator, request,
+                false);
 
         if ("true".equalsIgnoreCase(nofragmentsVar)) {
             options += UrlValidator.NO_FRAGMENTS;
         }
 
-        String schemesVar = allowallschemes ? null
-                : Resources.getVarValue("schemes",
-                field, validator, request, false);
+        String schemesVar =
+            allowallschemes ? null
+                            : Resources.getVarValue("schemes", field,
+                validator, request, false);
 
         // No options or schemes - use GenericValidator as default
         if ((options == 0) && (schemesVar == null)) {
@@ -1352,10 +1250,7 @@
                 return true;
             } else {
                 errors.add(field.getKey(),
-                        Resources.getActionMessage(validator,
-                                request,
-                                va,
-                                field));
+                    Resources.getActionMessage(validator, request, va, field));
 
                 return false;
             }
@@ -1383,10 +1278,7 @@
             return true;
         } else {
             errors.add(field.getKey(),
-                    Resources.getActionMessage(validator,
-                            request,
-                            va,
-                            field));
+                Resources.getActionMessage(validator, request, va, field));
 
             return false;
         }
@@ -1396,11 +1288,11 @@
      * Process a validation failure.
      */
     private static void processFailure(ActionMessages errors, Field field,
-                                       String validator, Throwable t) {
+        String validator, Throwable t) {
         // Log the error
         String logErrorMsg =
-                sysmsgs.getMessage("validation.failed", validator,
-                        field.getProperty(), t.toString());
+            sysmsgs.getMessage("validation.failed", validator,
+                field.getProperty(), t.toString());
 
         log.error(logErrorMsg);
 



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