org.joda.time.contrib.jsptag
Class Util

java.lang.Object
  extended byorg.joda.time.contrib.jsptag.Util

public class Util
extends Object

Utilities in support of tag-handler classes.

Author:
Jan Luehe, Jim Newsham

Constructor Summary
Util()
           
 
Method Summary
static LocalizationContext getLocalizationContext(PageContext pc)
          Gets the default I18N localization context.
static LocalizationContext getLocalizationContext(PageContext pc, String basename)
          Gets the resource bundle with the given base name, whose locale is determined as follows: Check if a match exists between the ordered set of preferred locales and the available locales, for the given base name.
static Enumeration getRequestLocales(HttpServletRequest request)
          HttpServletRequest.getLocales() returns the server's default locale if the request did not specify a preferred language.
static int getScope(String scope)
          Converts the given string description of a scope to the corresponding PageContext constant.
static Locale parseLocale(String locale)
          See parseLocale(String, String) for details.
static Locale parseLocale(String locale, String variant)
          Parses the given locale string into its language and (optionally) country components, and returns the corresponding java.util.Locale object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

getScope

public static int getScope(String scope)
Converts the given string description of a scope to the corresponding PageContext constant. The validity of the given scope has already been checked by the appropriate TLV.

Parameters:
scope - String description of scope
Returns:
PageContext constant corresponding to given scope description

getRequestLocales

public static Enumeration getRequestLocales(HttpServletRequest request)
HttpServletRequest.getLocales() returns the server's default locale if the request did not specify a preferred language. We do not want this behavior, because it prevents us from using the fallback locale. We therefore need to return an empty Enumeration if no preferred locale has been specified. This way, the logic for the fallback locale will be able to kick in.


parseLocale

public static Locale parseLocale(String locale)
See parseLocale(String, String) for details.


parseLocale

public static Locale parseLocale(String locale,
                                 String variant)
Parses the given locale string into its language and (optionally) country components, and returns the corresponding java.util.Locale object. If the given locale string is null or empty, the runtime's default locale is returned.

Parameters:
locale - the locale string to parse
variant - the variant
Returns:
java.util.Locale object corresponding to the given locale string, or the runtime's default locale if the locale string is null or empty
Throws:
IllegalArgumentException - if the given locale does not have a language component or has an empty country component

getLocalizationContext

public static LocalizationContext getLocalizationContext(PageContext pc)
Gets the default I18N localization context.

Parameters:
pc - Page in which to look up the default I18N localization context

getLocalizationContext

public static LocalizationContext getLocalizationContext(PageContext pc,
                                                         String basename)
Gets the resource bundle with the given base name, whose locale is determined as follows: Check if a match exists between the ordered set of preferred locales and the available locales, for the given base name. The set of preferred locales consists of a single locale (if the javax.servlet.jsp.jstl.fmt.locale configuration setting is present) or is equal to the client's preferred locales determined from the client's browser settings.

If no match was found in the previous step, check if a match exists between the fallback locale (given by the javax.servlet.jsp.jstl.fmt.fallbackLocale configuration setting) and the available locales, for the given base name.

Parameters:
pc - Page in which the resource bundle with the given base name is requested
basename - Resource bundle base name
Returns:
Localization context containing the resource bundle with the given base name and the locale that led to the resource bundle match, or the empty localization context if no resource bundle match was found


Copyright © 2005-2008 Joda.org. All Rights Reserved.