Package com.ibm.icu.util
Class LocaleMatcher.Result
- java.lang.Object
-
- com.ibm.icu.util.LocaleMatcher.Result
-
- Enclosing class:
- LocaleMatcher
public static final class LocaleMatcher.Result extends Object
Data for the best-matching pair of a desired and a supported locale.- Status:
- Stable ICU 65.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getDesiredIndex()
Returns the index of the best-matching desired locale in the input Iterable orderLocale
getDesiredLocale()
Returns the best-matching desired locale.ULocale
getDesiredULocale()
Returns the best-matching desired locale.int
getSupportedIndex()
Returns the index of the best-matching supported locale in the constructor’s or builder’s input order (“set” Collection plus “added” locales).Locale
getSupportedLocale()
Returns the best-matching supported locale.ULocale
getSupportedULocale()
Returns the best-matching supported locale.Locale
makeResolvedLocale()
Takes the best-matching supported locale and adds relevant fields of the best-matching desired locale, such as the -t- and -u- extensions.ULocale
makeResolvedULocale()
Takes the best-matching supported locale and adds relevant fields of the best-matching desired locale, such as the -t- and -u- extensions.
-
-
-
Method Detail
-
getDesiredULocale
public ULocale getDesiredULocale()
Returns the best-matching desired locale. null if the list of desired locales is empty or if none matched well enough.- Returns:
- the best-matching desired locale, or null.
- Status:
- Stable ICU 65.
-
getDesiredLocale
public Locale getDesiredLocale()
Returns the best-matching desired locale. null if the list of desired locales is empty or if none matched well enough.- Returns:
- the best-matching desired locale, or null.
- Status:
- Stable ICU 65.
-
getSupportedULocale
public ULocale getSupportedULocale()
Returns the best-matching supported locale. If none matched well enough, this is the default locale. The default locale is null ifLocaleMatcher.Builder.setNoDefaultLocale()
was called, or if the list of supported locales is empty and no explicit default locale is set.- Returns:
- the best-matching supported locale, or null.
- Status:
- Stable ICU 65.
-
getSupportedLocale
public Locale getSupportedLocale()
Returns the best-matching supported locale. If none matched well enough, this is the default locale. The default locale is null ifLocaleMatcher.Builder.setNoDefaultLocale()
was called, or if the list of supported locales is empty and no explicit default locale is set.- Returns:
- the best-matching supported locale, or null.
- Status:
- Stable ICU 65.
-
getDesiredIndex
public int getDesiredIndex()
Returns the index of the best-matching desired locale in the input Iterable order. -1 if the list of desired locales is empty or if none matched well enough.- Returns:
- the index of the best-matching desired locale, or -1.
- Status:
- Stable ICU 65.
-
getSupportedIndex
public int getSupportedIndex()
Returns the index of the best-matching supported locale in the constructor’s or builder’s input order (“set” Collection plus “added” locales). If the matcher was built from a locale list string, then the iteration order is that of a LocalePriorityList built from the same string. -1 if the list of supported locales is empty or if none matched well enough.- Returns:
- the index of the best-matching supported locale, or -1.
- Status:
- Stable ICU 65.
-
makeResolvedULocale
public ULocale makeResolvedULocale()
Takes the best-matching supported locale and adds relevant fields of the best-matching desired locale, such as the -t- and -u- extensions. May replace some fields of the supported locale. The result is the locale that should be used for date and number formatting, collation, etc. Returns null if getSupportedLocale() returns null.Example: desired=ar-SA-u-nu-latn, supported=ar-EG, resolved locale=ar-SA-u-nu-latn
- Returns:
- a locale combining the best-matching desired and supported locales.
- Status:
- Stable ICU 65.
-
makeResolvedLocale
public Locale makeResolvedLocale()
Takes the best-matching supported locale and adds relevant fields of the best-matching desired locale, such as the -t- and -u- extensions. May replace some fields of the supported locale. The result is the locale that should be used for date and number formatting, collation, etc. Returns null if getSupportedLocale() returns null.Example: desired=ar-SA-u-nu-latn, supported=ar-EG, resolved locale=ar-SA-u-nu-latn
- Returns:
- a locale combining the best-matching desired and supported locales.
- Status:
- Stable ICU 65.
-
-