View Javadoc

1   /*
2    * $Id: TilesRequestContext.java 527536 2007-04-11 15:44:51Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.tiles.context;
22  
23  import java.io.IOException;
24  import java.util.Locale;
25  import java.util.Map;
26  
27  /***
28   * Encapsulation of request information.
29   *
30   * @since 2.0
31   * @version $Rev: 527536 $ $Date: 2007-04-11 17:44:51 +0200 (Wed, 11 Apr 2007) $
32   */
33  public interface TilesRequestContext {
34  
35      /***
36       * Return an immutable Map that maps header names to the first (or only)
37       * header value (as a String).
38       *
39       * @return The header map.
40       */
41      Map<String, String> getHeader();
42  
43      /***
44       * Return an immutable Map that maps header names to the set of all values
45       * specified in the request (as a String array). Header names must be
46       * matched in a case-insensitive manner.
47       *
48       * @return The header values map.
49       */
50      Map<String, String[]> getHeaderValues();
51  
52      /***
53       * Return a mutable Map that maps request scope attribute names to their
54       * values.
55       *
56       * @return The request scope map.
57       */
58      Map<String, Object> getRequestScope();
59  
60      /***
61       * Return a mutable Map that maps session scope attribute names to their
62       * values.
63       *
64       * @return The request scope map.
65       */
66      Map<String, Object> getSessionScope();
67  
68      /***
69       * Dispatches the request to a specified path.
70       *
71       * @param path The path to dispatch to.
72       * @throws IOException If something goes wrong during dispatching.
73       */
74      void dispatch(String path) throws IOException;
75  
76      /***
77       * Includes the response from the specified URL in the current response output.
78       *
79       * @param path The path to include.
80       * @throws IOException If something goes wrong during inclusion.
81       */
82      void include(String path) throws IOException;
83  
84      /***
85       * Return an immutable Map that maps request parameter names to the first
86       * (or only) value (as a String).
87       *
88       * @return The parameter map.
89       */
90      Map<String, String> getParam();
91  
92      /***
93       * Return an immutable Map that maps request parameter names to the set of
94       * all values (as a String array).
95       *
96       * @return The parameter values map.
97       */
98      Map<String, String[]> getParamValues();
99  
100     /***
101      * Return the preferred Locale in which the client will accept content.
102      *
103      * @return The current request locale. It is the locale of the request
104      * object itself and it is NOT the locale that the user wants to use. See
105      * {@link org.apache.tiles.locale.LocaleResolver} to implement strategies to
106      * resolve locales.
107      */
108     Locale getRequestLocale();
109 
110     /***
111      * Determine whether or not the specified user is in the given role.
112      * @param role the role to check against.
113      * @return <code>true</code> if the user is in the given role.
114      */
115     boolean isUserInRole(String role);
116 
117     /***
118      * Get the underlying request.
119      *
120      * @return The current request object.
121      */
122     Object getRequest();
123 
124     /***
125      * Get the underlying response.
126      *
127      * @return The current request object.
128      */
129     Object getResponse();
130 }