public final class LocalizedString extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
LocalizedString.Value
A unmodifiable localized string value.
|
| Constructor and Description |
|---|
LocalizedString(Locale defaultLocale)
Build an empty localized string.
|
LocalizedString(Map<Locale,String> values,
Locale defaultLocale)
Build a localized string using a
|
LocalizedString(String defaultValue)
Convenience constructor for simple localized strings with only one value using the
Locale.ENGLISH locale. |
LocalizedString(String defaultValue,
Locale defaultLocale)
Convenience constructor for simple localized strings with only one value using the default locale.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
Locale |
getDefaultLocale()
Return the default locale of this localized string.
|
String |
getDefaultString()
Return the string for the default locale.
|
LocalizedString.Value |
getDefaultValue()
Returns the value for the default locale.
|
String |
getMostAppropriateValueFor(String[] desiredLocales)
Retrieves the localized value most appropriate based on the given desired locales.
|
LocalizedString.Value |
getPreferredOrBestLocalizedMappingFor(String[] desiredLocales)
Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered
according to locale preferences.
|
String |
getString(Locale locale,
boolean resolve)
Returns a string value.
|
LocalizedString.Value |
getValue(Locale locale,
boolean resolve)
Returns a localized value.
|
Map<Locale,LocalizedString.Value> |
getValues() |
int |
hashCode() |
boolean |
hasValues()
Determines if this LocalizedString contains any values.
|
String |
toString() |
public LocalizedString(String defaultValue) throws IllegalArgumentException
Locale.ENGLISH locale.defaultValue - the localized value using the specified default localeIllegalArgumentException - if no default value or locale is providedpublic LocalizedString(String defaultValue, Locale defaultLocale) throws IllegalArgumentException
defaultValue - the localized value using the specified default localedefaultLocale - the default localeIllegalArgumentException - if no default value or locale is providedpublic LocalizedString(Locale defaultLocale) throws IllegalArgumentException
defaultLocale - the default localeIllegalArgumentException - if no default locale is providedpublic LocalizedString(Map<Locale,String> values, Locale defaultLocale) throws IllegalArgumentException
values - the defaultLocale - the default localeIllegalArgumentException - if one argument if null or if the map entries are different from public boolean hasValues()
true if this LocalizedString contains localized values, false otherwise.public String getDefaultString()
public LocalizedString.Value getDefaultValue()
public String getString(Locale locale, boolean resolve)
locale - the desired localeresolve - true if the locale must be resolved to the most appropriatepublic LocalizedString.Value getValue(Locale locale, boolean resolve)
locale - the desired localeresolve - true if the locale must be resolved to the most appropriatepublic Map<Locale,LocalizedString.Value> getValues()
public Locale getDefaultLocale()
public String getMostAppropriateValueFor(String[] desiredLocales) throws IllegalArgumentException
desiredLocales - an array of compound language tags (as defined by IETF
RFC 3066) ordered according to locale preferences.IllegalArgumentException - if the array is null or one of the array string is null or invalid (see
#getLocaleFromRFC3066LanguageTag(String))public LocalizedString.Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
desiredLocales - an array of compound language tags (as defined by IETF
RFC 3066) ordered according to locale preferences.IllegalArgumentException - if the array is null or one of the array string is null or invalid (see LocaleFormat#RFC3066_LANGUAGE_TAG#getLocale(String)Copyright © 2025 JBoss by Red Hat. All Rights Reserved.