View Javadoc

1   /*
2    * $Id: MockOnlyLocaleTilesContext.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  
22  package org.apache.tiles.definition;
23  
24  import java.io.IOException;
25  import java.util.Locale;
26  import java.util.Map;
27  
28  import org.apache.tiles.context.TilesRequestContext;
29  
30  /***
31   * Creates a TilesApplicationContext that contains only a Locale.
32   *
33   * @version $Rev: 527536 $ $Date: 2007-04-11 17:44:51 +0200 (Wed, 11 Apr 2007) $
34   */
35  public class MockOnlyLocaleTilesContext implements TilesRequestContext {
36  
37      /***
38       * The locale object.
39       */
40      private Locale locale;
41  
42      /*** Creates a new instance of MockOnlyLocaleTilesContext.
43       *
44       * @param locale The locale object to use.
45       */
46      public MockOnlyLocaleTilesContext(Locale locale) {
47          this.locale = locale;
48      }
49  
50      /***
51       * Returns the locale specified in the constructor.
52       *
53       * @return The locale of the request.
54       * @see org.apache.tiles.context.TilesRequestContext#getRequestLocale()
55       */
56      public Locale getRequestLocale() {
57          return locale;
58      }
59  
60      // The rest of the implemented methods has a "dummy" behaviour, doing
61      // nothing or returning null, because they are not needed at all in tests
62      // that use this class.
63  
64      /*** {@inheritDoc} */
65      public void dispatch(String path) throws IOException {
66      }
67  
68      /*** {@inheritDoc} */
69      public Map<String, String> getHeader() {
70          return null;
71      }
72  
73      /*** {@inheritDoc} */
74      public Map<String, String[]> getHeaderValues() {
75          return null;
76      }
77  
78      /*** {@inheritDoc} */
79      public Map<String, String> getParam() {
80          return null;
81      }
82  
83      /*** {@inheritDoc} */
84      public Map<String, String[]> getParamValues() {
85          return null;
86      }
87  
88      /*** {@inheritDoc} */
89      public Map<String, Object> getRequestScope() {
90          return null;
91      }
92  
93      /*** {@inheritDoc} */
94      public Map<String, Object> getSessionScope() {
95          return null;
96      }
97  
98      /*** {@inheritDoc} */
99      public void include(String path) throws IOException {
100     }
101 
102     /*** {@inheritDoc} */
103     public boolean isUserInRole(String role) {
104         return false;
105     }
106 
107     /*** {@inheritDoc} */
108     public Object getRequest() {
109         return null;  //To change body of implemented methods use File | Settings | File Templates.
110     }
111 
112     /*** {@inheritDoc} */
113     public Object getResponse() {
114         return null;  //To change body of implemented methods use File | Settings | File Templates.
115     }
116 }