net.sourceforge.stripes.localization
Interface LocalePicker

All Superinterfaces:
ConfigurableComponent
All Known Implementing Classes:
DefaultLocalePicker

public interface LocalePicker
extends ConfigurableComponent

A LocalePicker is a class that determines what Locale a particular request will use. At first this may seem odd given that the request already has a method called getLocale(), but ask yourself this: if your site only supports English, and the user's browser requests the Japanese locale, in what locale should you accept their input?

The LocalPicker is given access to the request and can use any mechanism it chooses to decide upon a Locale. However, it must return a valid locale. It is suggested that if a locale cannot be chosen that the picker return the system locale.

Author:
Tim Fennell

Method Summary
 String pickCharacterEncoding(HttpServletRequest request, Locale locale)
          Picks the character encoding to use for the current request using the specified Locale.
 Locale pickLocale(HttpServletRequest request)
          Picks a locale for the HttpServletRequest supplied.
 
Methods inherited from interface net.sourceforge.stripes.config.ConfigurableComponent
init
 

Method Detail

pickLocale

Locale pickLocale(HttpServletRequest request)
Picks a locale for the HttpServletRequest supplied. Given that the request could be a regular request or a form upload request it is suggested that the LocalePicker only rely on the headers in the request, and perhaps the session, and not look for parameters.

Parameters:
request - the current HttpServletRequest
Returns:
Locale the locale to be used throughout the request for input parsing and localized output

pickCharacterEncoding

String pickCharacterEncoding(HttpServletRequest request,
                             Locale locale)
Picks the character encoding to use for the current request using the specified Locale. The character encoding will be set on both the request and the response. If the LocalePicker does not wish to change or specify a character encoding then this method should return null.

Parameters:
request - the current HttpServletRequest
locale - the Locale picked by the LocalePicker for this request
Returns:
the name of the character encoding to use, or null to use the default


? Copyright 2005-2006, Stripes Development Team.