Class LocalizedString

java.lang.Object
com.inductiveautomation.ignition.common.i18n.LocalizedString
All Implemented Interfaces:
Localized, Serializable, Comparable<LocalizedString>

public class LocalizedString extends Object implements Localized, Serializable, Comparable<LocalizedString>
A special string container that holds a key, and returns the localized version of that key on toString(). At the time of creation, however, it stores the value of the key in the default locale, and returns that value should the key not be available later. This makes it possible to serialize and send this class to different scopes, where the key may or may not be available when it comes time to use it.

NOTE: In cases where a LocalizedString object is required, but the value isn't actually localizable, you can use the static createRaw() function.

See Also:
  • Constructor Details

    • LocalizedString

      public LocalizedString()
      JavaBean compatibility...
    • LocalizedString

      public LocalizedString(String key, Object... params)
      Constructs a LocalizedString with the default locale.
      Parameters:
      key - The translation key.
      params - Optional parameters for string formatting.
    • LocalizedString

      public LocalizedString(Locale defaultLocale, String key, Object... params)
      Constructs a LocalizedString with a specific default locale.
      Parameters:
      defaultLocale - The locale to use for the initial default value.
      key - The translation key.
      params - Optional parameters for string formatting.
  • Method Details

    • createRaw

      public static LocalizedString createRaw(String stringVal)
      Creates a localized string not based on a key.
      Parameters:
      stringVal - The raw string value to use.
      Returns:
      A LocalizedString that always returns the provided stringVal, as it's not associated with a translation key.
    • getKey

      public String getKey()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(LocalizedString other)
      Specified by:
      compareTo in interface Comparable<LocalizedString>
    • toString

      public String toString(Locale locale)
      Returns the localized version of the string for the given locale.
      Specified by:
      toString in interface Localized
      Parameters:
      locale - The locale to use for translation.
      Returns:
      The localized string if the key exists, otherwise the default value.
    • getDefaultVal

      public String getDefaultVal()
    • setDefaultVal

      public void setDefaultVal(String defaultVal)
    • getParams

      public Object[] getParams()
    • setParams

      public void setParams(Object[] params)
    • setKey

      public void setKey(String key)
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object