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/01/21 01:21:00 UTC

svn commit: r370938 [14/50] - in /struts: action/trunk/ action/trunk/conf/java/ action/trunk/src/java/org/apache/struts/ action/trunk/src/java/org/apache/struts/action/ action/trunk/src/java/org/apache/struts/chain/ action/trunk/src/java/org/apache/str...

Modified: struts/action/trunk/src/java/org/apache/struts/mock/MockPrincipal.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockPrincipal.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockPrincipal.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockPrincipal.java Fri Jan 20 16:19:02 2006
@@ -15,19 +15,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.mock;
 
-
 import java.security.Principal;
 
-
 /**
- * <p>Mock <strong>Principal</strong> object for low-level unit tests
- * of Struts controller components.  Coarser grained tests should be
- * implemented in terms of the Cactus framework, instead of the mock
- * object classes.</p>
+ * <p>Mock <strong>Principal</strong> object for low-level unit tests of
+ * Struts controller components.  Coarser grained tests should be implemented
+ * in terms of the Cactus framework, instead of the mock object classes.</p>
  *
  * <p><strong>WARNING</strong> - Only the minimal set of methods needed to
  * create unit tests is provided, plus additional methods to configure this
@@ -37,11 +32,12 @@
  * <p><strong>WARNING</strong> - Because unit tests operate in a single
  * threaded environment, no synchronization is performed.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
  */
-
 public class MockPrincipal implements Principal {
-
+    protected String name = null;
+    protected String[] roles = null;
 
     public MockPrincipal() {
         super();
@@ -49,50 +45,43 @@
         this.roles = new String[0];
     }
 
-
     public MockPrincipal(String name) {
         super();
         this.name = name;
         this.roles = new String[0];
     }
 
-
-    public MockPrincipal(String name, String roles[]) {
+    public MockPrincipal(String name, String[] roles) {
         super();
         this.name = name;
         this.roles = roles;
     }
 
-
-    protected String name = null;
-
-
-    protected String roles[] = null;
-
-
     public String getName() {
         return (this.name);
     }
 
-
     public boolean isUserInRole(String role) {
         for (int i = 0; i < roles.length; i++) {
             if (role.equals(roles[i])) {
                 return (true);
             }
         }
+
         return (false);
     }
 
-
     public boolean equals(Object o) {
         if (o == null) {
             return (false);
         }
+
         if (!(o instanceof Principal)) {
             return (false);
         }
+
         Principal p = (Principal) o;
+
         if (name == null) {
             return (p.getName() == null);
         } else {
@@ -100,7 +89,6 @@
         }
     }
 
-
     public int hashCode() {
         if (name == null) {
             return ("".hashCode());
@@ -108,6 +96,4 @@
             return (name.hashCode());
         }
     }
-
-
 }

Modified: struts/action/trunk/src/java/org/apache/struts/mock/MockServletConfig.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockServletConfig.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockServletConfig.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockServletConfig.java Fri Jan 20 16:19:02 2006
@@ -15,23 +15,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.mock;
 
-
-import java.util.Enumeration;
-import java.util.HashMap;
-
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
-
+import java.util.Enumeration;
+import java.util.HashMap;
 
 /**
- * <p>Mock <strong>ServletConfig</strong> object for low-level unit tests
- * of Struts controller components.  Coarser grained tests should be
- * implemented in terms of the Cactus framework, instead of the mock
- * object classes.</p>
+ * <p>Mock <strong>ServletConfig</strong> object for low-level unit tests of
+ * Struts controller components.  Coarser grained tests should be implemented
+ * in terms of the Cactus framework, instead of the mock object classes.</p>
  *
  * <p><strong>WARNING</strong> - Only the minimal set of methods needed to
  * create unit tests is provided, plus additional methods to configure this
@@ -41,68 +35,47 @@
  * <p><strong>WARNING</strong> - Because unit tests operate in a single
  * threaded environment, no synchronization is performed.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
  */
-
 public class MockServletConfig implements ServletConfig {
-
-
+    // ----------------------------------------------------- Instance Variables
+    protected ServletContext context = null;
+    protected HashMap parameters = new HashMap();
 
     // ----------------------------------------------------------- Constructors
-
-
     public MockServletConfig() {
         super();
     }
 
-
     public MockServletConfig(ServletContext context) {
         super();
         setServletContext(context);
     }
 
-
-    // ----------------------------------------------------- Instance Variables
-
-
-    protected ServletContext context = null;
-    protected HashMap parameters = new HashMap();
-
-
     // --------------------------------------------------------- Public Methods
-
-
     public void addInitParameter(String name, String value) {
         parameters.put(name, value);
     }
 
-
     public void setServletContext(ServletContext context) {
         this.context = context;
     }
 
-
     // ------------------------------------------------- ServletContext Methods
-
-
     public String getInitParameter(String name) {
         return ((String) parameters.get(name));
     }
 
-
     public Enumeration getInitParameterNames() {
         return (new MockEnumeration(parameters.keySet().iterator()));
     }
 
-
     public ServletContext getServletContext() {
         return (this.context);
     }
 
-
     public String getServletName() {
         return ("action");
     }
-
-
 }

Modified: struts/action/trunk/src/java/org/apache/struts/mock/MockServletContext.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockServletContext.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockServletContext.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockServletContext.java Fri Jan 20 16:19:02 2006
@@ -15,28 +15,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.mock;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Set;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 
 /**
- * <p>Mock <strong>ServletContext</strong> object for low-level unit tests
- * of Struts controller components.  Coarser grained tests should be
- * implemented in terms of the Cactus framework, instead of the mock
- * object classes.</p>
+ * <p>Mock <strong>ServletContext</strong> object for low-level unit tests of
+ * Struts controller components.  Coarser grained tests should be implemented
+ * in terms of the Cactus framework, instead of the mock object classes.</p>
  *
  * <p><strong>WARNING</strong> - Only the minimal set of methods needed to
  * create unit tests is provided, plus additional methods to configure this
@@ -46,168 +42,133 @@
  * <p><strong>WARNING</strong> - Because unit tests operate in a single
  * threaded environment, no synchronization is performed.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
  */
-
 public class MockServletContext implements ServletContext {
-
-
-
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * The set of servlet context attributes.
      */
     protected HashMap attributes = new HashMap();
 
-
     /**
      * Default destination for <code>log()</code> output.
      */
     protected Log log = LogFactory.getLog(MockServletContext.class);
 
-
     /**
      * The set of context initialization parameters.
      */
     protected HashMap parameters = new HashMap();
 
-
     // --------------------------------------------------------- Public Methods
-
-
     public void addInitParameter(String name, String value) {
         parameters.put(name, value);
     }
 
-
     public void setLog(Log log) {
         this.log = log;
     }
 
-
-
     // ------------------------------------------------- ServletContext Methods
-
-
     public Object getAttribute(String name) {
         return (attributes.get(name));
     }
 
-
     public Enumeration getAttributeNames() {
         return (new MockEnumeration(attributes.keySet().iterator()));
     }
 
-
     public ServletContext getContext(String uripath) {
         throw new UnsupportedOperationException();
     }
 
-
     public String getInitParameter(String name) {
         return ((String) parameters.get(name));
     }
 
-
     public Enumeration getInitParameterNames() {
         return (new MockEnumeration(parameters.keySet().iterator()));
     }
 
-
     public int getMajorVersion() {
         return (2);
     }
 
-
     public String getMimeType(String file) {
         throw new UnsupportedOperationException();
     }
 
-
     public int getMinorVersion() {
         return (3);
     }
 
-
     public RequestDispatcher getNamedDispatcher(String name) {
         throw new UnsupportedOperationException();
     }
 
-
     public String getRealPath(String path) {
         throw new UnsupportedOperationException();
     }
 
-
     public RequestDispatcher getRequestDispatcher(String path) {
         throw new UnsupportedOperationException();
     }
 
-
     public URL getResource(String path) {
-      return this.getClass().getResource(path);
+        return this.getClass().getResource(path);
+
         //throw new UnsupportedOperationException();
     }
 
-
     public InputStream getResourceAsStream(String path) {
-      return this.getClass().getResourceAsStream(path);
+        return this.getClass().getResourceAsStream(path);
+
         //throw new UnsupportedOperationException();
     }
 
-
     public Set getResourcePaths(String path) {
         throw new UnsupportedOperationException();
     }
 
-
     public String getServerInfo() {
         return ("MockServletContext/$Version$");
     }
 
-
     public Servlet getServlet(String name) {
         throw new UnsupportedOperationException();
     }
 
-
     public String getServletContextName() {
         return (getServerInfo());
     }
 
-
     public Enumeration getServletNames() {
         throw new UnsupportedOperationException();
     }
 
-
     public Enumeration getServlets() {
         throw new UnsupportedOperationException();
     }
 
-
     public void log(Exception exception, String message) {
         log(message, exception);
     }
 
-
     public void log(String message) {
         log.info(message);
     }
 
-
     public void log(String message, Throwable throwable) {
         log.error(message, throwable);
     }
 
-
     public void removeAttribute(String name) {
         attributes.remove(name);
     }
 
-
     public void setAttribute(String name, Object value) {
         if (value == null) {
             attributes.remove(name);
@@ -215,7 +176,4 @@
             attributes.put(name, value);
         }
     }
-
-
-
 }

Modified: struts/action/trunk/src/java/org/apache/struts/mock/TestMockBase.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/TestMockBase.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/TestMockBase.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/TestMockBase.java Fri Jan 20 16:19:02 2006
@@ -15,64 +15,34 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.mock;
 
-
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
 import org.apache.struts.Globals;
 import org.apache.struts.action.ActionFormBean;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
-import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.ControllerConfig;
 import org.apache.struts.config.FormPropertyConfig;
 import org.apache.struts.config.ForwardConfig;
+import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.ModuleConfigFactory;
 
-
-
 /**
- * <p>Convenience base class for unit tests of the
- * <code>org.apache.struts.util</code> package, and others that require
- * a runtime environment similar to what the Struts controller servlet
- * sets up.  The <code>setUp()</code> method establishes
- * a consistent basic environment for the various tests.  The only
+ * <p>Convenience base class for unit tests of the <code>org.apache.struts.util</code>
+ * package, and others that require a runtime environment similar to what the
+ * Struts controller servlet sets up.  The <code>setUp()</code> method
+ * establishes a consistent basic environment for the various tests.  The only
  * tests included in this class are simple validations that the basic
  * environment was set up correctly.</p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-14 17:24:39 -0400 (Sun, 14 Aug 2005)
+ *          $
  */
-
 public class TestMockBase extends TestCase {
-
-
-    // ----------------------------------------------------------------- Basics
-
-
-    public TestMockBase(String name) {
-        super(name);
-    }
-
-
-    public static void main(String args[]) {
-        junit.awtui.TestRunner.main
-            (new String[] { TestMockBase.class.getName() } );
-    }
-
-
-    public static Test suite() {
-        return (new TestSuite(TestMockBase.class));
-    }
-
-
     // ----------------------------------------------------- Instance Variables
-
-
     protected ModuleConfig moduleConfig = null;
     protected ModuleConfig moduleConfig2 = null;
     protected ModuleConfig moduleConfig3 = null;
@@ -84,19 +54,29 @@
     protected MockHttpServletResponse response = null;
     protected MockHttpSession session = null;
 
+    // ----------------------------------------------------------------- Basics
+    public TestMockBase(String name) {
+        super(name);
+    }
 
-    // ----------------------------------------------------- Setup and Teardown
+    public static void main(String[] args) {
+        junit.awtui.TestRunner
+                .main(new String[]{TestMockBase.class.getName()});
+    }
 
+    public static Test suite() {
+        return (new TestSuite(TestMockBase.class));
+    }
 
+    // ----------------------------------------------------- Setup and Teardown
     public void setUp() {
-
         // Set up the servlet API objects for a test scenario
         context = new MockServletContext();
         config = new MockServletConfig(context);
         session = new MockHttpSession(context);
         request = new MockHttpServletRequest(session);
         principal = new MockPrincipal("username",
-                                      new String[] { "admin", "manager" });
+                new String[]{"admin", "manager"});
         request.setUserPrincipal(principal);
         response = new MockHttpServletResponse();
         page = new MockPageContext(config, request, response);
@@ -111,41 +91,39 @@
         // default module can be tested.  To select a module,
         // tests should set the request attribute Globals.MODULE_KEY
         // to the ModuleConfig instance for the selected module
-
     }
 
-
     protected void setUpDefaultApp() {
-
         ActionFormBean formBean = null;
         ActionMapping mapping = null;
 
-        ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
+        ModuleConfigFactory factoryObject =
+                ModuleConfigFactory.createFactory();
+
         moduleConfig = factoryObject.createModuleConfig("");
 
         context.setAttribute(Globals.MODULE_KEY, moduleConfig);
 
         // Forward "external" to "http://jakarta.apache.org/"
-        moduleConfig.addForwardConfig
-            (new ActionForward("external", "http://jakarta.apache.org/",
-                               false));
+        moduleConfig.addForwardConfig(new ActionForward("external",
+                "http://jakarta.apache.org/", false));
 
         // Forward "foo" to "/bar.jsp"
-        moduleConfig.addForwardConfig
-            (new ActionForward("foo", "/bar.jsp", false));
+        moduleConfig.addForwardConfig(new ActionForward("foo",
+                "/bar.jsp",
+                false));
 
         // Forward "relative1" to "relative.jsp" non-context-relative
-        moduleConfig.addForwardConfig
-            (new ActionForward("relative1", "relative.jsp", false));
+        moduleConfig.addForwardConfig(new ActionForward("relative1",
+                "relative.jsp", false));
 
         // Forward "relative2" to "relative.jsp" context-relative
-        moduleConfig.addForwardConfig
-            (new ActionForward("relative2", "relative.jsp", false));
+        moduleConfig.addForwardConfig(new ActionForward("relative2",
+                "relative.jsp", false));
 
         // Form Bean "static" is a standard ActionForm subclass
-        formBean = new ActionFormBean
-            ("static",
-             "org.apache.struts.mock.MockFormBean");
+        formBean = new ActionFormBean("static",
+                "org.apache.struts.mock.MockFormBean");
         moduleConfig.addFormBeanConfig(formBean);
 
         // Action "/static" uses the "static" form bean in request scope
@@ -158,14 +136,12 @@
         moduleConfig.addActionConfig(mapping);
 
         // Form Bean "dynamic" is a DynaActionForm with the same properties
-        formBean = new ActionFormBean
-            ("dynamic",
-             "org.apache.struts.action.DynaActionForm");
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("stringProperty", "java.lang.String",
-                                    null));
+        formBean = new ActionFormBean("dynamic",
+                "org.apache.struts.action.DynaActionForm");
+        formBean.addFormPropertyConfig(new FormPropertyConfig(
+                "booleanProperty", "boolean", "false"));
+        formBean.addFormPropertyConfig(new FormPropertyConfig(
+                "stringProperty", "java.lang.String", null));
         moduleConfig.addFormBeanConfig(formBean);
 
         // Action "/dynamic" uses the "dynamic" form bean in session scope
@@ -178,30 +154,24 @@
         moduleConfig.addActionConfig(mapping);
 
         // Form Bean "/dynamic0" is a DynaActionForm with initializers
-        formBean = new ActionFormBean
-            ("dynamic0",
-             "org.apache.struts.action.DynaActionForm");
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("booleanProperty", "boolean", "true"));
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("stringProperty", "java.lang.String",
-                                    "String Property"));
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("intArray1", "int[]",
-                                    "{1,2,3}", 4)); // 4 should be ignored
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("intArray2", "int[]",
-                                    null, 5)); // 5 should be respected
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("principal",
-                                    "org.apache.struts.mock.MockPrincipal",
-                                    null));
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("stringArray1", "java.lang.String[]",
-                                    "{aaa,bbb,ccc}", 2)); // 2 should be ignored
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("stringArray2", "java.lang.String[]",
-                                    null, 3)); // 3 should be respected
+        formBean = new ActionFormBean("dynamic0",
+                "org.apache.struts.action.DynaActionForm");
+        formBean.addFormPropertyConfig(new FormPropertyConfig(
+                "booleanProperty", "boolean", "true"));
+        formBean.addFormPropertyConfig(new FormPropertyConfig(
+                "stringProperty", "java.lang.String", "String Property"));
+        formBean.addFormPropertyConfig(new FormPropertyConfig("intArray1",
+                "int[]", "{1,2,3}", 4)); // 4 should be ignored
+        formBean.addFormPropertyConfig(new FormPropertyConfig("intArray2",
+                "int[]", null, 5)); // 5 should be respected
+        formBean.addFormPropertyConfig(new FormPropertyConfig("principal",
+                "org.apache.struts.mock.MockPrincipal", null));
+        formBean.addFormPropertyConfig(new FormPropertyConfig("stringArray1",
+                "java.lang.String[]",
+                "{aaa,bbb,ccc}",
+                2)); // 2 should be ignored
+        formBean.addFormPropertyConfig(new FormPropertyConfig("stringArray2",
+                "java.lang.String[]", null, 3)); // 3 should be respected
         moduleConfig.addFormBeanConfig(formBean);
 
         // Action "/dynamic0" uses the "dynamic0" form bean in request scope
@@ -219,75 +189,58 @@
         moduleConfig.addActionConfig(mapping);
 
         // Configure global forward declarations
-        moduleConfig.addForwardConfig
-            (new ForwardConfig("moduleForward",
-                               "/module/forward",
-                               false)); // No redirect, same module
-
-        moduleConfig.addForwardConfig
-            (new ForwardConfig("moduleRedirect",
-                               "/module/redirect",
-                               true));  // Redirect, same module
-
-        moduleConfig.addForwardConfig
-            (new ForwardConfig("contextForward",
-                               "/forward",
-                               false,   // No redirect
-                               "/context"));  // Specify module
-
-        moduleConfig.addForwardConfig
-            (new ForwardConfig("contextRedirect",
-                               "/redirect",
-                               true,    // Redirect
-                               "/context"));  // Specify module
-
-        moduleConfig.addForwardConfig
-            (new ForwardConfig("moduleNoslash",
-                               "module/noslash",
-                               false)); // No redirect, same module
-                               
-
-        moduleConfig.addForwardConfig
-            (new ForwardConfig("contextNoslash",
-                               "noslash",
-                               false,   // No redirect
-                               "/context"));  // Specify module
+        moduleConfig.addForwardConfig(new ForwardConfig("moduleForward",
+                "/module/forward", false)); // No redirect, same module
 
-    }
+        moduleConfig.addForwardConfig(new ForwardConfig("moduleRedirect",
+                "/module/redirect", true)); // Redirect, same module
 
+        moduleConfig.addForwardConfig(new ForwardConfig("contextForward",
+                "/forward", false, // No redirect
+                "/context")); // Specify module
+
+        moduleConfig.addForwardConfig(new ForwardConfig("contextRedirect",
+                "/redirect", true, // Redirect
+                "/context")); // Specify module
+
+        moduleConfig.addForwardConfig(new ForwardConfig("moduleNoslash",
+                "module/noslash", false)); // No redirect, same module
+
+        moduleConfig.addForwardConfig(new ForwardConfig("contextNoslash",
+                "noslash", false, // No redirect
+                "/context")); // Specify module
+    }
 
     protected void setUpSecondApp() {
-
         ActionFormBean formBean = null;
         ActionMapping mapping = null;
 
+        ModuleConfigFactory factoryObject =
+                ModuleConfigFactory.createFactory();
 
-        ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
         moduleConfig2 = factoryObject.createModuleConfig("/2");
 
         context.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);
 
         // Forward "external" to "http://jakarta.apache.org/"
-        moduleConfig2.addForwardConfig
-            (new ActionForward("external", "http://jakarta.apache.org/",
-                               false));
+        moduleConfig2.addForwardConfig(new ActionForward("external",
+                "http://jakarta.apache.org/", false));
 
         // Forward "foo" to "/baz.jsp" (different from default)
-        moduleConfig2.addForwardConfig
-            (new ActionForward("foo", "/baz.jsp", false));
+        moduleConfig2.addForwardConfig(new ActionForward("foo", "/baz.jsp",
+                false));
 
         // Forward "relative1" to "relative.jsp" non-context-relative
-        moduleConfig2.addForwardConfig
-            (new ActionForward("relative1", "relative.jsp", false));
+        moduleConfig2.addForwardConfig(new ActionForward("relative1",
+                "relative.jsp", false));
 
         // Forward "relative2" to "relative.jsp" context-relative
-        moduleConfig2.addForwardConfig
-            (new ActionForward("relative2", "relative.jsp", false));
+        moduleConfig2.addForwardConfig(new ActionForward("relative2",
+                "relative.jsp", false));
 
         // Form Bean "static" is a standard ActionForm subclass (same as default)
-        formBean = new ActionFormBean
-            ("static",
-             "org.apache.struts.mock.MockFormBean");
+        formBean = new ActionFormBean("static",
+                "org.apache.struts.mock.MockFormBean");
         moduleConfig2.addFormBeanConfig(formBean);
 
         // Action "/static" uses the "static" form bean in request scope (same as default)
@@ -300,14 +253,12 @@
         moduleConfig2.addActionConfig(mapping);
 
         // Form Bean "dynamic2" is a DynaActionForm with the same properties
-        formBean = new ActionFormBean
-            ("dynamic2",
-             "org.apache.struts.action.DynaActionForm");
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
-        formBean.addFormPropertyConfig
-            (new FormPropertyConfig("stringProperty", "java.lang.String",
-                                    null));
+        formBean = new ActionFormBean("dynamic2",
+                "org.apache.struts.action.DynaActionForm");
+        formBean.addFormPropertyConfig(new FormPropertyConfig(
+                "booleanProperty", "boolean", "false"));
+        formBean.addFormPropertyConfig(new FormPropertyConfig(
+                "stringProperty", "java.lang.String", null));
         moduleConfig2.addFormBeanConfig(formBean);
 
         // Action "/dynamic2" uses the "dynamic2" form bean in session scope
@@ -326,54 +277,40 @@
         moduleConfig2.addActionConfig(mapping);
 
         // Configure global forward declarations
-        moduleConfig2.addForwardConfig
-            (new ForwardConfig("moduleForward",
-                               "/module/forward",
-                               false)); // No redirect, same module
-
-        moduleConfig2.addForwardConfig
-            (new ForwardConfig("moduleRedirect",
-                               "/module/redirect",
-                               true));  // Redirect, same module
-                               
-
-        moduleConfig2.addForwardConfig
-            (new ForwardConfig("contextForward",
-                               "/forward",
-                               false,   // No redirect
-                               "/context"));  // Specify module
-
-        moduleConfig2.addForwardConfig
-            (new ForwardConfig("contextRedirect",
-                               "/redirect",
-                               true,    // Redirect
-                               "/context"));  // Specify module
-
-        moduleConfig2.addForwardConfig
-            (new ForwardConfig("moduleNoslash",
-                               "module/noslash",
-                               false)); // No redirect, same module
-
-        moduleConfig2.addForwardConfig
-            (new ForwardConfig("contextNoslash",
-                               "noslash",
-                               false,   // No redirect
-                               "/context"));  // Specify module
+        moduleConfig2.addForwardConfig(new ForwardConfig("moduleForward",
+                "/module/forward", false)); // No redirect, same module
 
-    }
+        moduleConfig2.addForwardConfig(new ForwardConfig("moduleRedirect",
+                "/module/redirect", true)); // Redirect, same module
 
+        moduleConfig2.addForwardConfig(new ForwardConfig("contextForward",
+                "/forward", false, // No redirect
+                "/context")); // Specify module
+
+        moduleConfig2.addForwardConfig(new ForwardConfig("contextRedirect",
+                "/redirect", true, // Redirect
+                "/context")); // Specify module
+
+        moduleConfig2.addForwardConfig(new ForwardConfig("moduleNoslash",
+                "module/noslash", false)); // No redirect, same module
+
+        moduleConfig2.addForwardConfig(new ForwardConfig("contextNoslash",
+                "noslash", false, // No redirect
+                "/context")); // Specify module
+    }
 
     // Set up third app for testing URL mapping
     protected void setUpThirdApp() {
+        ModuleConfigFactory factoryObject =
+                ModuleConfigFactory.createFactory();
 
-
-        ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
         moduleConfig3 = factoryObject.createModuleConfig("/3");
 
         context.setAttribute(Globals.MODULE_KEY + "/3", moduleConfig3);
 
         // Instantiate the controller configuration for this app
         ControllerConfig controller = new ControllerConfig();
+
         moduleConfig3.setControllerConfig(controller);
 
         // Configure the properties we will be testing
@@ -382,44 +319,29 @@
         controller.setPagePattern("/paging$M$P");
 
         // Configure global forward declarations
-        moduleConfig3.addForwardConfig
-            (new ForwardConfig("moduleForward",
-                               "/module/forward",
-                               false));   // No redirect, same module
-
-        moduleConfig3.addForwardConfig
-            (new ForwardConfig("moduleRedirect",
-                               "/module/redirect",
-                               true));  // Redirect, same module
-
-        moduleConfig3.addForwardConfig
-            (new ForwardConfig("contextForward",
-                               "/forward",
-                               false,   // No redirect
-                               "/context"));  // Specify module
-
-        moduleConfig3.addForwardConfig
-            (new ForwardConfig("contextRedirect",
-                               "/redirect",
-                               true,    // Redirect
-                               "/context"));  // Specify module
-
-        moduleConfig3.addForwardConfig
-            (new ForwardConfig("moduleNoslash",
-                               "module/noslash",
-                               false)); // No redirect, same module
-
-        moduleConfig3.addForwardConfig
-            (new ForwardConfig("contextNoslash",
-                               "noslash",
-                               false,       // No redirect
-                               "/context"));  // specify module
+        moduleConfig3.addForwardConfig(new ForwardConfig("moduleForward",
+                "/module/forward", false)); // No redirect, same module
 
-    }
+        moduleConfig3.addForwardConfig(new ForwardConfig("moduleRedirect",
+                "/module/redirect", true)); // Redirect, same module
 
+        moduleConfig3.addForwardConfig(new ForwardConfig("contextForward",
+                "/forward", false, // No redirect
+                "/context")); // Specify module
+
+        moduleConfig3.addForwardConfig(new ForwardConfig("contextRedirect",
+                "/redirect", true, // Redirect
+                "/context")); // Specify module
+
+        moduleConfig3.addForwardConfig(new ForwardConfig("moduleNoslash",
+                "module/noslash", false)); // No redirect, same module
+
+        moduleConfig3.addForwardConfig(new ForwardConfig("contextNoslash",
+                "noslash", false, // No redirect
+                "/context")); // specify module
+    }
 
     public void tearDown() {
-
         moduleConfig3 = null;
         moduleConfig2 = null;
         moduleConfig = null;
@@ -430,16 +352,11 @@
         request = null;
         response = null;
         session = null;
-
     }
 
-
     // ------------------------------------------------------- Individual Tests
-
-
     // Test the basic setup of the mock object environment
     public void testUtilBaseEnvironment() {
-
         // Validate the servlet API objects and inter-relationships
         assertNotNull("config is present", config);
         assertNotNull("context is present", context);
@@ -448,38 +365,27 @@
         assertNotNull("request is present", request);
         assertNotNull("response is present", response);
         assertNotNull("session is present", session);
-        assertEquals("page-->config",
-                     config, page.getServletConfig());
-        assertEquals("config-->context",
-                     context, config.getServletContext());
-        assertEquals("page-->context",
-                     context, page.getServletContext());
-        assertEquals("page-->request",
-                     request, page.getRequest());
-        assertEquals("page-->response",
-                     response, page.getResponse());
-        assertEquals("page-->session",
-                     session, page.getSession());
-        assertEquals("request-->principal",
-                     principal, request.getUserPrincipal());
-        assertEquals("request-->session",
-                     session, request.getSession());
+        assertEquals("page-->config", config, page.getServletConfig());
+        assertEquals("config-->context", context, config.getServletContext());
+        assertEquals("page-->context", context, page.getServletContext());
+        assertEquals("page-->request", request, page.getRequest());
+        assertEquals("page-->response", response, page.getResponse());
+        assertEquals("page-->session", session, page.getSession());
+        assertEquals("request-->principal", principal,
+                request.getUserPrincipal());
+        assertEquals("request-->session", session, request.getSession());
         assertEquals("session-->context",
-                     context, session.getServletContext());
+                context,
+                session.getServletContext());
 
         // Validate the configuration for the default module
         assertNotNull("moduleConfig is present", moduleConfig);
-        assertEquals("context-->moduleConfig",
-                     moduleConfig,
-                     context.getAttribute(Globals.MODULE_KEY));
+        assertEquals("context-->moduleConfig", moduleConfig,
+                context.getAttribute(Globals.MODULE_KEY));
 
         // Validate the configuration for the second module
         assertNotNull("moduleConfig2 is present", moduleConfig2);
-        assertEquals("context-->moduleConfig2",
-                     moduleConfig2,
-                     context.getAttribute(Globals.MODULE_KEY + "/2"));
-
+        assertEquals("context-->moduleConfig2", moduleConfig2,
+                context.getAttribute(Globals.MODULE_KEY + "/2"));
     }
-
-
 }

Modified: struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/upload/CommonsMultipartRequestHandler.java Fri Jan 20 16:19:02 2006
@@ -15,104 +15,90 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.upload;
 
+import org.apache.commons.fileupload.DiskFileUpload;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.Globals;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ModuleConfig;
 
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.Serializable;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.DiskFileUpload;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts.action.ActionServlet;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.config.ModuleConfig;
-import org.apache.struts.Globals;
-
-
- /**
-  * This class implements the <code>MultipartRequestHandler</code> interface
-  * by providing a wrapper around the Jakarta Commons FileUpload library.
-  *
-  * @version $Rev$ $Date$
-  * @since Struts 1.1
-  */
-public class CommonsMultipartRequestHandler implements MultipartRequestHandler {
-
 
+/**
+ * This class implements the <code>MultipartRequestHandler</code> interface by
+ * providing a wrapper around the Jakarta Commons FileUpload library.
+ *
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
+ * @since Struts 1.1
+ */
+public class CommonsMultipartRequestHandler
+        implements MultipartRequestHandler {
     // ----------------------------------------------------- Manifest Constants
 
-
     /**
      * The default value for the maximum allowable size, in bytes, of an
      * uploaded file. The value is equivalent to 250MB.
      */
     public static final long DEFAULT_SIZE_MAX = 250 * 1024 * 1024;
 
-
     /**
-     * The default value for the threshold which determines whether an uploaded
-     * file will be written to disk or cached in memory. The value is equivalent
-     * to 250KB.
+     * The default value for the threshold which determines whether an
+     * uploaded file will be written to disk or cached in memory. The value is
+     * equivalent to 250KB.
      */
     public static final int DEFAULT_SIZE_THRESHOLD = 256 * 1024;
 
-
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * Commons Logging instance.
      */
-    protected static Log log = LogFactory.getLog(
-            CommonsMultipartRequestHandler.class);
-
+    protected static Log log =
+            LogFactory.getLog(CommonsMultipartRequestHandler.class);
 
     /**
      * The combined text and file request parameters.
      */
     private Hashtable elementsAll;
 
-
     /**
      * The file request parameters.
      */
     private Hashtable elementsFile;
 
-
     /**
      * The text request parameters.
      */
     private Hashtable elementsText;
 
-
     /**
      * The action mapping  with which this handler is associated.
      */
     private ActionMapping mapping;
 
-
     /**
      * The servlet with which this handler is associated.
      */
     private ActionServlet servlet;
 
-
     // ---------------------------------------- MultipartRequestHandler Methods
 
-
     /**
      * Retrieves the servlet with which this handler is associated.
      *
@@ -122,7 +108,6 @@
         return this.servlet;
     }
 
-
     /**
      * Sets the servlet with which this handler is associated.
      *
@@ -132,7 +117,6 @@
         this.servlet = servlet;
     }
 
-
     /**
      * Retrieves the action mapping with which this handler is associated.
      *
@@ -142,7 +126,6 @@
         return this.mapping;
     }
 
-
     /**
      * Sets the action mapping with which this handler is associated.
      *
@@ -152,7 +135,6 @@
         this.mapping = mapping;
     }
 
-
     /**
      * Parses the input stream and partitions the parsed items into a set of
      * form fields and a set of file items. In the process, the parsed items
@@ -160,25 +142,27 @@
      * to Struts <code>FormFile</code> instances.
      *
      * @param request The multipart request to be processed.
-     *
      * @throws ServletException if an unrecoverable error occurs.
      */
     public void handleRequest(HttpServletRequest request)
             throws ServletException {
-
         // Get the app config for the current request.
-        ModuleConfig ac = (ModuleConfig) request.getAttribute(
-                Globals.MODULE_KEY);
+        ModuleConfig ac =
+                (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
 
         // Create and configure a DIskFileUpload instance.
         DiskFileUpload upload = new DiskFileUpload();
+
         // The following line is to support an "EncodingFilter"
         // see http://issues.apache.org/bugzilla/show_bug.cgi?id=23255
         upload.setHeaderEncoding(request.getCharacterEncoding());
+
         // Set the maximum size before a FileUploadException will be thrown.
         upload.setSizeMax(getSizeMax(ac));
+
         // Set the maximum size that will be stored in memory.
         upload.setSizeThreshold((int) getSizeThreshold(ac));
+
         // Set the the location for saving data on disk.
         upload.setRepositoryPath(getRepositoryPath(ac));
 
@@ -189,21 +173,25 @@
 
         // Parse the request into file items.
         List items = null;
+
         try {
             items = upload.parseRequest(request);
-        } catch (DiskFileUpload.SizeLimitExceededException e) {
+        }
+        catch (DiskFileUpload.SizeLimitExceededException e) {
             // Special handling for uploads that are too big.
-            request.setAttribute(
-                    MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED,
+            request.setAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED,
                     Boolean.TRUE);
+
             return;
-        } catch (FileUploadException e) {
+        }
+        catch (FileUploadException e) {
             log.error("Failed to parse multipart request", e);
             throw new ServletException(e);
         }
 
         // Partition the items into form fields and files.
         Iterator iter = items.iterator();
+
         while (iter.hasNext()) {
             FileItem item = (FileItem) iter.next();
 
@@ -215,7 +203,6 @@
         }
     }
 
-
     /**
      * Returns a hash table containing the text (that is, non-file) request
      * parameters.
@@ -226,7 +213,6 @@
         return this.elementsText;
     }
 
-
     /**
      * Returns a hash table containing the file (that is, non-text) request
      * parameters.
@@ -237,7 +223,6 @@
         return this.elementsFile;
     }
 
-
     /**
      * Returns a hash table containing both text and file request parameters.
      *
@@ -247,7 +232,6 @@
         return this.elementsAll;
     }
 
-
     /**
      * Cleans up when a problem occurs during request processing.
      */
@@ -261,7 +245,6 @@
         }
     }
 
-
     /**
      * Cleans up at the end of a request.
      */
@@ -269,51 +252,45 @@
         rollback();
     }
 
-
     // -------------------------------------------------------- Support Methods
 
-
     /**
      * Returns the maximum allowable size, in bytes, of an uploaded file. The
      * value is obtained from the current module's controller configuration.
      *
      * @param mc The current module's configuration.
-     *
      * @return The maximum allowable file size, in bytes.
      */
     protected long getSizeMax(ModuleConfig mc) {
-        return convertSizeToBytes(
-                mc.getControllerConfig().getMaxFileSize(),
+        return convertSizeToBytes(mc.getControllerConfig().getMaxFileSize(),
                 DEFAULT_SIZE_MAX);
     }
 
-
     /**
      * Returns the size threshold which determines whether an uploaded file
      * will be written to disk or cached in memory.
      *
      * @param mc The current module's configuration.
-     *
      * @return The size threshold, in bytes.
      */
     protected long getSizeThreshold(ModuleConfig mc) {
-        return convertSizeToBytes(
-                mc.getControllerConfig().getMemFileSize(),
+        return convertSizeToBytes(mc.getControllerConfig().getMemFileSize(),
                 DEFAULT_SIZE_THRESHOLD);
     }
 
     /**
-     * Converts a size value from a string representation to its numeric value.
-     * The string must be of the form nnnm, where nnn is an arbitrary decimal
-     * value, and m is a multiplier. The multiplier must be one of 'K', 'M' and
-     * 'G', representing kilobytes, megabytes and gigabytes respectively.
+     * Converts a size value from a string representation to its numeric
+     * value. The string must be of the form nnnm, where nnn is an arbitrary
+     * decimal value, and m is a multiplier. The multiplier must be one of
+     * 'K', 'M' and 'G', representing kilobytes, megabytes and gigabytes
+     * respectively.
      *
-     * If the size value cannot be converted, for example due to invalid syntax,
-     * the supplied default is returned instead.
+     * If the size value cannot be converted, for example due to invalid
+     * syntax, the supplied default is returned instead.
      *
-     * @param sizeString  The string representation of the size to be converted.
+     * @param sizeString  The string representation of the size to be
+     *                    converted.
      * @param defaultSize The value to be returned if the string is invalid.
-     *
      * @return The actual size in bytes.
      */
     protected long convertSizeToBytes(String sizeString, long defaultSize) {
@@ -326,16 +303,19 @@
         } else if (sizeString.endsWith("G")) {
             multiplier = 1024 * 1024 * 1024;
         }
+
         if (multiplier != 1) {
             sizeString = sizeString.substring(0, sizeString.length() - 1);
         }
 
         long size = 0;
+
         try {
             size = Long.parseLong(sizeString);
-        } catch (NumberFormatException nfe) {
-            log.warn("Invalid format for file size ('" + sizeString +
-                    "'). Using default.");
+        }
+        catch (NumberFormatException nfe) {
+            log.warn("Invalid format for file size ('" + sizeString
+                    + "'). Using default.");
             size = defaultSize;
             multiplier = 1;
         }
@@ -343,43 +323,37 @@
         return (size * multiplier);
     }
 
-
     /**
      * Returns the path to the temporary directory to be used for uploaded
      * files which are written to disk. The directory used is determined from
-     * the first of the following to be non-empty.
-     * <ol>
-     * <li>A temp dir explicitly defined either using the <code>tempDir</code>
-     *     servlet init param, or the <code>tempDir</code> attribute of the
-     *     &lt;controller&gt; element in the Struts config file.</li>
-     * <li>The container-specified temp dir, obtained from the
-     *     <code>javax.servlet.context.tempdir</code> servlet context
-     *     attribute.</li>
-     * <li>The temp dir specified by the <code>java.io.tmpdir</code> system
-     *     property.</li>
-     * (/ol>
+     * the first of the following to be non-empty. <ol> <li>A temp dir
+     * explicitly defined either using the <code>tempDir</code> servlet init
+     * param, or the <code>tempDir</code> attribute of the &lt;controller&gt;
+     * element in the Struts config file.</li> <li>The container-specified
+     * temp dir, obtained from the <code>javax.servlet.context.tempdir</code>
+     * servlet context attribute.</li> <li>The temp dir specified by the
+     * <code>java.io.tmpdir</code> system property.</li> (/ol>
      *
      * @param mc The module config instance for which the path should be
      *           determined.
-     *
      * @return The path to the directory to be used to store uploaded files.
      */
     protected String getRepositoryPath(ModuleConfig mc) {
-
         // First, look for an explicitly defined temp dir.
         String tempDir = mc.getControllerConfig().getTempDir();
 
         // If none, look for a container specified temp dir.
-        if (tempDir == null || tempDir.length() == 0) {
+        if ((tempDir == null) || (tempDir.length() == 0)) {
             if (servlet != null) {
                 ServletContext context = servlet.getServletContext();
                 File tempDirFile = (File) context.getAttribute(
                         "javax.servlet.context.tempdir");
+
                 tempDir = tempDirFile.getAbsolutePath();
             }
 
             // If none, pick up the system temp dir.
-            if (tempDir == null || tempDir.length() == 0) {
+            if ((tempDir == null) || (tempDir.length() == 0)) {
                 tempDir = System.getProperty("java.io.tmpdir");
             }
         }
@@ -391,7 +365,6 @@
         return tempDir;
     }
 
-
     /**
      * Adds a regular text parameter to the set of text parameters for this
      * request and also to the list of all parameters. Handles the case of
@@ -401,7 +374,8 @@
      * @param request The request in which the parameter was specified.
      * @param item    The file item for the parameter to add.
      */
-    protected void addTextParameter(HttpServletRequest request, FileItem item) {
+    protected void addTextParameter(HttpServletRequest request,
+                                    FileItem item) {
         String name = item.getFieldName();
         String value = null;
         boolean haveValue = false;
@@ -411,21 +385,27 @@
             try {
                 value = item.getString(encoding);
                 haveValue = true;
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 // Handled below, since haveValue is false.
             }
         }
+
         if (!haveValue) {
             try {
-                 value = item.getString("ISO-8859-1");
-            } catch (java.io.UnsupportedEncodingException uee) {
-                 value = item.getString();
+                value = item.getString("ISO-8859-1");
             }
+            catch (java.io.UnsupportedEncodingException uee) {
+                value = item.getString();
+            }
+
             haveValue = true;
         }
 
         if (request instanceof MultipartRequestWrapper) {
-            MultipartRequestWrapper wrapper = (MultipartRequestWrapper) request;
+            MultipartRequestWrapper wrapper =
+                    (MultipartRequestWrapper) request;
+
             wrapper.setParameter(name, value);
         }
 
@@ -437,19 +417,18 @@
             System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
             newArray[oldArray.length] = value;
         } else {
-            newArray = new String[] { value };
+            newArray = new String[]{value};
         }
 
         elementsText.put(name, newArray);
         elementsAll.put(name, newArray);
     }
 
-
     /**
      * Adds a file parameter to the set of file parameters for this request
      * and also to the list of all parameters.
      *
-     * @param item    The file item for the parameter to add.
+     * @param item The file item for the parameter to add.
      */
     protected void addFileParameter(FileItem item) {
         FormFile formFile = new CommonsFormFile(item);
@@ -458,10 +437,8 @@
         elementsAll.put(item.getFieldName(), formFile);
     }
 
-
     // ---------------------------------------------------------- Inner Classes
 
-
     /**
      * This class implements the Struts <code>FormFile</code> interface by
      * wrapping the Commons FileUpload <code>FileItem</code> interface. This
@@ -469,16 +446,14 @@
      * of this class will result in an <code>UnsupportedOperationException</code>.
      */
     static class CommonsFormFile implements FormFile, Serializable {
-
         /**
          * The <code>FileItem</code> instance wrapped by this object.
          */
         FileItem fileItem;
 
-
         /**
-         * Constructs an instance of this class which wraps the supplied
-         * file item.
+         * Constructs an instance of this class which wraps the supplied file
+         * item.
          *
          * @param fileItem The Commons file item to be wrapped.
          */
@@ -486,7 +461,6 @@
             this.fileItem = fileItem;
         }
 
-
         /**
          * Returns the content type for this file.
          *
@@ -496,11 +470,9 @@
             return fileItem.getContentType();
         }
 
-
         /**
-         * Sets the content type for this file.
-         * <p>
-         * NOTE: This method is not supported in this implementation.
+         * Sets the content type for this file. <p> NOTE: This method is not
+         * supported in this implementation.
          *
          * @param contentType A string representing the content type.
          */
@@ -509,21 +481,18 @@
                     "The setContentType() method is not supported.");
         }
 
-
         /**
          * Returns the size, in bytes, of this file.
          *
          * @return The size of the file, in bytes.
          */
         public int getFileSize() {
-            return (int)fileItem.getSize();
+            return (int) fileItem.getSize();
         }
 
-
         /**
-         * Sets the size, in bytes, for this file.
-         * <p>
-         * NOTE: This method is not supported in this implementation.
+         * Sets the size, in bytes, for this file. <p> NOTE: This method is
+         * not supported in this implementation.
          *
          * @param filesize The size of the file, in bytes.
          */
@@ -532,7 +501,6 @@
                     "The setFileSize() method is not supported.");
         }
 
-
         /**
          * Returns the (client-side) file name for this file.
          *
@@ -542,11 +510,9 @@
             return getBaseFileName(fileItem.getName());
         }
 
-
         /**
-         * Sets the (client-side) file name for this file.
-         * <p>
-         * NOTE: This method is not supported in this implementation.
+         * Sets the (client-side) file name for this file. <p> NOTE: This
+         * method is not supported in this implementation.
          *
          * @param fileName The client-side name for the file.
          */
@@ -555,71 +521,70 @@
                     "The setFileName() method is not supported.");
         }
 
-
         /**
          * Returns the data for this file as a byte array. Note that this may
          * result in excessive memory usage for large uploads. The use of the
-         * {@link #getInputStream() getInputStream} method is encouraged
-         * as an alternative.
+         * {@link #getInputStream() getInputStream} method is encouraged as an
+         * alternative.
          *
          * @return An array of bytes representing the data contained in this
          *         form file.
-         *
-         * @exception FileNotFoundException If some sort of file representation
-         *                                  cannot be found for the FormFile
-         * @exception IOException If there is some sort of IOException
+         * @throws FileNotFoundException If some sort of file representation
+         *                               cannot be found for the FormFile
+         * @throws IOException           If there is some sort of IOException
          */
-        public byte[] getFileData() throws FileNotFoundException, IOException {
+        public byte[] getFileData()
+                throws FileNotFoundException, IOException {
             return fileItem.get();
         }
 
-
         /**
-         * Get an InputStream that represents this file.  This is the preferred
-         * method of getting file data.
-         * @exception FileNotFoundException If some sort of file representation
-         *                                  cannot be found for the FormFile
-         * @exception IOException If there is some sort of IOException
+         * Get an InputStream that represents this file.  This is the
+         * preferred method of getting file data.
+         *
+         * @throws FileNotFoundException If some sort of file representation
+         *                               cannot be found for the FormFile
+         * @throws IOException           If there is some sort of IOException
          */
-        public InputStream getInputStream() throws FileNotFoundException, IOException {
+        public InputStream getInputStream()
+                throws FileNotFoundException, IOException {
             return fileItem.getInputStream();
         }
 
-
         /**
-         * Destroy all content for this form file.
-         * Implementations should remove any temporary
-         * files or any temporary file data stored somewhere
+         * Destroy all content for this form file. Implementations should
+         * remove any temporary files or any temporary file data stored
+         * somewhere
          */
         public void destroy() {
             fileItem.delete();
         }
 
-
         /**
-         * Returns the base file name from the supplied file path. On the surface,
-         * this would appear to be a trivial task. Apparently, however, some Linux
-         * JDKs do not implement <code>File.getName()</code> correctly for Windows
-         * paths, so we attempt to take care of that here.
+         * Returns the base file name from the supplied file path. On the
+         * surface, this would appear to be a trivial task. Apparently,
+         * however, some Linux JDKs do not implement <code>File.getName()</code>
+         * correctly for Windows paths, so we attempt to take care of that
+         * here.
          *
          * @param filePath The full path to the file.
-         *
          * @return The base file name, from the end of the path.
          */
         protected String getBaseFileName(String filePath) {
-
             // First, ask the JDK for the base file name.
             String fileName = new File(filePath).getName();
 
             // Now check for a Windows file name parsed incorrectly.
             int colonIndex = fileName.indexOf(":");
+
             if (colonIndex == -1) {
                 // Check for a Windows SMB file path.
                 colonIndex = fileName.indexOf("\\\\");
             }
+
             int backslashIndex = fileName.lastIndexOf("\\");
 
-            if (colonIndex > -1 && backslashIndex > -1) {
+            if ((colonIndex > -1) && (backslashIndex > -1)) {
                 // Consider this filename to be a full Windows path, and parse it
                 // accordingly to retrieve just the base file name.
                 fileName = fileName.substring(backslashIndex + 1);

Modified: struts/action/trunk/src/java/org/apache/struts/upload/FormFile.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/upload/FormFile.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/upload/FormFile.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/upload/FormFile.java Fri Jan 20 16:19:02 2006
@@ -15,15 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.upload;
 
-
-import java.io.InputStream;
-import java.io.IOException;
 import java.io.FileNotFoundException;
-
+import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * This interface represents a file that has been uploaded by a client. It is
@@ -77,25 +73,24 @@
     /**
      * Returns the data for the entire file as byte array. Care is needed when
      * using this method, since a large upload could easily exhaust available
-     * memory. The preferred method for accessing the file data is
-     * {@link #getInputStream() getInputStream}.
+     * memory. The preferred method for accessing the file data is {@link
+     * #getInputStream() getInputStream}.
      *
      * @return The file data as a byte array.
-     *
-     * @exception FileNotFoundException if the uploaded file is not found.
-     * @exception IOException           if an error occurred while reading the
-     *                                  file.
+     * @throws FileNotFoundException if the uploaded file is not found.
+     * @throws IOException           if an error occurred while reading the
+     *                               file.
      */
     public byte[] getFileData()
             throws FileNotFoundException, IOException;
 
     /**
-     * Returns an input stream for this file. The caller must close the
-     * stream when it is no longer needed.
+     * Returns an input stream for this file. The caller must close the stream
+     * when it is no longer needed.
      *
-     * @exception FileNotFoundException if the uploaded file is not found.
-     * @exception IOException           if an error occurred while reading the
-     *                                  file.
+     * @throws FileNotFoundException if the uploaded file is not found.
+     * @throws IOException           if an error occurred while reading the
+     *                               file.
      */
     public InputStream getInputStream()
             throws FileNotFoundException, IOException;

Modified: struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestHandler.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestHandler.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestHandler.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestHandler.java Fri Jan 20 16:19:02 2006
@@ -15,39 +15,41 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.upload;
 
-import java.util.Hashtable;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
-import org.apache.struts.action.ActionServlet;
-import org.apache.struts.action.ActionMapping;
+import java.util.Hashtable;
 
 /**
-  * MultipartRequestHandler provides an standard interface for struts to
-  * deal with file uploads from forms with enctypes of "multipart/form-data".
-  * Providers must provide a no-argument constructor for initialization.
-  *
-  */
+ * MultipartRequestHandler provides an standard interface for struts to deal
+ * with file uploads from forms with enctypes of "multipart/form-data".
+ * Providers must provide a no-argument constructor for initialization.
+ */
 public interface MultipartRequestHandler {
     /**
-     * This is the ServletRequest attribute that should be set when a multipart request is being read
-     * and the maximum length is exceeded. The value is a Boolean. If the maximum length isn't exceeded,
-     * this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this
-     * attribute in the request if the maximum length is exceeded; in the handleRequest(HttpServletRequest) method.
+     * This is the ServletRequest attribute that should be set when a
+     * multipart request is being read and the maximum length is exceeded. The
+     * value is a Boolean. If the maximum length isn't exceeded, this
+     * attribute shouldn't be put in the ServletRequest. It's the job of the
+     * implementation to put this attribute in the request if the maximum
+     * length is exceeded; in the handleRequest(HttpServletRequest) method.
      */
-    public static final String ATTRIBUTE_MAX_LENGTH_EXCEEDED = "org.apache.struts.upload.MaxLengthExceeded";
+    public static final String ATTRIBUTE_MAX_LENGTH_EXCEEDED =
+            "org.apache.struts.upload.MaxLengthExceeded";
 
     /**
-     * Convienience method to set a reference to a working
-     * ActionServlet instance.
+     * Convienience method to set a reference to a working ActionServlet
+     * instance.
      */
     public void setServlet(ActionServlet servlet);
 
     /**
-     * Convienience method to set a reference to a working
-     * ActionMapping instance.
+     * Convienience method to set a reference to a working ActionMapping
+     * instance.
      */
     public void setMapping(ActionMapping mapping);
 
@@ -62,60 +64,57 @@
     public ActionMapping getMapping();
 
     /**
-      * After constructed, this is the first method called on
-      * by ActionServlet.  Use this method for all your
-      * data-parsing of the ServletInputStream in the request
-      *
-      * @exception ServletException thrown if something goes wrong
-      */
+     * After constructed, this is the first method called on by ActionServlet.
+     * Use this method for all your data-parsing of the ServletInputStream in
+     * the request
+     *
+     * @throws ServletException thrown if something goes wrong
+     */
     public void handleRequest(HttpServletRequest request)
-        throws ServletException;
+            throws ServletException;
 
     /**
-     * This method is called on to retrieve all the text
-     * input elements of the request.
+     * This method is called on to retrieve all the text input elements of the
+     * request.
      *
-     * @return A Hashtable where the keys and values are the names and
-     *  values of the request input parameters
+     * @return A Hashtable where the keys and values are the names and values
+     *         of the request input parameters
      */
     public Hashtable getTextElements();
 
     /**
-     * This method is called on to retrieve all the FormFile
-     * input elements of the request.
-     * @see org.apache.struts.upload.FormFile
-     * @return A Hashtable where the keys are the input names of the
-     *  files and the values are FormFile objects
+     * This method is called on to retrieve all the FormFile input elements of
+     * the request.
+     *
+     * @return A Hashtable where the keys are the input names of the files and
+     *         the values are FormFile objects
+     * @see FormFile
      */
     public Hashtable getFileElements();
 
     /**
      * This method returns all elements of a multipart request.
-     * @return A Hashtable where the keys are input names and values
-     *   are either Strings or FormFiles
+     *
+     * @return A Hashtable where the keys are input names and values are
+     *         either Strings or FormFiles
      */
     public Hashtable getAllElements();
 
     /**
-     * This method is called on when there's some sort of problem
-     * and the form post needs to be rolled back.  Providers
-     * should remove any FormFiles used to hold information
-     * by setting them to null and also physically delete
-     * them if the implementation calls for writing directly
-     * to disk.
-     * NOTE: Currently implemented but not automatically
-     * supported, ActionForm implementors must call rollback()
-     * manually for rolling back file uploads.
+     * This method is called on when there's some sort of problem and the form
+     * post needs to be rolled back.  Providers should remove any FormFiles
+     * used to hold information by setting them to null and also physically
+     * delete them if the implementation calls for writing directly to disk.
+     * NOTE: Currently implemented but not automatically supported, ActionForm
+     * implementors must call rollback() manually for rolling back file
+     * uploads.
      */
     public void rollback();
 
     /**
-     * This method is called on when a successful form post
-     * has been made.  Some implementations will use this
-     * to destroy temporary files or write to a database
-     * or something of that nature.
+     * This method is called on when a successful form post has been made.
+     * Some implementations will use this to destroy temporary files or write
+     * to a database or something of that nature.
      */
     public void finish();
-
 }
-

Modified: struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestWrapper.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestWrapper.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestWrapper.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/upload/MultipartRequestWrapper.java Fri Jan 20 16:19:02 2006
@@ -15,25 +15,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.upload;
 
-import java.util.Map;
-import java.util.Vector;
-import java.util.HashMap;
-import java.util.Iterator;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
 
 /**
- * This class functions as a wrapper around HttpServletRequest to
- * provide working getParameter methods for multipart requests.
+ * This class functions as a wrapper around HttpServletRequest to provide
+ * working getParameter methods for multipart requests.
  */
 public class MultipartRequestWrapper extends HttpServletRequestWrapper {
-
     /**
      * The parameters for this multipart request
      */
@@ -45,16 +43,19 @@
     }
 
     /**
-     * Sets a parameter for this request.  The parameter is actually
-     * separate from the request parameters, but calling on the
-     * getParameter() methods of this class will work as if they weren't.
+     * Sets a parameter for this request.  The parameter is actually separate
+     * from the request parameters, but calling on the getParameter() methods
+     * of this class will work as if they weren't.
      */
     public void setParameter(String name, String value) {
         String[] mValue = (String[]) parameters.get(name);
+
         if (mValue == null) {
             mValue = new String[0];
         }
+
         String[] newValue = new String[mValue.length + 1];
+
         System.arraycopy(mValue, 0, newValue, 0, mValue.length);
         newValue[mValue.length] = value;
 
@@ -69,57 +70,67 @@
      */
     public String getParameter(String name) {
         String value = getRequest().getParameter(name);
+
         if (value == null) {
             String[] mValue = (String[]) parameters.get(name);
+
             if ((mValue != null) && (mValue.length > 0)) {
                 value = mValue[0];
             }
         }
+
         return value;
     }
 
     /**
-     * Returns the names of the parameters for this request.
-     * The enumeration consists of the normal request parameter
-     * names plus the parameters read from the multipart request
+     * Returns the names of the parameters for this request. The enumeration
+     * consists of the normal request parameter names plus the parameters read
+     * from the multipart request
      */
     public Enumeration getParameterNames() {
         Enumeration baseParams = getRequest().getParameterNames();
         Vector list = new Vector();
+
         while (baseParams.hasMoreElements()) {
             list.add(baseParams.nextElement());
         }
+
         Collection multipartParams = parameters.keySet();
         Iterator iterator = multipartParams.iterator();
+
         while (iterator.hasNext()) {
             list.add(iterator.next());
         }
+
         return Collections.enumeration(list);
     }
 
     /**
-     * Returns the values of a parameter in this request.
-     * It first looks in the underlying HttpServletRequest object 
-     * for the parameter, and if that doesn't exist it looks for 
-     * the parameter retrieved from the multipart request.
+     * Returns the values of a parameter in this request. It first looks in
+     * the underlying HttpServletRequest object for the parameter, and if that
+     * doesn't exist it looks for the parameter retrieved from the multipart
+     * request.
      */
     public String[] getParameterValues(String name) {
         String[] value = getRequest().getParameterValues(name);
+
         if (value == null) {
             value = (String[]) parameters.get(name);
         }
+
         return value;
     }
 
     /**
      * Combines the parameters stored here with those in the underlying
-     * request. If paramater values in the underlying request take
-     * precedence over those stored here.
+     * request. If paramater values in the underlying request take precedence
+     * over those stored here.
      */
     public Map getParameterMap() {
         Map map = new HashMap(parameters);
+
         map.putAll(getRequest().getParameterMap());
+
         return map;
     }
-
 }

Modified: struts/action/trunk/src/java/org/apache/struts/upload/package.html
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/upload/package.html?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/upload/package.html (original)
+++ struts/action/trunk/src/java/org/apache/struts/upload/package.html Fri Jan 20 16:19:02 2006
@@ -2,31 +2,32 @@
 <html>
 <head>
 </head>
-  <body bgcolor="white">
- 
+
+<body bgcolor="white">
+
 <p> The upload package facilities to upload files using
- multi-part requests.</p>
- <br>
- <br>
- <img src="doc-files/uploadUML.jpg" alt="Upload Package UML" >
- <br>
- 
+    multi-part requests.</p>
+<br>
+<br>
+<img src="doc-files/uploadUML.jpg" alt="Upload Package UML">
+<br>
+
 <h2>Package Specification</h2>
-      ##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####     
+##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
 <ul>
-   <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-   </li>
- 
+    <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
+    </li>
+
 </ul>
- 
+
 <h2>Related Documentation</h2>
-      For overviews, tutorials, examples, guides, and tool documentation, 
-please  see:     
+For overviews, tutorials, examples, guides, and tool documentation,
+please see:
 <ul>
-   <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-   </li>
- 
+    <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
+    </li>
+
 </ul>
- <!-- Put @see and @since tags down here. --> 
+<!-- Put @see and @since tags down here. -->
 </body>
 </html>

Modified: struts/action/trunk/src/java/org/apache/struts/util/ImageButtonBean.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/ImageButtonBean.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/ImageButtonBean.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/ImageButtonBean.java Fri Jan 20 16:19:02 2006
@@ -15,14 +15,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.struts.util;
 
-
 import java.io.Serializable;
 
-
 /**
  * A simple JavaBean to encapsulate the request parameters sent for an HTML
  * input element of type image. Such an element causes two parameters to be
@@ -31,14 +27,24 @@
  * and provide a simple means of detecting whether or not the corresponding
  * image was selected.
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
  */
 public class ImageButtonBean implements Serializable {
+    // ------------------------------------------------------------- Properties
+
+    /**
+     * The X coordinate of the button press.
+     */
+    private String x;
 
+    /**
+     * The Y coordinate of the button press.
+     */
+    private String y;
 
     // ----------------------------------------------------------- Constructors
 
-
     /**
      * Construct an instance with empty property values.
      */
@@ -57,15 +63,6 @@
         this.y = y;
     }
 
-
-    // ------------------------------------------------------------- Properties
-
-
-    /**
-     * The X coordinate of the button press.
-     */
-    private String x;
-
     public String getX() {
         return (this.x);
     }
@@ -74,43 +71,35 @@
         this.x = x;
     }
 
-
-    /**
-     * The Y coordinate of the button press.
-     */
-    private String y;
-
     public String getY() {
-         return (this.y);
+        return (this.y);
     }
 
     public void setY(String y) {
         this.y = y;
     }
 
-
     // --------------------------------------------------------- Public Methods
 
-
     /**
-     * A convenience method to determine whether or not the corresponding image
-     * element was selected.
+     * A convenience method to determine whether or not the corresponding
+     * image element was selected.
      */
     public boolean isSelected() {
         return ((x != null) || (y != null));
     }
 
-
     /**
      * Return a string representation of this object.
      */
     public String toString() {
         StringBuffer sb = new StringBuffer("ImageButtonBean[");
+
         sb.append(this.x);
         sb.append(", ");
         sb.append(this.y);
         sb.append("]");
+
         return (sb.toString());
     }
-
 }

Modified: struts/action/trunk/src/java/org/apache/struts/util/IteratorAdapter.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/IteratorAdapter.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/IteratorAdapter.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/IteratorAdapter.java Fri Jan 20 16:19:02 2006
@@ -15,23 +15,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.util;
 
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-
 /**
- * Utility method for converting Enumeration to an Iterator
- * class.  If you attempt to remove() an Object from the iterator, it will
- * throw an UnsupportedOperationException. Added for use by TagLib so
- * Enumeration can be supported
+ * Utility method for converting Enumeration to an Iterator class.  If you
+ * attempt to remove() an Object from the iterator, it will throw an
+ * UnsupportedOperationException. Added for use by TagLib so Enumeration can
+ * be supported
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
  */
-
 public class IteratorAdapter implements Iterator {
     private Enumeration e;
 
@@ -41,15 +39,19 @@
 
     public boolean hasNext() {
         return e.hasMoreElements();
-   }
+    }
 
     public Object next() {
         if (!e.hasMoreElements()) {
-            throw new NoSuchElementException("IteratorAdaptor.next() has no more elements");
+            throw new NoSuchElementException(
+                    "IteratorAdaptor.next() has no more elements");
         }
+
         return e.nextElement();
     }
+
     public void remove() {
-        throw new UnsupportedOperationException("Method IteratorAdaptor.remove() not implemented");
+        throw new UnsupportedOperationException(
+                "Method IteratorAdaptor.remove() not implemented");
     }
 }

Modified: struts/action/trunk/src/java/org/apache/struts/util/LabelValueBean.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/LabelValueBean.java?rev=370938&r1=370937&r2=370938&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/LabelValueBean.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/LabelValueBean.java Fri Jan 20 16:19:02 2006
@@ -15,26 +15,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.struts.util;
 
 import java.io.Serializable;
 import java.util.Comparator;
 
 /**
- * A simple JavaBean to represent label-value pairs. This is most commonly used
- * when constructing user interface elements which have a label to be displayed
- * to the user, and a corresponding value to be returned to the server. One
- * example is the <code>&lt;html:options&gt;</code> tag.
+ * A simple JavaBean to represent label-value pairs. This is most commonly
+ * used when constructing user interface elements which have a label to be
+ * displayed to the user, and a corresponding value to be returned to the
+ * server. One example is the <code>&lt;html:options&gt;</code> tag.
  *
- * <p>
- * Note: this class has a natural ordering that is inconsistent with equals.
- * </p>
+ * <p> Note: this class has a natural ordering that is inconsistent with
+ * equals. </p>
  *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
+ *          $
  */
 public class LabelValueBean implements Comparable, Serializable {
-
     /**
      * Comparator that can be used for a case insensitive sort of
      * <code>LabelValueBean</code> objects.
@@ -43,13 +41,24 @@
         public int compare(Object o1, Object o2) {
             String label1 = ((LabelValueBean) o1).getLabel();
             String label2 = ((LabelValueBean) o2).getLabel();
+
             return label1.compareToIgnoreCase(label2);
         }
     };
 
+    // ------------------------------------------------------------- Properties
 
-    // ----------------------------------------------------------- Constructors
+    /**
+     * The property which supplies the option label visible to the end user.
+     */
+    private String label = null;
 
+    /**
+     * The property which supplies the value returned to the server.
+     */
+    private String value = null;
+
+    // ----------------------------------------------------------- Constructors
 
     /**
      * Default constructor.
@@ -69,15 +78,6 @@
         this.value = value;
     }
 
-
-    // ------------------------------------------------------------- Properties
-
-
-    /**
-     * The property which supplies the option label visible to the end user.
-     */
-    private String label = null;
-
     public String getLabel() {
         return this.label;
     }
@@ -86,12 +86,6 @@
         this.label = label;
     }
 
-
-    /**
-     * The property which supplies the value returned to the server.
-     */
-    private String value = null;
-
     public String getValue() {
         return this.value;
     }
@@ -100,12 +94,12 @@
         this.value = value;
     }
 
-
     // --------------------------------------------------------- Public Methods
 
     /**
      * Compare LabelValueBeans based on the label, because that's the human
      * viewable part of the object.
+     *
      * @see Comparable
      */
     public int compareTo(Object o) {
@@ -121,16 +115,19 @@
      */
     public String toString() {
         StringBuffer sb = new StringBuffer("LabelValueBean[");
+
         sb.append(this.label);
         sb.append(", ");
         sb.append(this.value);
         sb.append("]");
+
         return (sb.toString());
     }
 
     /**
      * LabelValueBeans are equal if their values are both null or equal.
-     * @see java.lang.Object#equals(java.lang.Object)
+     *
+     * @see Object#equals(Object)
      */
     public boolean equals(Object obj) {
         if (obj == this) {
@@ -143,7 +140,8 @@
 
         LabelValueBean bean = (LabelValueBean) obj;
         int nil = (this.getValue() == null) ? 1 : 0;
-        nil += (bean.getValue() == null) ? 1 : 0;
+
+        nil += ((bean.getValue() == null) ? 1 : 0);
 
         if (nil == 2) {
             return true;
@@ -152,12 +150,12 @@
         } else {
             return this.getValue().equals(bean.getValue());
         }
-
     }
 
     /**
      * The hash code is based on the object's value.
-     * @see java.lang.Object#hashCode()
+     *
+     * @see Object#hashCode()
      */
     public int hashCode() {
         return (this.getValue() == null) ? 17 : this.getValue().hashCode();



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