Package dev.learning.xapi.model
Class LanguageMap
- All Implemented Interfaces:
Serializable,Cloneable,Map<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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty LanguageMap.LanguageMap(Map<Locale, String> languageMap) Constructs an new LanguageMap with the same mappings as the specified Map. -
Method Summary
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Constructor Details
-
LanguageMap
public LanguageMap()Constructs an empty LanguageMap. -
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
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
Returns the value which best matches one of the specified language ranges.
The return value could be:
- Best matching locale key using the lookup mechanism defined in RFC 4647
- Locale with undefined language key
- First value in language map
- 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
-