|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.spiffyui.server.i18n.BasicBestLocaleMatcher
public final class BasicBestLocaleMatcher
A basic implementation for matching a list of locales from the request and finding a best corresponding supported locale.
Method Summary | |
---|---|
static java.util.Locale |
getBestMatchLocale(HttpServletRequest request,
HttpServletResponse response,
java.util.List<java.util.Locale> supportedLocales)
Return the best match locale by getting a list of requested locales from the request and matching it to the provided list of supported locales. |
static java.util.Locale |
getBestMatchLocale(HttpServletRequest request,
HttpServletResponse response,
ServletContext context)
Return the best match locale for JavaScript dates by getting a list of requested locales from the request. |
static java.util.Locale |
getLocaleFromCode(java.lang.String localeCode)
Creates a Locale object from the xml:lang attribute format or the Java standard (as returned by Locale.toString()) for specifying locales. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.Locale getBestMatchLocale(HttpServletRequest request, HttpServletResponse response, ServletContext context)
Return the best match locale for JavaScript dates by getting a list of requested locales from the request.
This methods builds the list of supported locales based on the JavaScript date and time localization classes included in the Spiffy UI framework. It will loop through the list of locales and attempt to match first exactly, then by language and country, then by country. If no match is found it will default to English.
This method should almost never be called by classes outside of the Spiffy UI framework.
If your application supports a different list of locales, and most of them do, then you should call the version of this method passing a list of supported locales.
request
- - the HttpServletRequestresponse
- - the HttpServletResponsecontext
- - the ServletContext
public static java.util.Locale getBestMatchLocale(HttpServletRequest request, HttpServletResponse response, java.util.List<java.util.Locale> supportedLocales)
Return the best match locale by getting a list of requested locales from the request and matching it to the provided list of supported locales.
This method will loop through the list of locales and attempt to match first exactly, then by language and country, then by country. If no match is found it will default to English.
request
- - the HttpServletRequestresponse
- - the HttpServletResponsesupportedLocales
- - the list of available locales to choose from
public static java.util.Locale getLocaleFromCode(java.lang.String localeCode)
localeCode
- String code that conforms to the RFC 3066 standard or the Java standard (as returned by Locale.toString()).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |