Package com.appiancorp.suiteapi.common
Class LocaleString
java.lang.Object
com.appiancorp.suiteapi.common.LocaleString
- All Implemented Interfaces:
Serializable
,Cloneable
LocaleString
LocaleString represents one String with representations in one or more Locales, or in all Locales (an insensitive String).
This may be output or input as a single encoded String, using escapes.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone this LocaleString; the result will have its own locale sensitive map.boolean
containsLocale
(Locale locale_) boolean
final String
final String
Get the Locale keys for this LocaleString.int
hashCode()
boolean
boolean
boolean
final void
final void
final void
final String
retrieveValueForLocaleOrFirstAvailable
(Locale targetLocale) Returns the localized value for the given locale, if available.final String
retrieveValueForUserLocaleOrPrimary
(Locale userLocale, SiteLocaleSettings sls) Deprecated.This method will be removed in a future release.final String
retrieveValueForUserLocaleOrPrimary
(Locale userLocale, Locale primaryLocale) Returns the localized value for the user's locale, if available.int
Method that calculates the "structural" hash code, which is the true hash code of the contents of this object.final String
toString()
Returns a string representation of the givenLocaleString
object.
-
Constructor Details
-
LocaleString
public LocaleString() -
LocaleString
-
LocaleString
-
-
Method Details
-
get
- Parameters:
locale
-- Returns:
- text for the given locale, or insensitive text if this LocaleString is not sensitive to Locale
-
get
- Parameters:
locale
-- Returns:
- text for the given locale, or insensitive text if this LocaleString is not sensitive to Locale
-
retrieveValueForUserLocaleOrPrimary
@Deprecated public final String retrieveValueForUserLocaleOrPrimary(Locale userLocale, SiteLocaleSettings sls) Deprecated.This method will be removed in a future release. Use retrieveValueForUserLocaleOrPrimary(Locale, Locale) instead.Returns the localized value for the user's locale, if available. If the value is not available in the user's locale, it falls back to the site's primary locale. -
retrieveValueForUserLocaleOrPrimary
Returns the localized value for the user's locale, if available. If the value is not available in the user's locale, it falls back to the site's primary locale. -
retrieveValueForLocaleOrFirstAvailable
Returns the localized value for the given locale, if available. If the value is not available in the given locale, returns the first available value. If there are no values at all, returnsnull
. -
put
- Parameters:
text
- replacing all sensitive text with this text insensitive to Locale (similar to plain String)
-
put
- Parameters:
locale
- under which to place this texttext
- associated with this given locale
-
put
-
toEncodedString
- Returns:
- the encoded representation of the mappings contained in this object.
-
getLocales
Get the Locale keys for this LocaleString.- Returns:
- Set of Locales stored in this LocaleString, which may be empty for LocaleStrings insensitive to Locale
- Throws:
IllegalStateException
- if an invalid Locale is encountered
-
toString
Returns a string representation of the givenLocaleString
object. The returned string representation is suitable for logging or debugging. This should NOT be used for outputting the string to the end-user. -
isNullOrEmpty
public boolean isNullOrEmpty()- Returns:
- true if this LocaleString has no locales with associated text, or insensitive to Locale with empty string
-
isExpression
public boolean isExpression()- Returns:
- if this LocaleString contains an expression as part of its locale mappings.
-
getLocalizeExpressionString
- Returns:
- the String representation of the localize expression-function used to validate LocaleString objects that contain expressions in its mappings.
-
getStringLocales
-
containsLocale
-
equals
-
hashCode
public int hashCode() -
structuralHashCode
public int structuralHashCode()Method that calculates the "structural" hash code, which is the true hash code of the contents of this object. The value will be calculated only once and cached, since this method should only be used in a SAIL context where LocaleString instances are immutable. If the value is mutated afterwards this method will return an incorrect value. -
clone
Clone this LocaleString; the result will have its own locale sensitive map. -
isSensitiveToLocale
public boolean isSensitiveToLocale()- Returns:
- Is this LocaleString sensitive to input locale, that is, has it been loaded with Locale sensitive data, e.g., by put(Locale,String)? If not, then all get(Locale) will return the same results.
-