Class LocaleIDParser


  • public final class LocaleIDParser
    extends Object
    Utility class to parse and normalize locale ids (including POSIX style)
    • Constructor Detail

      • LocaleIDParser

        public LocaleIDParser​(String localeID)
      • LocaleIDParser

        public LocaleIDParser​(String localeID,
                              boolean canonicalize)
    • Method Detail

      • getLanguage

        public String getLanguage()
        Returns the normalized language id, or the empty string.
      • getScript

        public String getScript()
        Returns the normalized script id, or the empty string.
      • getCountry

        public String getCountry()
        return the normalized country id, or the empty string.
      • getVariant

        public String getVariant()
        Returns the normalized variant id, or the empty string.
      • getLanguageScriptCountryVariant

        public String[] getLanguageScriptCountryVariant()
        Returns the language, script, country, and variant as separate strings.
      • setBaseName

        public void setBaseName​(String baseName)
      • parseBaseName

        public void parseBaseName()
      • getBaseName

        public String getBaseName()
        Returns the normalized base form of the locale id. The base form does not include keywords.
      • getName

        public String getName()
        Returns the normalized full form of the locale id. The full form includes keywords if they are present.
      • getKeywordMap

        public Map<String,​String> getKeywordMap()
        Returns a map of the keywords and values, or null if there are none.
      • getKeywords

        public Iterator<String> getKeywords()
        Returns an iterator over the keywords, or null if we have an empty map.
      • getKeywordValue

        public String getKeywordValue​(String keywordName)
        Returns the value for the named keyword, or null if the keyword is not present.
      • defaultKeywordValue

        public void defaultKeywordValue​(String keywordName,
                                        String value)
        Set the keyword value only if it is not already set to something else.
      • setKeywordValue

        public void setKeywordValue​(String keywordName,
                                    String value)
        Set the value for the named keyword, or unset it if value is null. If keywordName itself is null, unset all keywords. If keywordName is not null, value must not be null.