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: 736275 $ $Date: 2009-01-21 10:58:20 +0100 (mer, 21 gen 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 * Return an immutable Map that maps request parameter names to the first
127 * (or only) value (as a String).
128 *
129 * @return The parameter map.
130 */
131 Map<String, String> getParam();
132
133 /***
134 * Return an immutable Map that maps request parameter names to the set of
135 * all values (as a String array).
136 *
137 * @return The parameter values map.
138 */
139 Map<String, String[]> getParamValues();
140
141 /***
142 * Return the preferred Locale in which the client will accept content.
143 *
144 * @return The current request locale. It is the locale of the request
145 * object itself and it is NOT the locale that the user wants to use. See
146 * {@link org.apache.tiles.locale.LocaleResolver} to implement strategies to
147 * resolve locales.
148 */
149 Locale getRequestLocale();
150
151 /***
152 * Determine whether or not the specified user is in the given role.
153 * @param role the role to check against.
154 * @return <code>true</code> if the user is in the given role.
155 */
156 boolean isUserInRole(String role);
157
158 /***
159 * Returns the original request objects used to create this request.
160 *
161 * @return The request objects.
162 * @since 2.1.2
163 */
164 Object[] getRequestObjects();
165
166 /***
167 * Get the underlying request.
168 *
169 * @return The current request object.
170 * @deprecated Use {@link #getRequestObjects()}.
171 */
172 @Deprecated
173 Object getRequest();
174
175 /***
176 * Get the underlying response.
177 *
178 * @return The current request object.
179 * @deprecated Use {@link #getRequestObjects()}.
180 */
181 @Deprecated
182 Object getResponse();
183 }