org.apache.cocoon.i18n
Class I18nUtils

java.lang.Object
  extended by org.apache.cocoon.i18n.I18nUtils

public class I18nUtils
extends Object

A utility class for i18n formatting and parsing routing.

Version:
$Id: I18nUtils.html 1304258 2012-03-23 10:09:27Z ilgrosso $
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)
 
Field Summary
static String NAMESPACE_URI
          The namespace for i18n is "http://apache.org/cocoon/i18n/2.1".
static String OLD_NAMESPACE_URI
          The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0".
 
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 boolean matchesI18nNamespace(String uri)
           
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
 

Field Detail

NAMESPACE_URI

public static final String NAMESPACE_URI
The namespace for i18n is "http://apache.org/cocoon/i18n/2.1".

See Also:
Constant Field Values

OLD_NAMESPACE_URI

public static final String OLD_NAMESPACE_URI
The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0".

See Also:
Constant Field Values
Method Detail

parseLocale

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

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

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

matchesI18nNamespace

public static boolean matchesI18nNamespace(String uri)


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.