Class LocaleString

java.lang.Object
com.appiancorp.suiteapi.common.LocaleString
All Implemented Interfaces:
Serializable, Cloneable

public final class LocaleString extends Object implements 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 Details

    • LocaleString

      public LocaleString()
    • LocaleString

      public LocaleString(Locale locale, String text)
    • LocaleString

      public LocaleString(String overall)
  • Method Details

    • get

      public final String get(Locale locale)
      Parameters:
      locale -
      Returns:
      text for the given locale, or insensitive text if this LocaleString is not sensitive to Locale
    • get

      public final String get(String locale)
      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

      public final String retrieveValueForUserLocaleOrPrimary(Locale userLocale, Locale primaryLocale)
      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

      public final String retrieveValueForLocaleOrFirstAvailable(Locale targetLocale)
      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, returns null.
    • put

      public final void put(String text)
      Parameters:
      text - replacing all sensitive text with this text insensitive to Locale (similar to plain String)
    • put

      public final void put(Locale locale, String text)
      Parameters:
      locale - under which to place this text
      text - associated with this given locale
    • put

      public final void put(String locale, String text)
    • toEncodedString

      public final String toEncodedString()
      Returns:
      the encoded representation of the mappings contained in this object.
    • getLocales

      public Set<Locale> 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

      public String toString()
      Returns a string representation of the given LocaleString object. The returned string representation is suitable for logging or debugging. This should NOT be used for outputting the string to the end-user.
      Overrides:
      toString in class Object
    • 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

      public String getLocalizeExpressionString()
      Returns:
      the String representation of the localize expression-function used to validate LocaleString objects that contain expressions in its mappings.
    • getStringLocales

      public Set<String> getStringLocales()
    • containsLocale

      public boolean containsLocale(Locale locale_)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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

      public LocaleString clone()
      Clone this LocaleString; the result will have its own locale sensitive map.
      Overrides:
      clone in class Object
    • 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.