KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > LocaleResolver


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.web.servlet;
18
19 import java.util.Locale JavaDoc;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import javax.servlet.http.HttpServletResponse JavaDoc;
23
24 /**
25  * Interface for web-based locale resolution strategies that allows for
26  * both locale resolution via the request and locale modification via
27  * request and response.
28  *
29  * <p>This interface allows for implementations based on request, session,
30  * cookies, etc. The default implementation is AcceptHeaderLocaleResolver,
31  * simply using the request's locale provided by the respective HTTP header.
32  *
33  * <p>Use <code>RequestContext.getLocale()</code> to retrieve the current locale
34  * in controllers or views, independent of the actual resolution strategy.
35  *
36  * @author Juergen Hoeller
37  * @since 27.02.2003
38  * @see org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
39  * @see org.springframework.web.servlet.support.RequestContext#getLocale
40  */

41 public interface LocaleResolver {
42
43   /**
44    * Resolve the current locale via the given request.
45    * Should return a default locale as fallback in any case.
46    * @param request the request to resolve the locale for
47    * @return the current locale (never <code>null</code>)
48    */

49     Locale JavaDoc resolveLocale(HttpServletRequest JavaDoc request);
50
51   /**
52    * Set the current locale to the given one.
53    * @param request the request to be used for locale modification
54    * @param response the response to be used for locale modification
55    * @param locale the new locale, or <code>null</code> to clear the locale
56      * @throws UnsupportedOperationException if the LocaleResolver implementation
57      * does not support dynamic changing of the theme
58    */

59     void setLocale(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Locale JavaDoc locale);
60
61 }
62
Popular Tags