Class MLText
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.util.Locale,java.lang.String>
-
- org.alfresco.service.cmr.repository.MLText
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.util.Locale,java.lang.String>
public class MLText extends java.util.HashMap<java.util.Locale,java.lang.String>Class to represent a multilingual (ML) text value.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
HashMapwith a few convenience methods.- Author:
- Philippe Dubois, Derek Hulley
- See Also:
- ISO639-2, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddValue(java.util.Locale locale, java.lang.String value)Add a multilingual text valuejava.lang.StringgetClosestValue(java.util.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 theconstructorAn arbitrary value nulljava.lang.StringgetDefaultValue()Retrieves a default value from the set of available locales.java.util.Set<java.util.Locale>getLocales()java.lang.StringgetValue(java.util.Locale locale)Retrieve a multilingual text valuejava.util.Collection<java.lang.String>getValues()voidremoveValue(java.util.Locale locale)Remove a multilingual text value-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Constructor Detail
-
MLText
public MLText()
-
MLText
public MLText(java.lang.String value)
Construct an instance with a value corresponding to the current context locale.- Parameters:
value- the value for the current default locale- See Also:
I18NUtil.getLocale(),MLText(Locale, String),getDefaultValue()
-
MLText
public MLText(java.util.Locale locale, java.lang.String value)Construct an instance with a value for the given locale.- Parameters:
locale- the localevalue- the value- See Also:
getDefaultValue()
-
-
Method Detail
-
getLocales
public java.util.Set<java.util.Locale> getLocales()
- Returns:
- Returns all the language locales defined in the text
-
getValues
public java.util.Collection<java.lang.String> getValues()
- Returns:
- Returns all the values stored
-
addValue
public void addValue(java.util.Locale locale, java.lang.String value)Add a multilingual text value- Parameters:
locale- the language localevalue- the multilingual text
-
getValue
public java.lang.String getValue(java.util.Locale locale)
Retrieve a multilingual text value- Parameters:
locale- the language locale
-
getDefaultValue
public java.lang.String getDefaultValue()
Retrieves a default value from the set of available locales.- See Also:
I18NUtil.getLocale(),getClosestValue(Locale)
-
getClosestValue
public java.lang.String getClosestValue(java.util.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
- Parameters:
locale- the locale to use as the starting point of the value search- Returns:
- Returns a default String value or null if one isn't available. null will only be returned if there are no values associated with this instance. With or without a match, the return value may be null, depending on the values associated with the locales.
-
removeValue
public void removeValue(java.util.Locale locale)
Remove a multilingual text value- Parameters:
locale- the language locale
-
-