1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.fileupload.portlet;
17
18 import java.io.InputStream;
19 import java.io.IOException;
20 import javax.portlet.ActionRequest;
21 import org.apache.commons.fileupload.RequestContext;
22
23 /***
24 * <p>Provides access to the request information needed for a request made to
25 * a portlet.</p>
26 *
27 * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
28 *
29 * @since FileUpload 1.1
30 *
31 * @version $Id: PortletRequestContext.java 349393 2005-11-28 06:36:35Z martinc $
32 */
33 public class PortletRequestContext implements RequestContext {
34
35
36
37 /***
38 * The request for which the context is being provided.
39 */
40 private ActionRequest request;
41
42
43
44
45 /***
46 * Construct a context for this request.
47 *
48 * @param request The request to which this context applies.
49 */
50 public PortletRequestContext(ActionRequest request) {
51 this.request = request;
52 }
53
54
55
56
57 /***
58 * Retrieve the character encoding for the request.
59 *
60 * @return The character encoding for the request.
61 */
62 public String getCharacterEncoding() {
63 return request.getCharacterEncoding();
64 }
65
66 /***
67 * Retrieve the content type of the request.
68 *
69 * @return The content type of the request.
70 */
71 public String getContentType() {
72 return request.getContentType();
73 }
74
75 /***
76 * Retrieve the content length of the request.
77 *
78 * @return The content length of the request.
79 */
80 public int getContentLength() {
81 return request.getContentLength();
82 }
83
84 /***
85 * Retrieve the input stream for the request.
86 *
87 * @return The input stream for the request.
88 *
89 * @throws IOException if a problem occurs.
90 */
91 public InputStream getInputStream() throws IOException {
92 return request.getPortletInputStream();
93 }
94
95 /***
96 * Returns a string representation of this object.
97 *
98 * @return a string representation of this object.
99 */
100 public String toString() {
101 return "ContentLength="
102 + this.getContentLength()
103 + ", ContentType="
104 + this.getContentType();
105 }
106
107 }