1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.tiles.context;
22
23 import java.io.IOException;
24 import java.io.OutputStream;
25 import java.io.PrintWriter;
26 import java.io.Writer;
27 import java.util.Locale;
28 import java.util.Map;
29
30 import org.apache.tiles.TilesApplicationContext;
31
32 /***
33 * Encapsulation of request information.
34 *
35 * @since 2.0
36 * @version $Rev: 769961 $ $Date: 2009-04-30 00:07:34 +0200 (gio, 30 apr 2009) $
37 */
38 public interface TilesRequestContext {
39
40 /***
41 * Return an immutable Map that maps header names to the first (or only)
42 * header value (as a String).
43 *
44 * @return The header map.
45 */
46 Map<String, String> getHeader();
47
48 /***
49 * Return an immutable Map that maps header names to the set of all values
50 * specified in the request (as a String array). Header names must be
51 * matched in a case-insensitive manner.
52 *
53 * @return The header values map.
54 */
55 Map<String, String[]> getHeaderValues();
56
57 /***
58 * Return a mutable Map that maps request scope attribute names to their
59 * values.
60 *
61 * @return The request scope map.
62 */
63 Map<String, Object> getRequestScope();
64
65 /***
66 * Return a mutable Map that maps session scope attribute names to their
67 * values.
68 *
69 * @return The request scope map.
70 */
71 Map<String, Object> getSessionScope();
72
73 /***
74 * Returns the associated application context.
75 *
76 * @return The application context associated to this request.
77 * @since 2.1.1
78 */
79 TilesApplicationContext getApplicationContext();
80
81 /***
82 * Dispatches the request to a specified path.
83 *
84 * @param path The path to dispatch to.
85 * @throws IOException If something goes wrong during dispatching.
86 */
87 void dispatch(String path) throws IOException;
88
89 /***
90 * Includes the response from the specified URL in the current response output.
91 *
92 * @param path The path to include.
93 * @throws IOException If something goes wrong during inclusion.
94 */
95 void include(String path) throws IOException;
96
97 /***
98 * Returns an output stream to be used to write directly in the response.
99 *
100 * @return The output stream that writes in the response.
101 * @throws IOException If something goes wrong when getting the output stream.
102 * @since 2.1.2
103 */
104 OutputStream getOutputStream() throws IOException;
105
106 /***
107 * Returns a writer to be used to write directly in the response.
108 *
109 * @return The writer that writes in the response.
110 * @throws IOException If something goes wrong when getting the writer.
111 * @since 2.1.2
112 */
113 Writer getWriter() throws IOException;
114
115 /***
116 * Returns a print writer to be used to write directly in the response.
117 *
118 * @return The print writer that writes in the response.
119 * @throws IOException If something goes wrong when getting the print
120 * writer.
121 * @since 2.1.2
122 */
123 PrintWriter getPrintWriter() throws IOException;
124
125 /***
126 * Sets the content type when rendering the result.
127 *
128 * @param contentType The content type. It should follow the specifications
129 * from W3C about content types.
130 * @since 2.2.0
131 */
132 void setContentType(String contentType);
133
134 /***
135 * Checks if the response has been committed.
136 *
137 * @return <code>true</code> only if the response has been committed.
138 * @since 2.2.0
139 */
140 boolean isResponseCommitted();
141
142 /***
143 * Return an immutable Map that maps request parameter names to the first
144 * (or only) value (as a String).
145 *
146 * @return The parameter map.
147 */
148 Map<String, String> getParam();
149
150 /***
151 * Return an immutable Map that maps request parameter names to the set of
152 * all values (as a String array).
153 *
154 * @return The parameter values map.
155 */
156 Map<String, String[]> getParamValues();
157
158 /***
159 * Return the preferred Locale in which the client will accept content.
160 *
161 * @return The current request locale. It is the locale of the request
162 * object itself and it is NOT the locale that the user wants to use. See
163 * {@link org.apache.tiles.locale.LocaleResolver} to implement strategies to
164 * resolve locales.
165 */
166 Locale getRequestLocale();
167
168 /***
169 * Determine whether or not the specified user is in the given role.
170 * @param role the role to check against.
171 * @return <code>true</code> if the user is in the given role.
172 */
173 boolean isUserInRole(String role);
174
175 /***
176 * Returns the original request objects used to create this request.
177 *
178 * @return The request objects.
179 * @since 2.1.2
180 */
181 Object[] getRequestObjects();
182
183 /***
184 * Get the underlying request.
185 *
186 * @return The current request object.
187 * @deprecated Use {@link #getRequestObjects()}.
188 */
189 @Deprecated
190 Object getRequest();
191
192 /***
193 * Get the underlying response.
194 *
195 * @return The current request object.
196 * @deprecated Use {@link #getRequestObjects()}.
197 */
198 @Deprecated
199 Object getResponse();
200 }