public class MLText extends HashMap<Locale,String>
The language codes used should conform to the ISO639-2 language code standard, although there is no enforcement of the standard in this class.
This is a simple extension of a HashMap
with a few convenience methods.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
MLText() |
MLText(Locale locale,
String value)
Construct an instance with a value for the given locale.
|
MLText(String value)
Construct an instance with a value corresponding to the current context locale.
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(Locale locale,
String value)
Add a multilingual text value
|
String |
getClosestValue(Locale locale)
The given locale is used to search for a matching value according to:
An exact locale match
A match of locale ISO language codes
The value for the locale provided in the
constructor
An arbitrary value
null
|
String |
getDefaultValue()
Retrieves a default value from the set of available locales.
|
Set<Locale> |
getLocales() |
String |
getValue(Locale locale)
Retrieve a multilingual text value
|
Collection<String> |
getValues() |
void |
removeValue(Locale locale)
Remove a multilingual text value
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public MLText()
public MLText(String value)
value
- the value for the current default localeI18NUtil.getLocale()
,
MLText(Locale, String)
,
getDefaultValue()
public MLText(Locale locale, String value)
locale
- the localevalue
- the valuegetDefaultValue()
public Set<Locale> getLocales()
public Collection<String> getValues()
public void addValue(Locale locale, String value)
locale
- the language localevalue
- the multilingual textpublic String getValue(Locale locale)
locale
- the language localepublic String getDefaultValue()
I18NUtil.getLocale()
,
getClosestValue(Locale)
public String getClosestValue(Locale locale)
constructor
locale
- the locale to use as the starting point of the value searchpublic void removeValue(Locale locale)
locale
- the language localeCopyright © 2005–2017 Alfresco Software. All rights reserved.