Package org.nuiton.i18n.bundle
Enum I18nBundleScope
- java.lang.Object
-
- java.lang.Enum<I18nBundleScope>
-
- org.nuiton.i18n.bundle.I18nBundleScope
-
- All Implemented Interfaces:
Serializable
,Comparable<I18nBundleScope>
public enum I18nBundleScope extends Enum<I18nBundleScope>
The enumaration defines the scope of a bundle entry. There is three scope possible:GENERAL
: for a bundle entry with no locale specialized information, eg :bundle.properties
LANGUAGE
: for a bundle entry with language locale specialized information, eg :bundle-en.properties
FULL
: for a bundle entry with full locale specialized information, eg :bundle-en_GB.properties
GENERAL
<LANGUAGE
<FULL
Scopes are inclusives, in a search of entries, eg the search ofen_GB
will includeen
scope... The#patternAll
is the searching pattern of bundle of the scope. The methodgetMatcher(String)
obtain from the#patternAll
the matcher for a bundle path. The methodgetLocale(Matcher)
obtain from the#patternAll
matched in a bundle path, the corresponding locale. The class offer also a static methodvalueOf(Locale)
to obtain the scope of a locale.- Author:
- Tony Chemit - chemit@codelutin.com
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getBundlePrefix(Matcher matcher)
abstract Locale
getLocale(Matcher matcher)
get the locale for a given matcher.Matcher
getMatcher(String path)
get a matcher fro the given path for this scopestatic I18nBundleScope
valueOf(String name)
Returns the enum constant of this type with the specified name.static I18nBundleScope
valueOf(Locale locale)
Obtain the scope of a givenlocale
.static I18nBundleScope[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
GENERAL
public static final I18nBundleScope GENERAL
default scope (with no language, nor country information)
-
LANGUAGE
public static final I18nBundleScope LANGUAGE
language scope (no country information)
-
FULL
public static final I18nBundleScope FULL
full scope : language + country
-
-
Method Detail
-
values
public static I18nBundleScope[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (I18nBundleScope c : I18nBundleScope.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static I18nBundleScope valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
valueOf
public static I18nBundleScope valueOf(Locale locale)
Obtain the scope of a givenlocale
. The given locale can be null, which meansGENERAL
scope.- Parameters:
locale
- given locale to convert- Returns:
- the scope of given locale
-
getMatcher
public Matcher getMatcher(String path)
get a matcher fro the given path for this scope- Parameters:
path
- the path to treate- Returns:
- the bunle detect matcher
-
getLocale
public abstract Locale getLocale(Matcher matcher)
get the locale for a given matcher.- Parameters:
matcher
- the scope matcher to use- Returns:
- the locale
-
-