Package org.nuiton.i18n.bundle
Enum I18nBundleScope
java.lang.Object
java.lang.Enum<I18nBundleScope>
org.nuiton.i18n.bundle.I18nBundleScope
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<I18nBundleScope>,java.lang.constant.Constable
public enum I18nBundleScope extends java.lang.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.propertiesLANGUAGE: for a bundle entry with language locale specialized information, eg :bundle-en.propertiesFULL: 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 of
en_GB will include en scope...
The #patternAll is the searching pattern of bundle of the scope.
The method getMatcher(String) obtain from the #patternAll
the matcher for a bundle path.
The method getLocale(Matcher) obtain from the #patternAll
matched in a bundle path, the corresponding locale.
The class offer also a static method valueOf(Locale) to obtain the
scope of a locale.- Author:
- Tony Chemit - chemit@codelutin.com
-
Nested Class Summary
-
Enum Constant Summary
-
Method Summary
Modifier and Type Method Description java.lang.StringgetBundlePrefix(java.util.regex.Matcher matcher)abstract java.util.LocalegetLocale(java.util.regex.Matcher matcher)get the locale for a given matcher.java.util.regex.MatchergetMatcher(java.lang.String path)get a matcher fro the given path for this scopestatic I18nBundleScopevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static I18nBundleScopevalueOf(java.util.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 Details
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
valueOf
Obtain the scope of a givenlocale. The given locale can be null, which meansGENERALscope.- Parameters:
locale- given locale to convert- Returns:
- the scope of given locale
-
getMatcher
public java.util.regex.Matcher getMatcher(java.lang.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 java.util.Locale getLocale(java.util.regex.Matcher matcher)get the locale for a given matcher.- Parameters:
matcher- the scope matcher to use- Returns:
- the locale
-
getBundlePrefix
public java.lang.String getBundlePrefix(java.util.regex.Matcher matcher)- Parameters:
matcher- the scope matcher to use- Returns:
- the prefix of the bundle
-