Class LocaleUtils


  • public class LocaleUtils
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  LocaleUtils.Match  
    • Constructor Summary

      Constructors 
      Constructor Description
      LocaleUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Locale getLocale​(java.lang.String localeString)
      Returns a Locale from a locale string.
      static boolean localeMatches​(java.util.Locale[] availableLocales, java.util.Locale locale)  
      (package private) static boolean localMatches​(java.util.Locale requested, LocaleUtils.Match matchLevel, java.util.Locale... available)
      Returns whether a locale is matched by one of more other locales.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocaleUtils

        public LocaleUtils()
    • Method Detail

      • getLocale

        public static java.util.Locale getLocale​(java.lang.String localeString)
                                          throws ParseException
        Returns a Locale from a locale string. Each locale is specified by a language identifier, possibly country identifier, and possibly a variant. The syntax is as follows:
         locale ::= language [ "_" country [ "_" variant ] ]
         
        Parameters:
        localeString - the locale string
        Returns:
        locale of document
        Throws:
        ParseException
      • localeMatches

        public static boolean localeMatches​(java.util.Locale[] availableLocales,
                                            java.util.Locale locale)
      • localMatches

        static boolean localMatches​(java.util.Locale requested,
                                    LocaleUtils.Match matchLevel,
                                    java.util.Locale... available)
        Returns whether a locale is matched by one of more other locales. Only the non-empty language, country, and variant codes are compared; for example, a requested locale of Locale("","","") would always return true.
        Parameters:
        requested - the requested locale
        matchLevel - the depth with which to match locales.
        available - the available locales
        Returns:
        true if requested matches any of available, or if available is empty or null.
        See Also:
        Locale, LocaleUtils.Match