com.github.fge.msgsimple.locale
Class LocaleUtils

java.lang.Object
  extended by com.github.fge.msgsimple.locale.LocaleUtils

public final class LocaleUtils
extends Object

Utility methods for Locale management

This class provides two methods:

The getApplicable(Locale) method emulates what the JDK's ResourceBundle does when you look up a message in a locale; it returns an ordered list from the most specific to the more general. For instance, given the locale "ja_JP_JP", it will generate the following list:


Method Summary
static Collection<Locale> getApplicable(Locale target)
          Get a "decrementing" list of candidate locales for a given locale
static Locale parseLocale(String input)
          Parse a string input as an argument and return a locale object
 
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 input)
Parse a string input as an argument and return a locale object

Three things to note:

Parameters:
input - the input string
Returns:
a Locale
Throws:
NullPointerException - input is null
IllegalArgumentException - input is malformed (see above)
See Also:
Locale

getApplicable

public static Collection<Locale> getApplicable(Locale target)
Get a "decrementing" list of candidate locales for a given locale

The order of locale returned is from the more specific to the less specific (the latter being Locale.ROOT).

Parameters:
target - the locale
Returns:
the list of applicable locales