org.apache.cocoon.i18n
Class I18nUtils

java.lang.Object
  extended byorg.apache.cocoon.i18n.I18nUtils

public class I18nUtils
extends Object

A utility class for i18n formatting and parsing routing.

Version:
$Id: I18nUtils.java 312970 2005-10-11 22:50:06Z vgritsenko $
Author:
Konstantin Piroumian, Vadim Gritsenko

Nested Class Summary
static interface I18nUtils.LocaleValidator
          Callback interface for findLocale(Map, String, Parameters, Locale, boolean, boolean, boolean, I18nUtils.LocaleValidator)
 
Method Summary
static Locale findLocale(Map objectModel, String attribute, Parameters parameters, Locale defaultLocale, boolean useLocale)
          Find a suitable locale from an objectModel.
static Locale findLocale(Map objectModel, String attribute, Parameters parameters, Locale defaultLocale, boolean useLocale, boolean useLocales, boolean useBlankLocale, I18nUtils.LocaleValidator test)
          Find a suitable locale from an objectModel.
static Locale parseLocale(String localeString)
          Parses given locale string to Locale object.
static Locale parseLocale(String localeString, Locale defaultLocale)
          Parses given locale string to Locale object.
static void storeLocale(Map objectModel, String attribute, String locale, boolean storeInRequest, boolean storeInSession, boolean storeInCookie, boolean createSession)
          Store locale in request, session, or cookie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseLocale

public static Locale parseLocale(String localeString,
                                 Locale defaultLocale)
Parses given locale string to Locale object. If the string is null then the given locale is returned.

Parameters:
localeString - a string containing locale in language_country_variant format.
defaultLocale - returned if localeString is null

parseLocale

public static Locale parseLocale(String localeString)
Parses given locale string to Locale object. If the string is null then the VM default locale is returned.

Parameters:
localeString - a string containing locale in language_country_variant format.
See Also:
parseLocale(String, Locale), Locale.getDefault()

findLocale

public static Locale findLocale(Map objectModel,
                                String attribute,
                                Parameters parameters,
                                Locale defaultLocale,
                                boolean useLocale,
                                boolean useLocales,
                                boolean useBlankLocale,
                                I18nUtils.LocaleValidator test)
Find a suitable locale from an objectModel.

Returns:
locale found, or null if none found.
Since:
2.1.6

findLocale

public static Locale findLocale(Map objectModel,
                                String attribute,
                                Parameters parameters,
                                Locale defaultLocale,
                                boolean useLocale)
Find a suitable locale from an objectModel.

Returns:
locale found, or server default (never null).
Since:
2.1.6

storeLocale

public static void storeLocale(Map objectModel,
                               String attribute,
                               String locale,
                               boolean storeInRequest,
                               boolean storeInSession,
                               boolean storeInCookie,
                               boolean createSession)
Store locale in request, session, or cookie.

Since:
2.1.6


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.