Class LocalePriorityList.Builder

java.lang.Object
com.ibm.icu.util.LocalePriorityList.Builder
Enclosing class:
LocalePriorityList

public static class LocalePriorityList.Builder extends Object
Class used for building LocalePriorityLists.
  • Method Details

    • build

      public LocalePriorityList build()
      Creates a LocalePriorityList. This is equivalent to Builder.build(false).
      Returns:
      A LocalePriorityList
    • build

      public LocalePriorityList build(boolean preserveWeights)
      Creates a LocalePriorityList.
      Parameters:
      preserveWeights - when true, each locale's given weight is preserved.
      Returns:
      A LocalePriorityList
    • add

      Adds locales with weights.
      Parameters:
      list - list of locales with weights
      Returns:
      this, for chaining
    • add

      public LocalePriorityList.Builder add(ULocale locale)
      Adds a locale with weight 1.0.
      Parameters:
      locale - to add with weight 1.0
      Returns:
      this, for chaining
    • add

      public LocalePriorityList.Builder add(ULocale... locales)
      Adds locales, each with weight 1.0.
      Parameters:
      locales - locales/languages to be added
      Returns:
      this, for chaining.
    • add

      public LocalePriorityList.Builder add(ULocale locale, double weight)
      Adds a locale with a specified weight. Overrides any previous weight for the locale. A zero or negative weight leads to removing the locale. A weight greater than 1 is pinned to 1.
      Parameters:
      locale - language/locale to add
      weight - value between 0.0 and 1.1
      Returns:
      this, for chaining.
    • add

      public LocalePriorityList.Builder add(String acceptLanguageList)
      Parses the RFC 2616 string, and adds locales with weights accordingly.
      Parameters:
      acceptLanguageList - in RFC 2616 format (leniently parsed)
      Returns:
      this, for chaining.