1/*2 * $Id: TilesRequestContext.java 769961 2009-04-29 22:07:34Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */21package org.apache.tiles.context;
2223import java.io.IOException;
24import java.io.OutputStream;
25import java.io.PrintWriter;
26import java.io.Writer;
27import java.util.Locale;
28import java.util.Map;
2930import org.apache.tiles.TilesApplicationContext;
3132/***33 * Encapsulation of request information.34 *35 * @since 2.036 * @version $Rev: 769961 $ $Date: 2009-04-30 00:07:34 +0200 (gio, 30 apr 2009) $37 */38publicinterfaceTilesRequestContext {
3940/***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();
4748/***49 * Return an immutable Map that maps header names to the set of all values50 * specified in the request (as a String array). Header names must be51 * matched in a case-insensitive manner.52 *53 * @return The header values map.54 */55 Map<String, String[]> getHeaderValues();
5657/***58 * Return a mutable Map that maps request scope attribute names to their59 * values.60 *61 * @return The request scope map.62 */63 Map<String, Object> getRequestScope();
6465/***66 * Return a mutable Map that maps session scope attribute names to their67 * values.68 *69 * @return The request scope map.70 */71 Map<String, Object> getSessionScope();
7273/***74 * Returns the associated application context.75 *76 * @return The application context associated to this request.77 * @since 2.1.178 */79 TilesApplicationContext getApplicationContext();
8081/***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 */87void dispatch(String path) throws IOException;
8889/***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 */95void include(String path) throws IOException;
9697/***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.2103 */104 OutputStream getOutputStream() throws IOException;
105106/***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.2112 */113 Writer getWriter() throws IOException;
114115/***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 print120 * writer.121 * @since 2.1.2122 */123 PrintWriter getPrintWriter() throws IOException;
124125/***126 * Sets the content type when rendering the result.127 *128 * @param contentType The content type. It should follow the specifications129 * from W3C about content types.130 * @since 2.2.0131 */132void setContentType(String contentType);
133134/***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.0139 */140boolean isResponseCommitted();
141142/***143 * Return an immutable Map that maps request parameter names to the first144 * (or only) value (as a String).145 *146 * @return The parameter map.147 */148 Map<String, String> getParam();
149150/***151 * Return an immutable Map that maps request parameter names to the set of152 * all values (as a String array).153 *154 * @return The parameter values map.155 */156 Map<String, String[]> getParamValues();
157158/***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 request162 * object itself and it is NOT the locale that the user wants to use. See163 * {@link org.apache.tiles.locale.LocaleResolver} to implement strategies to164 * resolve locales.165 */166 Locale getRequestLocale();
167168/***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 */173boolean isUserInRole(String role);
174175/***176 * Returns the original request objects used to create this request.177 *178 * @return The request objects.179 * @since 2.1.2180 */181 Object[] getRequestObjects();
182183/***184 * Get the underlying request.185 *186 * @return The current request object.187 * @deprecated Use {@link #getRequestObjects()}.188 */189 @Deprecated
190 Object getRequest();
191192/***193 * Get the underlying response.194 *195 * @return The current request object.196 * @deprecated Use {@link #getRequestObjects()}.197 */198 @Deprecated
199 Object getResponse();
200 }