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 java.lang.Object
Data for the best-matching pair of a desired and a supported locale.
-
-
Field Summary
Fields Modifier and Type Field Description private int
desiredIndex
private java.util.Locale
desiredLocale
private ULocale
desiredULocale
private int
supportedIndex
private java.util.Locale
supportedLocale
private ULocale
supportedULocale
-
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 order.java.util.Locale
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).java.util.Locale
getSupportedLocale()
Returns the best-matching supported locale.ULocale
getSupportedULocale()
Returns the best-matching supported locale.java.util.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.
-
-
-
Field Detail
-
desiredULocale
private final ULocale desiredULocale
-
supportedULocale
private final ULocale supportedULocale
-
desiredLocale
private final java.util.Locale desiredLocale
-
supportedLocale
private final java.util.Locale supportedLocale
-
desiredIndex
private final int desiredIndex
-
supportedIndex
private final int supportedIndex
-
-
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.
-
getDesiredLocale
public java.util.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.
-
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.
-
getSupportedLocale
public java.util.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.
-
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.
-
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.
-
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.
-
makeResolvedLocale
public java.util.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.
-
-