Package biz.aQute.bnd.reporter.helpers
Class LocaleHelper
- java.lang.Object
-
- biz.aQute.bnd.reporter.helpers.LocaleHelper
-
public class LocaleHelper extends java.lang.ObjectAn helper to extract localization data from a Jar.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Locale_localeprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>_localizations
-
Constructor Summary
Constructors Modifier Constructor Description privateLocaleHelper()privateLocaleHelper(Jar jar, java.util.Locale locale, java.lang.String basePath)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.LocalecomputeNextLocale(java.util.Locale nextLocale)static LocaleHelpercreateIfPresent(Jar jar, java.util.Locale locale, java.lang.String basePath)Create aLocaleHelperif localization data are found at the specified path, otherwise returnnull.static LocaleHelperempty()private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>extractLocalizations(Jar jar, java.lang.String path)java.lang.Stringget(java.lang.String variableOrValue)If the argument is a variable, its corresponding value will be returned for the default locale of this helper instance.java.lang.Stringget(java.lang.String variableOrValue, java.util.Locale locale)If the argument is a variable, its corresponding value will be returned for the specified locale.private static booleanhasLocalization(Jar jar, java.lang.String path)
-
-
-
Constructor Detail
-
LocaleHelper
private LocaleHelper(Jar jar, java.util.Locale locale, java.lang.String basePath)
-
LocaleHelper
private LocaleHelper()
-
-
Method Detail
-
createIfPresent
public static LocaleHelper createIfPresent(Jar jar, java.util.Locale locale, java.lang.String basePath)
Create aLocaleHelperif localization data are found at the specified path, otherwise returnnull.- Parameters:
jar- the jar containing the localization file, must not benulllocale- the default locale for this helper, must not benullbasePath- a base path in the Jar to the localization property files without its extension and its locale suffix, must not benull- Returns:
- a
LocaleHelperwhich contains localization data ornullif there is no localization data at the specified path.
-
empty
public static LocaleHelper empty()
- Returns:
- a
LocaleHelperwithout localization data, nevernull
-
get
public java.lang.String get(java.lang.String variableOrValue)
If the argument is a variable, its corresponding value will be returned for the default locale of this helper instance. Otherwise, the argument is returned.Values will be search from the most specific to the less specific locale including unlocalized (empty locale) value.
- Parameters:
variableOrValue- a variable (starting with '%') or a value, can benull- Returns:
- the localized value, can be
null
-
get
public java.lang.String get(java.lang.String variableOrValue, java.util.Locale locale)If the argument is a variable, its corresponding value will be returned for the specified locale. Otherwise, the argument is returned.Values will be search from the most specific to the less specific locale including unlocalized (empty locale) value.
- Parameters:
variableOrValue- a variable (starting with '%') or a value, can benulllocale- the locale, must not benull- Returns:
- the localized value, can be
null
-
computeNextLocale
private java.util.Locale computeNextLocale(java.util.Locale nextLocale)
-
hasLocalization
private static boolean hasLocalization(Jar jar, java.lang.String path)
-
extractLocalizations
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> extractLocalizations(Jar jar, java.lang.String path)
-
-