Class LocaleMatcher.Builder

    • Method Detail

      • setSupportedLocales

        public LocaleMatcher.Builder setSupportedLocales​(java.lang.String locales)
        Parses the string like LocalePriorityList does and sets the supported locales accordingly. Clears any previously set/added supported locales first.
        Parameters:
        locales - the string of locales to set, to be parsed like LocalePriorityList does
        Returns:
        this Builder object
      • setSupportedULocales

        public LocaleMatcher.Builder setSupportedULocales​(java.util.Collection<ULocale> locales)
        Copies the supported locales, preserving iteration order. Clears any previously set/added supported locales first. Duplicates are allowed, and are not removed.
        Parameters:
        locales - the list of locales
        Returns:
        this Builder object
      • setSupportedLocales

        public LocaleMatcher.Builder setSupportedLocales​(java.util.Collection<java.util.Locale> locales)
        Copies the supported locales, preserving iteration order. Clears any previously set/added supported locales first. Duplicates are allowed, and are not removed.
        Parameters:
        locales - the list of locale
        Returns:
        this Builder object
      • addSupportedULocale

        public LocaleMatcher.Builder addSupportedULocale​(ULocale locale)
        Adds another supported locale. Duplicates are allowed, and are not removed.
        Parameters:
        locale - another locale
        Returns:
        this Builder object
      • addSupportedLocale

        public LocaleMatcher.Builder addSupportedLocale​(java.util.Locale locale)
        Adds another supported locale. Duplicates are allowed, and are not removed.
        Parameters:
        locale - another locale
        Returns:
        this Builder object
      • setDefaultULocale

        public LocaleMatcher.Builder setDefaultULocale​(ULocale defaultLocale)
        Sets the default locale; if null, or if it is not set explicitly, then the first supported locale is used as the default locale.
        Parameters:
        defaultLocale - the default locale
        Returns:
        this Builder object
      • setDefaultLocale

        public LocaleMatcher.Builder setDefaultLocale​(java.util.Locale defaultLocale)
        Sets the default locale; if null, or if it is not set explicitly, then the first supported locale is used as the default locale.
        Parameters:
        defaultLocale - the default locale
        Returns:
        this Builder object
      • setFavorSubtag

        public LocaleMatcher.Builder setFavorSubtag​(LocaleMatcher.FavorSubtag subtag)
        If SCRIPT, then the language differences are smaller than script differences. This is used in situations (such as maps) where it is better to fall back to the same script than a similar language.
        Parameters:
        subtag - the subtag to favor
        Returns:
        this Builder object
      • setDemotionPerDesiredLocale

        public LocaleMatcher.Builder setDemotionPerDesiredLocale​(LocaleMatcher.Demotion demotion)
        Option for whether all desired locales are treated equally or earlier ones are preferred (this is the default).
        Parameters:
        demotion - the demotion per desired locale to set.
        Returns:
        this Builder object
      • setDirection

        public LocaleMatcher.Builder setDirection​(LocaleMatcher.Direction direction)
        Option for whether to include or ignore one-way (fallback) match data. By default, they are included.
        Parameters:
        direction - the match direction to set.
        Returns:
        this Builder object
      • internalSetThresholdDistance

        @Deprecated
        public LocaleMatcher.Builder internalSetThresholdDistance​(int thresholdDistance)
        Deprecated.
        This API is ICU internal only.
        Internal only!
        Parameters:
        thresholdDistance - the thresholdDistance to set, with -1 = default
        Returns:
        this Builder object
      • build

        public LocaleMatcher build()
        Builds and returns a new locale matcher. This builder can continue to be used.
        Returns:
        new LocaleMatcher.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object