public class LocalizedOptionValueProvider extends java.lang.Object implements PredefinedValuesValueProvider
OptionValueProvider
providing localized value titles for a given set of predefined values.
Use addValue(String)
to add all values that this provider should provider.
The value provider is given some name which is used in localized information lookup.
The bundles retrieved by the given bundle loader in the constructor are expected to contain the following label keys with localized information for each provided value:
Constructor and Description |
---|
LocalizedOptionValueProvider(java.lang.String optionName,
LocalisationBundleLoader loader) |
Modifier and Type | Method and Description |
---|---|
void |
addValue(java.lang.String value) |
void |
addValue(java.lang.String value,
java.lang.String title)
Add a value to provide
|
java.lang.String |
getEmptyListMessage(java.util.Locale locale)
Returns a - maybe localized - message to display when the list of provided values is empty
|
java.util.List<java.lang.String> |
getProvidedValues()
Returns the possible/allowed values
|
java.lang.String |
getValueTitle(java.lang.String value,
java.util.Locale locale)
Returns a - maybe localized - title for a given value
|
public LocalizedOptionValueProvider(java.lang.String optionName, LocalisationBundleLoader loader)
optionName
- Some name of this value provider used to lookup localized labels in the bundle loaderloader
- The bundle loader to load localized information frompublic java.util.List<java.lang.String> getProvidedValues()
OptionValueProvider
getProvidedValues
in interface OptionValueProvider
public java.lang.String getValueTitle(java.lang.String value, java.util.Locale locale)
OptionValueProvider
getValueTitle
in interface OptionValueProvider
value
- The valuelocale
- The locale for localisationpublic void addValue(java.lang.String value, java.lang.String title)
PredefinedValuesValueProvider
addValue
in interface PredefinedValuesValueProvider
value
- The stored value to providetitle
- The title of the value, if needed for this provider. May be null if no title given or to be read from another source.public void addValue(java.lang.String value)
public java.lang.String getEmptyListMessage(java.util.Locale locale)
OptionValueProvider
getEmptyListMessage
in interface OptionValueProvider
locale
- The locale for localisation