Class LanguageMap

All Implemented Interfaces:
Serializable, Cloneable, Map<Locale,String>

public class LanguageMap extends LinkedHashMap<Locale,String>
A language map is a dictionary where the key is a RFC 5646 Language Tag, and the value is a string in the language specified in the tag.
Author:
Thomas Turrell-Croft
See Also:
  • Constructor Details

    • LanguageMap

      public LanguageMap()
      Constructs an empty LanguageMap.
    • LanguageMap

      public LanguageMap(Map<Locale,String> languageMap)
      Constructs an new LanguageMap with the same mappings as the specified Map.
      Parameters:
      languageMap - the map whose mappings are to be placed in this LanguageMap
  • Method Details

    • put

      public void put(String value)
      Puts a value in the language map with the undefined locale as a key. If the language map previously contained a mapping for the undefined locale, the old value is replaced.
      Parameters:
      value - to be added with the undefined locale as a key
    • get

      public String get(List<Locale.LanguageRange> languageRanges)

      Returns the value which best matches one of the specified language ranges.

      The return value could be:

      1. Best matching locale key using the lookup mechanism defined in RFC 4647
      2. Locale with undefined language key
      3. First value in language map
      4. null

      Note: This helper method is not defined in the xAPI specification.

      Parameters:
      languageRanges - used for matching a locale key
      Returns:
      the value which best matches one of the specified language ranges, or null if this map is empty