Class MultilingualText

java.lang.Object
com.aquima.interactions.foundation.text.MultilingualText
All Implemented Interfaces:
IMultilingualText, Serializable

public class MultilingualText extends Object implements IMultilingualText
This implementation of IMultilingualText can be used to get the same String value returned independent of the language. In addition this object can contain different texts for different languages.
Since:
6.4
Author:
F. van der Meer, J. van Leuven
See Also:
  • Constructor Details

    • MultilingualText

      public MultilingualText()
      Creates a new empty multilingual text object without a default value.
    • MultilingualText

      public MultilingualText(String defaultText)
      Create a new MultiLanguageText object with the specified id.
      Parameters:
      defaultText - The default text that should be used when no text can be found for a specific language (optional).
  • Method Details

    • addContent

      public MultilingualText addContent(String code, String text)
      Add a new translation to this MultiLanguageText.
      Parameters:
      code - the language code of the added text.
      text - The actual text
      Returns:
      This pointer to allow method chaining.
    • getLanguageCodes

      public String[] getLanguageCodes()
      Description copied from interface: IMultilingualText
      Retrieves the language codes.
      Specified by:
      getLanguageCodes in interface IMultilingualText
      Returns:
      The text, can't return null.
    • getValue

      public String getValue(ILanguage language)
    • getValue

      public String getValue(ILanguage language, ILanguage fallbackLanguage)
    • getValue

      public String getValue(String languageCode)
      Description copied from interface: IMultilingualText
      Retrieves the text for the specified language code. If desired one can return a constant text independent of language code.
      Specified by:
      getValue in interface IMultilingualText
      Parameters:
      languageCode - never null
      Returns:
      The text, can return a null pointer.
    • getValue

      public String getValue(String languageCode, String fallbackLanguageCode)
      Description copied from interface: IMultilingualText
      Retrieves the text for the specified language code. If this text does not exist, the text of the fallback language code is being retrieved. If desired one can return a constant text independent of language code.
      Specified by:
      getValue in interface IMultilingualText
      Parameters:
      languageCode - never null
      fallbackLanguageCode - never null
      Returns:
      The text, can return a null pointer.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

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

      public String getDefaultText()
      Description copied from interface: IMultilingualText
      Returns the default text.
      Specified by:
      getDefaultText in interface IMultilingualText
      Returns:
      The default text, can be null.
    • setDefaultText

      public void setDefaultText(String defaultText)
      Sets the default text.
      Parameters:
      defaultText - The default text.