org.databene.commons
Class LocaleUtil

java.lang.Object
  extended by org.databene.commons.LocaleUtil

public final class LocaleUtil
extends java.lang.Object

Provides locale operations like determining the parent of a locale, finding a locale by code, providing the characters of a locale and a so-called 'fallback locale'.

Created: 26.09.2006 23:34:41

Author:
Volker Bergmann

Constructor Summary
LocaleUtil()
           
 
Method Summary
static java.lang.String availableLocaleUrl(java.lang.String baseName, java.util.Locale locale, java.lang.String suffix)
           
static
<T> T
callInLocale(java.util.Locale locale, java.util.concurrent.Callable<T> task)
           
static java.lang.String getDefaultCountryCode()
           
static java.util.Locale getFallbackLocale()
          Returns the fallback locale.
static java.util.Locale getLocale(java.lang.String code)
          Maps the locale code to a locale, e.g. de_DE to Locale.GERMANY.
static java.util.Locale language(java.util.Locale locale)
           
static java.util.Set<java.lang.Character> letters(java.util.Locale locale)
          Returns a set that contains all letters of the specified locale.
static java.util.Locale parent(java.util.Locale locale)
          Determines a locale's parent, e.g. for a locale 'de_DE' it returns 'de'.
static void runInLocale(java.util.Locale locale, java.lang.Runnable task)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocaleUtil

public LocaleUtil()
Method Detail

letters

public static java.util.Set<java.lang.Character> letters(java.util.Locale locale)
Returns a set that contains all letters of the specified locale.

Parameters:
locale - the locale of which the character set is requested
Returns:
a set of characters that contains all letters of the specified locale
Throws:
java.lang.UnsupportedOperationException - if the locale is not supported

parent

public static java.util.Locale parent(java.util.Locale locale)
Determines a locale's parent, e.g. for a locale 'de_DE' it returns 'de'.

Parameters:
locale - the locale of which to determine the parent
Returns:
the locale's parent, or null if the locale has no parent.

getFallbackLocale

public static java.util.Locale getFallbackLocale()
Returns the fallback locale. This differs from the default locale for cases in which it is desirable to restrict the used character ranges to an unproblematic minimum.

Returns:
the fallback locale.

getLocale

public static java.util.Locale getLocale(java.lang.String code)
Maps the locale code to a locale, e.g. de_DE to Locale.GERMANY.

Parameters:
code - the locale colde to map
Returns:
a locale instance the represents the code

availableLocaleUrl

public static java.lang.String availableLocaleUrl(java.lang.String baseName,
                                                  java.util.Locale locale,
                                                  java.lang.String suffix)

getDefaultCountryCode

public static java.lang.String getDefaultCountryCode()

language

public static java.util.Locale language(java.util.Locale locale)

runInLocale

public static void runInLocale(java.util.Locale locale,
                               java.lang.Runnable task)

callInLocale

public static <T> T callInLocale(java.util.Locale locale,
                                 java.util.concurrent.Callable<T> task)
                      throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2010. All Rights Reserved.