org.barracudamvc.core.util.l10n
Class Locales

java.lang.Object
  extended byorg.barracudamvc.plankton.l10n.Locales
      extended byorg.barracudamvc.core.util.l10n.Locales

public class Locales
extends Locales

Simple locale utilities. This class makes it easy to determine the target locale from an event context or a servlet request. You can also set the locale and ask the class to save the information for you (in a cookie and/or the session) so that the locale info will persist across muliple requests


Field Summary
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class org.barracudamvc.plankton.l10n.Locales
COOKIES_AND_SESSION, COUNTRY_KEY, LANGAUGE_KEY, NONE, PERSIST_DEFAULT, SESSION, VARIANT_KEY
 
Constructor Summary
Locales()
           
 
Method Summary
static Locale getClientLocale(EventContext ec)
          Get the client locale from an EventContext using the default param keys and persist option.
static Locale getClientLocale(EventContext ec, String languageKey, String countryKey, String variantKey, int persistOption)
          Get the client locale from an EventContext
static void releaseClientLocale(EventContext ec)
          Release the client locale using an EventContext (this effectively removes it from whereever it might have been persisted).
static void releaseClientLocale(EventContext ec, int persistOption)
          Release the client locale using an EventContext (this effectively removes it from whereever it might have been persisted).
static void saveClientLocale(EventContext ec, Locale loc)
          Save the client locale using an EventContext using the default persist option
static void saveClientLocale(EventContext ec, Locale loc, int persistOption)
          Save the client locale using an EventContext
 
Methods inherited from class org.barracudamvc.plankton.l10n.Locales
findClosestLocale, getClientLocale, getClientLocale, releaseClientLocale, releaseClientLocale, saveClientLocale, saveClientLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

Locales

public Locales()
Method Detail

getClientLocale

public static Locale getClientLocale(EventContext ec)
Get the client locale from an EventContext using the default param keys and persist option. This will probably be the method you use most frequently.

Parameters:
ec - the EventContext from which we'd like to determine Locale
Returns:
the target client Locale

getClientLocale

public static Locale getClientLocale(EventContext ec,
                                     String languageKey,
                                     String countryKey,
                                     String variantKey,
                                     int persistOption)
Get the client locale from an EventContext

Parameters:
ec - the EventContext from which we'd like to determine Locale
languageKey - the key to be used to look in the request for a language paramter
countryKey - the key to be used to look in the request for a country paramter
variantKey - the key to be used to look in the request for a variant paramter
persistOption - how we'd like to persist the Locale (by default, it will be stored in the SESSION)
Returns:
the target client Locale

saveClientLocale

public static void saveClientLocale(EventContext ec,
                                    Locale loc)
Save the client locale using an EventContext using the default persist option

Parameters:
ec - the EventContext in which we'd like to set Locale
loc - the target client locale we'd like to set

saveClientLocale

public static void saveClientLocale(EventContext ec,
                                    Locale loc,
                                    int persistOption)
Save the client locale using an EventContext

Parameters:
ec - the EventContext in which we'd like to set Locale
loc - the target client locale we'd like to set
persistOption - the specific persistOption to be used

releaseClientLocale

public static void releaseClientLocale(EventContext ec)
Release the client locale using an EventContext (this effectively removes it from whereever it might have been persisted). This means that on the next request the locale will be determined from scratch again.

Parameters:
ec - the EventContext in which we'd like to set Locale (this tells us where the locale info needs to be removed from)

releaseClientLocale

public static void releaseClientLocale(EventContext ec,
                                       int persistOption)
Release the client locale using an EventContext (this effectively removes it from whereever it might have been persisted). This means that on the next request the locale will be determined from scratch again.

Parameters:
ec - the EventContext in which we'd like to set Locale
persistOption - the specific persistOption to be used (this tells us where the locale info needs to be removed from)


Copyright © 2004 BarracudaMVC.org All Rights Reserved.