Class LocalePriorityList.Builder

  • Enclosing class:
    LocalePriorityList

    public static class LocalePriorityList.Builder
    extends java.lang.Object
    Class used for building LocalePriorityLists.
    • Method Detail

      • build

        public LocalePriorityList build​(boolean preserveWeights)
        Creates a LocalePriorityList.
        Parameters:
        preserveWeights - when true, each locale's given weight is preserved.
        Returns:
        A LocalePriorityList
      • 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​(java.lang.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.