com.google.visualization.datasource.base
Class LocaleUtil

java.lang.Object
  extended by com.google.visualization.datasource.base.LocaleUtil

public class LocaleUtil
extends java.lang.Object

A utility class for locale handling.

Author:
Yaniv S.

Method Summary
static com.ibm.icu.util.ULocale getDefaultLocale()
          Returns the default locale.
static java.util.Locale getLocaleFromLocaleString(java.lang.String s)
          Converts a locale string from the RFC 3066 standard format to the Java locale format.
static java.lang.String getLocalizedMessageFromBundle(java.lang.String bundleName, java.lang.String key, java.util.Locale locale)
          Returns a localized message from the specified ResourceBundle for the given key.
static void setDefaultLocale(com.ibm.icu.util.ULocale defaultLocale)
          Sets the default locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLocaleFromLocaleString

public static java.util.Locale getLocaleFromLocaleString(java.lang.String s)
Converts a locale string from the RFC 3066 standard format to the Java locale format. You can call this on any locale string obtained from an external source (cookie, URL parameter, header, etc.). This method accepts more than just the standard format and will also tolerate capitalization discrepancies and the use of an underscore in place of a hyphen.

Parameters:
s - The locale string.
Returns:
The locale for the given locale string.

setDefaultLocale

public static void setDefaultLocale(com.ibm.icu.util.ULocale defaultLocale)
Sets the default locale.

Parameters:
defaultLocale - The default locale.

getDefaultLocale

public static com.ibm.icu.util.ULocale getDefaultLocale()
Returns the default locale.

Returns:
The default locale.

getLocalizedMessageFromBundle

public static java.lang.String getLocalizedMessageFromBundle(java.lang.String bundleName,
                                                             java.lang.String key,
                                                             java.util.Locale locale)
Returns a localized message from the specified ResourceBundle for the given key. In case the locale is null, uses the default locale. If locale is null, the default ResourceBundle is used.

Parameters:
bundleName - The name of the resource bundle.
key - The key of the requested string.
locale - The locale.
Returns:
A localized message from the bundle based on the given locale.


Copyright © 2009 Google. All Rights Reserved.