1/*2 * $Id: TilesRequestContext.java 736275 2009-01-21 09:58:20Z 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: 736275 $ $Date: 2009-01-21 10:58:20 +0100 (mer, 21 gen 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 * Return an immutable Map that maps request parameter names to the first127 * (or only) value (as a String).128 *129 * @return The parameter map.130 */131 Map<String, String> getParam();
132133/***134 * Return an immutable Map that maps request parameter names to the set of135 * all values (as a String array).136 *137 * @return The parameter values map.138 */139 Map<String, String[]> getParamValues();
140141/***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 request145 * object itself and it is NOT the locale that the user wants to use. See146 * {@link org.apache.tiles.locale.LocaleResolver} to implement strategies to147 * resolve locales.148 */149 Locale getRequestLocale();
150151/***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 */156boolean isUserInRole(String role);
157158/***159 * Returns the original request objects used to create this request.160 *161 * @return The request objects.162 * @since 2.1.2163 */164 Object[] getRequestObjects();
165166/***167 * Get the underlying request.168 *169 * @return The current request object.170 * @deprecated Use {@link #getRequestObjects()}.171 */172 @Deprecated
173 Object getRequest();
174175/***176 * Get the underlying response.177 *178 * @return The current request object.179 * @deprecated Use {@link #getRequestObjects()}.180 */181 @Deprecated
182 Object getResponse();
183 }