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.
  • Method Details

    • 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 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 if LocaleMatcher.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 Locale getSupportedLocale()
      Returns the best-matching supported locale. If none matched well enough, this is the default locale. The default locale is null if LocaleMatcher.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 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.