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 [4/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/mock/MockHttpServletRequest.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletRequest.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletRequest.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletRequest.java Thu Feb 9 06:11:07 2006
@@ -22,8 +22,11 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+
import java.io.BufferedReader;
+
import java.security.Principal;
+
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
@@ -50,52 +53,53 @@
// ----------------------------------------------------- Instance Variables
/**
- * The set of request attributes.
+ * <p> The set of request attributes. </p>
*/
protected HashMap attributes = new HashMap();
/**
- * The context path for this request.
+ * <p> The context path for this request. </p>
*/
protected String contextPath = null;
/**
- * The preferred locale for this request.
+ * <p> The preferred locale for this request. </p>
*/
protected Locale locale = null;
/**
- * The set of arrays of parameter values, keyed by parameter name.
+ * <p> The set of arrays of parameter values, keyed by parameter name.
+ * </p>
*/
protected HashMap parameters = new HashMap();
/**
- * The extra path information for this request.
+ * <p> The extra path information for this request. v * </p>
*/
protected String pathInfo = null;
/**
- * The authenticated user for this request.
+ * <p> The authenticated user for this request. </p>
*/
protected Principal principal = null;
/**
- * The query string for this request.
+ * <p> The query string for this request. </p>
*/
protected String queryString = null;
/**
- * The servlet path for this request.
+ * <p> The servlet path for this request. </p>
*/
protected String servletPath = null;
/**
- * The HttpSession with which we are associated.
+ * <p> The HttpSession with which we are associated. </p>
*/
protected HttpSession session = null;
/**
- * The HTTP request method.
+ * <p> The HTTP request method. </p>
*/
protected String method = null;
@@ -110,14 +114,13 @@
}
public MockHttpServletRequest(String contextPath, String servletPath,
- String pathInfo, String queryString) {
+ String pathInfo, String queryString) {
super();
setPathElements(contextPath, servletPath, pathInfo, queryString);
}
public MockHttpServletRequest(String contextPath, String servletPath,
- String pathInfo, String queryString,
- HttpSession session) {
+ String pathInfo, String queryString, HttpSession session) {
super();
setPathElements(contextPath, servletPath, pathInfo, queryString);
setHttpSession(session);
@@ -128,7 +131,7 @@
String[] values = (String[]) parameters.get(name);
if (values == null) {
- String[] results = new String[]{value};
+ String[] results = new String[] { value };
parameters.put(name, results);
@@ -155,7 +158,7 @@
}
public void setPathElements(String contextPath, String servletPath,
- String pathInfo, String queryString) {
+ String pathInfo, String queryString) {
this.contextPath = contextPath;
this.servletPath = servletPath;
this.pathInfo = pathInfo;
Modified: struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletResponse.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletResponse.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletResponse.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockHttpServletResponse.java Thu Feb 9 06:11:07 2006
@@ -20,8 +20,10 @@
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
+
import java.io.IOException;
import java.io.PrintWriter;
+
import java.util.Locale;
/**
@@ -131,12 +133,12 @@
}
public ServletOutputStream getOutputStream()
- throws IOException {
+ throws IOException {
throw new UnsupportedOperationException();
}
public PrintWriter getWriter()
- throws IOException {
+ throws IOException {
throw new UnsupportedOperationException();
}
Modified: struts/action/trunk/src/java/org/apache/struts/mock/MockHttpSession.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockHttpSession.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockHttpSession.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockHttpSession.java Thu Feb 9 06:11:07 2006
@@ -20,6 +20,7 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;
+
import java.util.Enumeration;
import java.util.HashMap;
@@ -43,12 +44,12 @@
// ----------------------------------------------------- Instance Variables
/**
- * The set of session attributes.
+ * <p> The set of session attributes. </p>
*/
protected HashMap attributes = new HashMap();
/**
- * The ServletContext with which we are associated.
+ * <p> The ServletContext with which we are associated. </p>
*/
protected ServletContext servletContext = null;
Modified: struts/action/trunk/src/java/org/apache/struts/mock/MockPageContext.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/mock/MockPageContext.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/mock/MockPageContext.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/mock/MockPageContext.java Thu Feb 9 06:11:07 2006
@@ -27,9 +27,11 @@
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
+
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
+
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -67,13 +69,15 @@
}
public MockPageContext(ServletConfig config, ServletRequest request,
- ServletResponse response) {
+ ServletResponse response) {
super();
setValues(config, request, response);
}
/**
+ * <p>
* Construct a new PageContext impl.
+ * </p>
*
* @param throwIOException Determines if the returned JspWriter should
* throw an IOException on any method call.
@@ -86,7 +90,7 @@
}
private void checkAndThrow()
- throws IOException {
+ throws IOException {
if (throwIOException) {
throw new IOException();
}
@@ -94,7 +98,7 @@
// --------------------------------------------------------- Public Methods
public void setValues(ServletConfig config, ServletRequest request,
- ServletResponse response) {
+ ServletResponse response) {
this.config = config;
if (config != null) {
@@ -195,14 +199,12 @@
public int getAttributesScope(String name) {
if (attributes.get(name) != null) {
return (PageContext.PAGE_SCOPE);
- } else
- if ((request != null) && (request.getAttribute(name) != null)) {
+ } else if ((request != null) && (request.getAttribute(name) != null)) {
return (PageContext.REQUEST_SCOPE);
- } else
- if ((session != null) && (session.getAttribute(name) != null)) {
+ } else if ((session != null) && (session.getAttribute(name) != null)) {
return (PageContext.SESSION_SCOPE);
} else if ((application != null)
- && (application.getAttribute(name) != null)) {
+ && (application.getAttribute(name) != null)) {
return (PageContext.APPLICATION_SCOPE);
} else {
return (0);
@@ -214,280 +216,283 @@
}
/**
+ * <p>
* Custom JspWriter that throws the specified exception (supplied on the
* constructor...if any), else it simply returns.
+ * </p>
*/
public JspWriter getOut() {
- JspWriter jspWriter = new JspWriter(0, false) {
- public void print(String s)
+ JspWriter jspWriter =
+ new JspWriter(0, false) {
+ public void print(String s)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void newLine()
+ public void newLine()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(boolean b)
+ public void print(boolean b)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(char c)
+ public void print(char c)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(int i)
+ public void print(int i)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(long l)
+ public void print(long l)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(float f)
+ public void print(float f)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(double d)
+ public void print(double d)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(char[] s)
+ public void print(char[] s)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(Object obj)
+ public void print(Object obj)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println()
+ public void println()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(boolean x)
+ public void println(boolean x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(char x)
+ public void println(char x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(int x)
+ public void println(int x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(long x)
+ public void println(long x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(float x)
+ public void println(float x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(double x)
+ public void println(double x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(char[] x)
+ public void println(char[] x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(String x)
+ public void println(String x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(Object x)
+ public void println(Object x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void clear()
+ public void clear()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void clearBuffer()
+ public void clearBuffer()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void flush()
+ public void flush()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void close()
+ public void close()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public int getRemaining() {
- return 0;
- }
+ public int getRemaining() {
+ return 0;
+ }
- public void write(char[] cbuf, int off, int len)
+ public void write(char[] cbuf, int off, int len)
throws IOException {
- checkAndThrow();
- }
- };
+ checkAndThrow();
+ }
+ };
if (returnBodyContent) {
return new BodyContent(jspWriter) {
- public Reader getReader() {
- return null;
- }
+ public Reader getReader() {
+ return null;
+ }
- public String getString() {
- return null;
- }
+ public String getString() {
+ return null;
+ }
- public void writeOut(Writer out)
+ public void writeOut(Writer out)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void newLine()
+ public void newLine()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(boolean b)
+ public void print(boolean b)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(char c)
+ public void print(char c)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(int i)
+ public void print(int i)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(long l)
+ public void print(long l)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(float f)
+ public void print(float f)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(double d)
+ public void print(double d)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(char[] s)
+ public void print(char[] s)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(String s)
+ public void print(String s)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void print(Object obj)
+ public void print(Object obj)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println()
+ public void println()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(boolean x)
+ public void println(boolean x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(char x)
+ public void println(char x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(int x)
+ public void println(int x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(long x)
+ public void println(long x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(float x)
+ public void println(float x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(double x)
+ public void println(double x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(char[] x)
+ public void println(char[] x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(String x)
+ public void println(String x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void println(Object x)
+ public void println(Object x)
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void clear()
+ public void clear()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void clearBuffer()
+ public void clearBuffer()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public void close()
+ public void close()
throws IOException {
- checkAndThrow();
- }
+ checkAndThrow();
+ }
- public int getRemaining() {
- return 0;
- }
+ public int getRemaining() {
+ return 0;
+ }
- public void write(char[] cbuf, int off, int len)
+ public void write(char[] cbuf, int off, int len)
throws IOException {
- checkAndThrow();
- }
- };
+ checkAndThrow();
+ }
+ };
}
return jspWriter;
@@ -530,9 +535,8 @@
}
public void initialize(Servlet servlet, ServletRequest request,
- ServletResponse response, String errorPageURL,
- boolean needsSession,
- int bufferSize, boolean autoFlush) {
+ ServletResponse response, String errorPageURL, boolean needsSession,
+ int bufferSize, boolean autoFlush) {
throw new UnsupportedOperationException();
}
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -19,6 +19,7 @@
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
+
import java.util.Enumeration;
import java.util.HashMap;
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -23,8 +23,11 @@
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;
@@ -49,17 +52,17 @@
// ----------------------------------------------------- Instance Variables
/**
- * The set of servlet context attributes.
+ * <p> The set of servlet context attributes. </p>
*/
protected HashMap attributes = new HashMap();
/**
- * Default destination for <code>LOG()</code> output.
+ * <p> Default destination for <code>LOG()</code> output. </p>
*/
protected Log log = LogFactory.getLog(MockServletContext.class);
/**
- * The set of context initialization parameters.
+ * <p> The set of context initialization parameters. </p>
*/
protected HashMap parameters = new HashMap();
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -20,6 +20,7 @@
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;
@@ -60,8 +61,7 @@
}
public static void main(String[] args) {
- junit.awtui.TestRunner
- .main(new String[]{TestMockBase.class.getName()});
+ junit.awtui.TestRunner.main(new String[] { TestMockBase.class.getName() });
}
public static Test suite() {
@@ -75,8 +75,8 @@
config = new MockServletConfig(context);
session = new MockHttpSession(context);
request = new MockHttpServletRequest(session);
- principal = new MockPrincipal("username",
- new String[]{"admin", "manager"});
+ principal =
+ new MockPrincipal("username", new String[] { "admin", "manager" });
request.setUserPrincipal(principal);
response = new MockHttpServletResponse();
page = new MockPageContext(config, request, response);
@@ -97,8 +97,7 @@
ActionFormBean formBean = null;
ActionMapping mapping = null;
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
moduleConfig = factoryObject.createModuleConfig("");
@@ -109,9 +108,7 @@
"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",
@@ -122,8 +119,8 @@
"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
@@ -136,7 +133,8 @@
moduleConfig.addActionConfig(mapping);
// Form Bean "dynamic" is a DynaActionForm with the same properties
- formBean = new ActionFormBean("dynamic",
+ formBean =
+ new ActionFormBean("dynamic",
"org.apache.struts.action.DynaActionForm");
formBean.addFormPropertyConfig(new FormPropertyConfig(
"booleanProperty", "boolean", "false"));
@@ -154,7 +152,8 @@
moduleConfig.addActionConfig(mapping);
// Form Bean "/dynamic0" is a DynaActionForm with initializers
- formBean = new ActionFormBean("dynamic0",
+ formBean =
+ new ActionFormBean("dynamic0",
"org.apache.struts.action.DynaActionForm");
formBean.addFormPropertyConfig(new FormPropertyConfig(
"booleanProperty", "boolean", "true"));
@@ -167,9 +166,7 @@
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
+ "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);
@@ -215,8 +212,7 @@
ActionFormBean formBean = null;
ActionMapping mapping = null;
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
moduleConfig2 = factoryObject.createModuleConfig("/2");
@@ -239,8 +235,8 @@
"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)
@@ -253,7 +249,8 @@
moduleConfig2.addActionConfig(mapping);
// Form Bean "dynamic2" is a DynaActionForm with the same properties
- formBean = new ActionFormBean("dynamic2",
+ formBean =
+ new ActionFormBean("dynamic2",
"org.apache.struts.action.DynaActionForm");
formBean.addFormPropertyConfig(new FormPropertyConfig(
"booleanProperty", "boolean", "false"));
@@ -301,8 +298,7 @@
// Set up third app for testing URL mapping
protected void setUpThirdApp() {
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
moduleConfig3 = factoryObject.createModuleConfig("/3");
@@ -372,20 +368,18 @@
assertEquals("page-->response", response, page.getResponse());
assertEquals("page-->session", session, page.getSession());
assertEquals("request-->principal", principal,
- request.getUserPrincipal());
+ request.getUserPrincipal());
assertEquals("request-->session", session, request.getSession());
- assertEquals("session-->context",
- context,
- session.getServletContext());
+ assertEquals("session-->context", context, session.getServletContext());
// Validate the configuration for the default module
assertNotNull("moduleConfig is present", moduleConfig);
assertEquals("context-->moduleConfig", moduleConfig,
- context.getAttribute(Globals.MODULE_KEY));
+ 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"));
+ 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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -30,77 +30,79 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
+
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
/**
- * This class implements the <code>MultipartRequestHandler</code> interface by
- * providing a wrapper around the Jakarta Commons FileUpload library.
+ * <p> This class implements the <code>MultipartRequestHandler</code>
+ * interface by providing a wrapper around the Jakarta Commons FileUpload
+ * library. </p>
*
* @version $Rev$ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
* $
* @since Struts 1.1
*/
-public class CommonsMultipartRequestHandler
- implements MultipartRequestHandler {
+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.
+ * <p> The default value for the maximum allowable size, in bytes, of an
+ * uploaded file. The value is equivalent to 250MB. </p>
*/
public static final long DEFAULT_SIZE_MAX = 250 * 1024 * 1024;
/**
- * The default value for the threshold which determines whether an
+ * <p> 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.
+ * equivalent to 250KB. </p>
*/
public static final int DEFAULT_SIZE_THRESHOLD = 256 * 1024;
// ----------------------------------------------------- Instance Variables
/**
- * Commons Logging instance.
+ * <p> Commons Logging instance. </p>
*/
protected static Log log =
- LogFactory.getLog(CommonsMultipartRequestHandler.class);
+ LogFactory.getLog(CommonsMultipartRequestHandler.class);
/**
- * The combined text and file request parameters.
+ * <p> The combined text and file request parameters. </p>
*/
private Hashtable elementsAll;
/**
- * The file request parameters.
+ * <p> The file request parameters. </p>
*/
private Hashtable elementsFile;
/**
- * The text request parameters.
+ * <p> The text request parameters. </p>
*/
private Hashtable elementsText;
/**
- * The action mapping with which this handler is associated.
+ * <p> The action mapping with which this handler is associated. </p>
*/
private ActionMapping mapping;
/**
- * The servlet with which this handler is associated.
+ * <p> The servlet with which this handler is associated. </p>
*/
private ActionServlet servlet;
// ---------------------------------------- MultipartRequestHandler Methods
/**
- * Retrieves the servlet with which this handler is associated.
+ * <p> Retrieves the servlet with which this handler is associated. </p>
*
* @return The associated servlet.
*/
@@ -109,7 +111,7 @@
}
/**
- * Sets the servlet with which this handler is associated.
+ * <p> Sets the servlet with which this handler is associated. </p>
*
* @param servlet The associated servlet.
*/
@@ -118,7 +120,8 @@
}
/**
- * Retrieves the action mapping with which this handler is associated.
+ * <p> Retrieves the action mapping with which this handler is associated.
+ * </p>
*
* @return The associated action mapping.
*/
@@ -127,7 +130,8 @@
}
/**
- * Sets the action mapping with which this handler is associated.
+ * <p> Sets the action mapping with which this handler is associated.
+ * </p>
*
* @param mapping The associated action mapping.
*/
@@ -136,19 +140,19 @@
}
/**
- * 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
- * are translated from Commons FileUpload <code>FileItem</code> instances
- * to Struts <code>FormFile</code> instances.
+ * <p> 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 are translated from Commons FileUpload <code>FileItem</code>
+ * instances to Struts <code>FormFile</code> instances. </p>
*
* @param request The multipart request to be processed.
* @throws ServletException if an unrecoverable error occurs.
*/
public void handleRequest(HttpServletRequest request)
- throws ServletException {
+ throws ServletException {
// Get the app config for the current request.
ModuleConfig ac =
- (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
+ (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
// Create and configure a DIskFileUpload instance.
DiskFileUpload upload = new DiskFileUpload();
@@ -176,15 +180,13 @@
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,
- Boolean.TRUE);
+ Boolean.TRUE);
return;
- }
- catch (FileUploadException e) {
+ } catch (FileUploadException e) {
log.error("Failed to parse multipart request", e);
throw new ServletException(e);
}
@@ -204,8 +206,8 @@
}
/**
- * Returns a hash table containing the text (that is, non-file) request
- * parameters.
+ * <p> Returns a hash table containing the text (that is, non-file)
+ * request parameters. </p>
*
* @return The text request parameters.
*/
@@ -214,8 +216,8 @@
}
/**
- * Returns a hash table containing the file (that is, non-text) request
- * parameters.
+ * <p> Returns a hash table containing the file (that is, non-text)
+ * request parameters. </p>
*
* @return The file request parameters.
*/
@@ -224,7 +226,8 @@
}
/**
- * Returns a hash table containing both text and file request parameters.
+ * <p> Returns a hash table containing both text and file request
+ * parameters. </p>
*
* @return The text and file request parameters.
*/
@@ -233,7 +236,7 @@
}
/**
- * Cleans up when a problem occurs during request processing.
+ * <p> Cleans up when a problem occurs during request processing. </p>
*/
public void rollback() {
Iterator iter = elementsFile.values().iterator();
@@ -246,7 +249,7 @@
}
/**
- * Cleans up at the end of a request.
+ * <p> Cleans up at the end of a request. </p>
*/
public void finish() {
rollback();
@@ -255,38 +258,38 @@
// -------------------------------------------------------- Support Methods
/**
- * Returns the maximum allowable size, in bytes, of an uploaded file. The
- * value is obtained from the current module's controller configuration.
+ * <p> Returns the maximum allowable size, in bytes, of an uploaded file.
+ * The value is obtained from the current module's controller
+ * configuration. </p>
*
* @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(),
- DEFAULT_SIZE_MAX);
+ DEFAULT_SIZE_MAX);
}
/**
- * Returns the size threshold which determines whether an uploaded file
- * will be written to disk or cached in memory.
+ * <p> Returns the size threshold which determines whether an uploaded
+ * file will be written to disk or cached in memory. </p>
*
* @param mc The current module's configuration.
* @return The size threshold, in bytes.
*/
protected long getSizeThreshold(ModuleConfig mc) {
return convertSizeToBytes(mc.getControllerConfig().getMemFileSize(),
- DEFAULT_SIZE_THRESHOLD);
+ DEFAULT_SIZE_THRESHOLD);
}
/**
- * Converts a size value from a string representation to its numeric
+ * <p> 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.
+ * respectively. </p><p> If the size value cannot be converted, for
+ * example due to invalid syntax, the supplied default is returned
+ * instead. </p>
*
* @param sizeString The string representation of the size to be
* converted.
@@ -312,10 +315,9 @@
try {
size = Long.parseLong(sizeString);
- }
- catch (NumberFormatException nfe) {
+ } catch (NumberFormatException nfe) {
log.warn("Invalid format for file size ('" + sizeString
- + "'). Using default.");
+ + "'). Using default.");
size = defaultSize;
multiplier = 1;
}
@@ -324,7 +326,7 @@
}
/**
- * Returns the path to the temporary directory to be used for uploaded
+ * <p> 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
@@ -332,7 +334,7 @@
* 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>
+ * <code>java.io.tmpdir</code> system property.</li> (/ol> </p>
*
* @param mc The module config instance for which the path should be
* determined.
@@ -346,8 +348,8 @@
if ((tempDir == null) || (tempDir.length() == 0)) {
if (servlet != null) {
ServletContext context = servlet.getServletContext();
- File tempDirFile = (File) context.getAttribute(
- "javax.servlet.context.tempdir");
+ File tempDirFile =
+ (File) context.getAttribute("javax.servlet.context.tempdir");
tempDir = tempDirFile.getAbsolutePath();
}
@@ -366,16 +368,15 @@
}
/**
- * 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
- * multiple values for the same parameter by using an array for the
- * parameter value.
+ * <p> 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 multiple values for the same parameter by using an array for the
+ * parameter value. </p>
*
* @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;
@@ -385,8 +386,7 @@
try {
value = item.getString(encoding);
haveValue = true;
- }
- catch (Exception e) {
+ } catch (Exception e) {
// Handled below, since haveValue is false.
}
}
@@ -394,8 +394,7 @@
if (!haveValue) {
try {
value = item.getString("ISO-8859-1");
- }
- catch (java.io.UnsupportedEncodingException uee) {
+ } catch (java.io.UnsupportedEncodingException uee) {
value = item.getString();
}
@@ -403,8 +402,7 @@
}
if (request instanceof MultipartRequestWrapper) {
- MultipartRequestWrapper wrapper =
- (MultipartRequestWrapper) request;
+ MultipartRequestWrapper wrapper = (MultipartRequestWrapper) request;
wrapper.setParameter(name, value);
}
@@ -417,7 +415,7 @@
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);
@@ -425,8 +423,8 @@
}
/**
- * Adds a file parameter to the set of file parameters for this request
- * and also to the list of all parameters.
+ * <p> Adds a file parameter to the set of file parameters for this
+ * request and also to the list of all parameters. </p>
*
* @param item The file item for the parameter to add.
*/
@@ -440,20 +438,22 @@
// ---------------------------------------------------------- Inner Classes
/**
- * This class implements the Struts <code>FormFile</code> interface by
+ * <p> This class implements the Struts <code>FormFile</code> interface by
* wrapping the Commons FileUpload <code>FileItem</code> interface. This
* implementation is <i>read-only</i>; any attempt to modify an instance
* of this class will result in an <code>UnsupportedOperationException</code>.
+ * </p>
*/
static class CommonsFormFile implements FormFile, Serializable {
/**
- * The <code>FileItem</code> instance wrapped by this object.
+ * <p> The <code>FileItem</code> instance wrapped by this object.
+ * </p>
*/
FileItem fileItem;
/**
* Constructs an instance of this class which wraps the supplied file
- * item.
+ * item. </p>
*
* @param fileItem The Commons file item to be wrapped.
*/
@@ -462,7 +462,7 @@
}
/**
- * Returns the content type for this file.
+ * <p> Returns the content type for this file. </p>
*
* @return A String representing content type.
*/
@@ -471,18 +471,18 @@
}
/**
- * Sets the content type for this file. <p> NOTE: This method is not
- * supported in this implementation.
+ * <p> Sets the content type for this file. <p> NOTE: This method is
+ * not supported in this implementation. </p>
*
* @param contentType A string representing the content type.
*/
public void setContentType(String contentType) {
throw new UnsupportedOperationException(
- "The setContentType() method is not supported.");
+ "The setContentType() method is not supported.");
}
/**
- * Returns the size, in bytes, of this file.
+ * <p> Returns the size, in bytes, of this file. </p>
*
* @return The size of the file, in bytes.
*/
@@ -491,18 +491,18 @@
}
/**
- * Sets the size, in bytes, for this file. <p> NOTE: This method is
- * not supported in this implementation.
+ * <p> Sets the size, in bytes, for this file. <p> NOTE: This method
+ * is not supported in this implementation. </p>
*
* @param filesize The size of the file, in bytes.
*/
public void setFileSize(int filesize) {
throw new UnsupportedOperationException(
- "The setFileSize() method is not supported.");
+ "The setFileSize() method is not supported.");
}
/**
- * Returns the (client-side) file name for this file.
+ * <p> Returns the (client-side) file name for this file. </p>
*
* @return The client-size file name.
*/
@@ -511,21 +511,21 @@
}
/**
- * Sets the (client-side) file name for this file. <p> NOTE: This
- * method is not supported in this implementation.
+ * <p> Sets the (client-side) file name for this file. <p> NOTE: This
+ * method is not supported in this implementation. </p>
*
* @param fileName The client-side name for the file.
*/
public void setFileName(String fileName) {
throw new UnsupportedOperationException(
- "The setFileName() method is not supported.");
+ "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.
+ * <p> 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. </p>
*
* @return An array of bytes representing the data contained in this
* form file.
@@ -534,38 +534,38 @@
* @throws IOException If there is some sort of IOException
*/
public byte[] getFileData()
- throws FileNotFoundException, IOException {
+ throws FileNotFoundException, IOException {
return fileItem.get();
}
/**
- * Get an InputStream that represents this file. This is the
- * preferred method of getting file data.
+ * <p> Get an InputStream that represents this file. This is the
+ * preferred method of getting file data. </p>
*
* @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 {
+ throws FileNotFoundException, IOException {
return fileItem.getInputStream();
}
/**
- * Destroy all content for this form file. Implementations should
+ * <p> Destroy all content for this form file. Implementations should
* remove any temporary files or any temporary file data stored
- * somewhere
+ * somewhere </p>
*/
public void destroy() {
fileItem.delete();
}
/**
- * Returns the base file name from the supplied file path. On the
+ * <p> 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.
+ * here. </p>
*
* @param filePath The full path to the file.
* @return The base file name, from the end of the path.
@@ -594,7 +594,7 @@
}
/**
- * Returns the (client-side) file name for this file.
+ * <p> Returns the (client-side) file name for this file. </p>
*
* @return The client-size file name.
*/
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -22,59 +22,59 @@
import java.io.InputStream;
/**
- * This interface represents a file that has been uploaded by a client. It is
- * the only interface or class in upload package which is typically referenced
- * directly by a Struts application.
+ * <p> This interface represents a file that has been uploaded by a client. It
+ * is the only interface or class in upload package which is typically
+ * referenced directly by a Struts application. </p>
*/
public interface FormFile {
/**
- * Returns the content type for this file.
+ * <p> Returns the content type for this file. </p>
*
* @return A String representing content type.
*/
public String getContentType();
/**
- * Sets the content type for this file.
+ * <p> Sets the content type for this file. </p>
*
* @param contentType The content type for the file.
*/
public void setContentType(String contentType);
/**
- * Returns the size of this file.
+ * <p> Returns the size of this file. </p>
*
* @return The size of the file, in bytes.
*/
public int getFileSize();
/**
- * Sets the file size.
+ * <p> Sets the file size. </p>
*
* @param fileSize The size of the file, in bytes,
*/
public void setFileSize(int fileSize);
/**
- * Returns the file name of this file. This is the base name of the file,
- * as supplied by the user when the file was uploaded.
+ * <p> Returns the file name of this file. This is the base name of the
+ * file, as supplied by the user when the file was uploaded. </p>
*
* @return The base file name.
*/
public String getFileName();
/**
- * Sets the file name of this file.
+ * <p> Sets the file name of this file. </p>
*
* @param fileName The base file name.
*/
public void setFileName(String fileName);
/**
- * 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}.
+ * <p> 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}. </p>
*
* @return The file data as a byte array.
* @throws FileNotFoundException if the uploaded file is not found.
@@ -82,22 +82,22 @@
* file.
*/
public byte[] getFileData()
- throws FileNotFoundException, IOException;
+ throws FileNotFoundException, IOException;
/**
- * Returns an input stream for this file. The caller must close the stream
- * when it is no longer needed.
+ * <p> Returns an input stream for this file. The caller must close the
+ * stream when it is no longer needed. </p>
*
* @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;
+ throws FileNotFoundException, IOException;
/**
- * Destroys all content for the uploaded file, including any underlying
- * data files.
+ * <p> Destroys all content for the uploaded file, including any
+ * underlying data files. </p>
*/
public void destroy();
}
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -22,60 +22,62 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
+
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.
+ * <p> 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. </p>
*/
public interface MultipartRequestHandler {
/**
- * This is the ServletRequest attribute that should be set when a
+ * <p> 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.
+ * </p>
*/
public static final String ATTRIBUTE_MAX_LENGTH_EXCEEDED =
- "org.apache.struts.upload.MaxLengthExceeded";
+ "org.apache.struts.upload.MaxLengthExceeded";
/**
- * Convienience method to set a reference to a working ActionServlet
- * instance.
+ * <p> Convienience method to set a reference to a working ActionServlet
+ * instance. </p>
*/
public void setServlet(ActionServlet servlet);
/**
- * Convienience method to set a reference to a working ActionMapping
- * instance.
+ * <p> Convienience method to set a reference to a working ActionMapping
+ * instance. </p>
*/
public void setMapping(ActionMapping mapping);
/**
- * Get the ActionServlet instance
+ * <p> Get the ActionServlet instance </p>
*/
public ActionServlet getServlet();
/**
- * Get the ActionMapping instance for this request
+ * <p> Get the ActionMapping instance for this request </p>
*/
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
+ * <p> 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 </p>
*
* @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.
+ * <p> This method is called on to retrieve all the text input elements of
+ * the request. </p>
*
* @return A Hashtable where the keys and values are the names and values
* of the request input parameters
@@ -83,8 +85,8 @@
public Hashtable getTextElements();
/**
- * This method is called on to retrieve all the FormFile input elements of
- * the request.
+ * <p> This method is called on to retrieve all the FormFile input
+ * elements of the request. </p>
*
* @return A Hashtable where the keys are the input names of the files and
* the values are FormFile objects
@@ -93,7 +95,7 @@
public Hashtable getFileElements();
/**
- * This method returns all elements of a multipart request.
+ * <p> This method returns all elements of a multipart request. </p>
*
* @return A Hashtable where the keys are input names and values are
* either Strings or FormFiles
@@ -101,20 +103,20 @@
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.
+ * <p> 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. </p>
*/
public void rollback();
/**
- * This method is called on when a successful form post has been made.
+ * <p> 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.
+ * to a database or something of that nature. </p>
*/
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -19,6 +19,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
@@ -28,12 +29,12 @@
import java.util.Vector;
/**
- * This class functions as a wrapper around HttpServletRequest to provide
- * working getParameter methods for multipart requests.
+ * <p> This class functions as a wrapper around HttpServletRequest to provide
+ * working getParameter methods for multipart requests. </p>
*/
public class MultipartRequestWrapper extends HttpServletRequestWrapper {
/**
- * The parameters for this multipart request
+ * <p> The parameters for this multipart request </p>
*/
protected Map parameters;
@@ -43,9 +44,9 @@
}
/**
- * 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.
+ * <p> 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. </p>
*/
public void setParameter(String name, String value) {
String[] mValue = (String[]) parameters.get(name);
@@ -63,10 +64,10 @@
}
/**
- * Attempts to get a parameter for this request. It first looks in the
- * underlying HttpServletRequest object for the parameter, and if that
+ * <p> Attempts to get a parameter for this request. It first looks in
+ * the underlying HttpServletRequest object for the parameter, and if that
* doesn't exist it looks for the parameters retrieved from the multipart
- * request
+ * request </p>
*/
public String getParameter(String name) {
String value = getRequest().getParameter(name);
@@ -83,9 +84,9 @@
}
/**
- * 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
+ * <p> 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 </p>
*/
public Enumeration getParameterNames() {
Enumeration baseParams = getRequest().getParameterNames();
@@ -106,10 +107,10 @@
}
/**
- * 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.
+ * <p> 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. </p>
*/
public String[] getParameterValues(String name) {
String[] value = getRequest().getParameterValues(name);
@@ -122,9 +123,9 @@
}
/**
- * Combines the parameters stored here with those in the underlying
+ * <p> Combines the parameters stored here with those in the underlying
* request. If paramater values in the underlying request take precedence
- * over those stored here.
+ * over those stored here. </p>
*/
public Map getParameterMap() {
Map map = new HashMap(parameters);
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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -44,7 +44,7 @@
public Object next() {
if (!e.hasMoreElements()) {
throw new NoSuchElementException(
- "IteratorAdaptor.next() has no more elements");
+ "IteratorAdaptor.next() has no more elements");
}
return e.nextElement();
@@ -52,6 +52,6 @@
public void remove() {
throw new UnsupportedOperationException(
- "Method IteratorAdaptor.remove() not implemented");
+ "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=376300&r1=376299&r2=376300&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 Thu Feb 9 06:11:07 2006
@@ -18,6 +18,7 @@
package org.apache.struts.util;
import java.io.Serializable;
+
import java.util.Comparator;
/**
@@ -37,14 +38,15 @@
* Comparator that can be used for a case insensitive sort of
* <code>LabelValueBean</code> objects.
*/
- public static final Comparator CASE_INSENSITIVE_ORDER = new Comparator() {
- public int compare(Object o1, Object o2) {
- String label1 = ((LabelValueBean) o1).getLabel();
- String label2 = ((LabelValueBean) o2).getLabel();
+ public static final Comparator CASE_INSENSITIVE_ORDER =
+ new Comparator() {
+ public int compare(Object o1, Object o2) {
+ String label1 = ((LabelValueBean) o1).getLabel();
+ String label2 = ((LabelValueBean) o2).getLabel();
- return label1.compareToIgnoreCase(label2);
- }
- };
+ return label1.compareToIgnoreCase(label2);
+ }
+ };
// ------------------------------------------------------------- Properties
Modified: struts/action/trunk/src/java/org/apache/struts/util/MessageResources.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/MessageResources.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/MessageResources.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/MessageResources.java Thu Feb 9 06:11:07 2006
@@ -21,7 +21,9 @@
import org.apache.commons.logging.LogFactory;
import java.io.Serializable;
+
import java.text.MessageFormat;
+
import java.util.HashMap;
import java.util.Locale;
@@ -115,7 +117,7 @@
* @param returnNull The returnNull property we should initialize with
*/
public MessageResources(MessageResourcesFactory factory, String config,
- boolean returnNull) {
+ boolean returnNull) {
super();
this.factory = factory;
this.config = config;
@@ -235,8 +237,7 @@
* @param arg1 The replacement for placeholder {1} in the message
* @param arg2 The replacement for placeholder {2} in the message
*/
- public String getMessage(String key, Object arg0, Object arg1,
- Object arg2) {
+ public String getMessage(String key, Object arg0, Object arg1, Object arg2) {
return this.getMessage((Locale) null, key, arg0, arg1, arg2);
}
@@ -250,9 +251,8 @@
* @param arg2 The replacement for placeholder {2} in the message
* @param arg3 The replacement for placeholder {3} in the message
*/
- public String getMessage(String key, Object arg0, Object arg1,
- Object arg2,
- Object arg3) {
+ public String getMessage(String key, Object arg0, Object arg1, Object arg2,
+ Object arg3) {
return this.getMessage((Locale) null, key, arg0, arg1, arg2, arg3);
}
@@ -319,7 +319,7 @@
* @param arg0 The replacement for placeholder {0} in the message
*/
public String getMessage(Locale locale, String key, Object arg0) {
- return this.getMessage(locale, key, new Object[]{arg0});
+ return this.getMessage(locale, key, new Object[] { arg0 });
}
/**
@@ -333,9 +333,8 @@
* @param arg0 The replacement for placeholder {0} in the message
* @param arg1 The replacement for placeholder {1} in the message
*/
- public String getMessage(Locale locale, String key, Object arg0,
- Object arg1) {
- return this.getMessage(locale, key, new Object[]{arg0, arg1});
+ public String getMessage(Locale locale, String key, Object arg0, Object arg1) {
+ return this.getMessage(locale, key, new Object[] { arg0, arg1 });
}
/**
@@ -351,8 +350,8 @@
* @param arg2 The replacement for placeholder {2} in the message
*/
public String getMessage(Locale locale, String key, Object arg0,
- Object arg1, Object arg2) {
- return this.getMessage(locale, key, new Object[]{arg0, arg1, arg2});
+ Object arg1, Object arg2) {
+ return this.getMessage(locale, key, new Object[] { arg0, arg1, arg2 });
}
/**
@@ -369,9 +368,9 @@
* @param arg3 The replacement for placeholder {3} in the message
*/
public String getMessage(Locale locale, String key, Object arg0,
- Object arg1, Object arg2, Object arg3) {
+ Object arg1, Object arg2, Object arg3) {
return this.getMessage(locale, key,
- new Object[]{arg0, arg1, arg2, arg3});
+ new Object[] { arg0, arg1, arg2, arg3 });
}
/**
@@ -478,7 +477,7 @@
* @param config Configuration parameter for this message bundle.
*/
public synchronized static MessageResources getMessageResources(
- String config) {
+ String config) {
if (defaultFactory == null) {
defaultFactory = MessageResourcesFactory.createFactory();
}
Modified: struts/action/trunk/src/java/org/apache/struts/util/MessageResourcesFactory.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/MessageResourcesFactory.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/MessageResourcesFactory.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/MessageResourcesFactory.java Thu Feb 9 06:11:07 2006
@@ -25,12 +25,18 @@
/**
* Factory for <code>MessageResources</code> instances. The general usage
- * pattern for this class is: <ul> <li>Call <code>MessageResourcesFactory().createFactory()</code>
+ * pattern for this class is:
+ *
+ * <ul>
+ *
+ * <li>Call <code>MessageResourcesFactory().createFactory()</code>
* to retrieve a <code>MessageResourcesFactory</code> instance.</li> <li>Set
* properties as required to configure this factory instance to create
* <code>MessageResources</code> instances with desired characteristics.</li>
+ *
* <li>Call the <code>createResources()</code> method of the factory to
* retrieve a newly instantiated <code>MessageResources</code> instance.</li>
+ *
* </ul>
*
* @version $Rev$ $Date: 2005-08-29 23:57:50 -0400 (Mon, 29 Aug 2005)
@@ -55,7 +61,7 @@
* instances.
*/
protected static String factoryClass =
- "org.apache.struts.util.PropertyMessageResourcesFactory";
+ "org.apache.struts.util.PropertyMessageResourcesFactory";
// ---------------------------------------------------- Instance Properties
@@ -158,12 +164,11 @@
clazz = RequestUtils.applicationClass(factoryClass);
}
- MessageResourcesFactory factory = (MessageResourcesFactory) clazz
- .newInstance();
+ MessageResourcesFactory factory =
+ (MessageResourcesFactory) clazz.newInstance();
return (factory);
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
LOG.error("MessageResourcesFactory.createFactory", t);
return (null);
Modified: struts/action/trunk/src/java/org/apache/struts/util/ModuleException.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/ModuleException.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/ModuleException.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/ModuleException.java Thu Feb 9 06:11:07 2006
@@ -74,7 +74,7 @@
* @param value2 Third replacement value
*/
public ModuleException(String key, Object value0, Object value1,
- Object value2) {
+ Object value2) {
super(key);
message = new ActionMessage(key, value0, value1, value2);
}
@@ -89,7 +89,7 @@
* @param value3 Fourth replacement value
*/
public ModuleException(String key, Object value0, Object value1,
- Object value2, Object value3) {
+ Object value2, Object value3) {
super(key);
message = new ActionMessage(key, value0, value1, value2, value3);
}
Modified: struts/action/trunk/src/java/org/apache/struts/util/ModuleUtils.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/ModuleUtils.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/ModuleUtils.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/ModuleUtils.java Thu Feb 9 06:11:07 2006
@@ -83,13 +83,12 @@
* @return the ModuleConfig object specified, or null if not found in the
* context.
*/
- public ModuleConfig getModuleConfig(String prefix,
- ServletContext context) {
+ public ModuleConfig getModuleConfig(String prefix, ServletContext context) {
if ((prefix == null) || "/".equals(prefix)) {
return (ModuleConfig) context.getAttribute(Globals.MODULE_KEY);
} else {
return (ModuleConfig) context.getAttribute(Globals.MODULE_KEY
- + prefix);
+ + prefix);
}
}
@@ -104,8 +103,7 @@
* context.
*/
public ModuleConfig getModuleConfig(String prefix,
- HttpServletRequest request,
- ServletContext context) {
+ HttpServletRequest request, ServletContext context) {
ModuleConfig moduleConfig = null;
if (prefix != null) {
@@ -127,7 +125,7 @@
* @return the ModuleConfig object
*/
public ModuleConfig getModuleConfig(HttpServletRequest request,
- ServletContext context) {
+ ServletContext context) {
ModuleConfig moduleConfig = this.getModuleConfig(request);
if (moduleConfig == null) {
@@ -146,10 +144,10 @@
* @return The module prefix or ""
*/
public String getModuleName(HttpServletRequest request,
- ServletContext context) {
+ ServletContext context) {
// Acquire the path used to compute the module
- String matchPath = (String) request
- .getAttribute(RequestProcessor.INCLUDE_SERVLET_PATH);
+ String matchPath =
+ (String) request.getAttribute(RequestProcessor.INCLUDE_SERVLET_PATH);
if (matchPath == null) {
matchPath = request.getServletPath();
@@ -177,7 +175,7 @@
int lastSlash = 0; // Initialize before loop
while (prefix.equals("")
- && ((lastSlash = matchPath.lastIndexOf("/")) > 0)) {
+ && ((lastSlash = matchPath.lastIndexOf("/")) > 0)) {
// We may be in a non-default module. Try to get it's prefix.
matchPath = matchPath.substring(0, lastSlash);
@@ -193,7 +191,7 @@
if (log.isDebugEnabled()) {
log.debug("Module name found: "
- + (prefix.equals("") ? "default" : prefix));
+ + (prefix.equals("") ? "default" : prefix));
}
return prefix;
@@ -218,8 +216,7 @@
* @param request The servlet request we are processing
* @param context The ServletContext for this web application
*/
- public void selectModule(HttpServletRequest request,
- ServletContext context) {
+ public void selectModule(HttpServletRequest request, ServletContext context) {
// Compute module name
String prefix = getModuleName(request, context);
@@ -236,20 +233,20 @@
* @param context The ServletContext for this web application
*/
public void selectModule(String prefix, HttpServletRequest request,
- ServletContext context) {
+ ServletContext context) {
// Expose the resources for this module
ModuleConfig config = getModuleConfig(prefix, context);
if (config != null) {
request.setAttribute(Globals.MODULE_KEY, config);
- MessageResourcesConfig[] mrConfig = config
- .findMessageResourcesConfigs();
+ MessageResourcesConfig[] mrConfig =
+ config.findMessageResourcesConfigs();
for (int i = 0; i < mrConfig.length; i++) {
String key = mrConfig[i].getKey();
- MessageResources resources = (MessageResources) context
- .getAttribute(key + prefix);
+ MessageResources resources =
+ (MessageResources) context.getAttribute(key + prefix);
if (resources != null) {
request.setAttribute(key, resources);
Modified: struts/action/trunk/src/java/org/apache/struts/util/PropertyMessageResources.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/PropertyMessageResources.java?rev=376300&r1=376299&r2=376300&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/PropertyMessageResources.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/PropertyMessageResources.java Thu Feb 9 06:11:07 2006
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
@@ -47,7 +48,7 @@
* The <code>Log</code> instance for this class.
*/
protected static final Log log =
- LogFactory.getLog(PropertyMessageResources.class);
+ LogFactory.getLog(PropertyMessageResources.class);
// ------------------------------------------------------------- Properties
@@ -73,7 +74,7 @@
* @param config The configuration parameter for this MessageResources
*/
public PropertyMessageResources(MessageResourcesFactory factory,
- String config) {
+ String config) {
super(factory, config);
log.trace("Initializing, config='" + config + "'");
}
@@ -88,10 +89,10 @@
* @param returnNull The returnNull property we should initialize with
*/
public PropertyMessageResources(MessageResourcesFactory factory,
- String config, boolean returnNull) {
+ String config, boolean returnNull) {
super(factory, config, returnNull);
log.trace("Initializing, config='" + config + "', returnNull="
- + returnNull);
+ + returnNull);
}
// --------------------------------------------------------- Public Methods
@@ -236,7 +237,7 @@
}
ClassLoader classLoader =
- Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = this.getClass().getClassLoader();
@@ -247,15 +248,12 @@
if (is != null) {
try {
props.load(is);
- }
- catch (IOException e) {
+ } catch (IOException e) {
log.error("loadLocale()", e);
- }
- finally {
+ } finally {
try {
is.close();
- }
- catch (IOException e) {
+ } catch (IOException e) {
log.error("loadLocale()", e);
}
}
@@ -278,11 +276,10 @@
if (log.isTraceEnabled()) {
log.trace(" Saving message key '"
- + messageKey(localeKey, key));
+ + messageKey(localeKey, key));
}
- messages.put(messageKey(localeKey, key),
- props.getProperty(key));
+ messages.put(messageKey(localeKey, key), props.getProperty(key));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org