Enum LocaleMatcher

  • All Implemented Interfaces:
    Serializable, Comparable<LocaleMatcher>, Key

    public enum LocaleMatcher
    extends Enum<LocaleMatcher>
    implements Key
    The list of locales specified by the locales argument, after Unicode extensions have been removed from them, is interpreted as a prioritized request from the application.
    The runtime compares it against the locales it has available and picks the best one available.
    Two matching algorithms exist, "lookup" and "best fit".
    Author:
    Andrea "Stock" Stocchero
    • Enum Constant Detail

      • LOOKUP

        public static final LocaleMatcher LOOKUP
        Used to select the single language tag that best matches the language priority list for a given request.
        When performing lookup, each language range in the language priority list is considered in turn, according to priority.
        By contrast with filtering, each language range represents the most specific tag that is an acceptable match.

        See BCP 47 for more details.
      • BEST_FIT

        public static final LocaleMatcher BEST_FIT
        Lets the runtime provide a locale that's at least, but possibly more, suited for the request than the result of the Lookup algorithm.
    • Method Detail

      • values

        public static LocaleMatcher[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (LocaleMatcher c : LocaleMatcher.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static LocaleMatcher valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • value

        public String value()
        Description copied from interface: Key
        Returns the name value of property
        Specified by:
        value in interface Key
        Returns:
        the name value of property