Class LocalizedString

java.lang.Object
se.swedenconnect.opensaml.common.utils.LocalizedString

public class LocalizedString extends Object
Utility class for a localized string.
Author:
Martin Lindström (martin@idsec.se)
See Also:
  • Field Details

  • Constructor Details

    • LocalizedString

      public LocalizedString()
      Default constructor.
    • LocalizedString

      public LocalizedString(String source)
      Creates an instance by parsing the source string that must be on the format <lang-tag>-<string according to language>. The string "en-Hello" will give a LocalizedString where:
      
       ls.getLanguage() => "en"
       ls.getLocalString() => "Hello"
       
      Parameters:
      source - the string to parse
    • LocalizedString

      public LocalizedString(String localString, String language)
      Constructor.
      Parameters:
      localString - the localized string
      language - the language of the string
    • LocalizedString

      public LocalizedString(String localString, Locale locale)
      Constructor.
      Parameters:
      localString - the localized string
      locale - the locale (the language is obtained using Locale.getLanguage())
  • Method Details

    • getLocalString

      public String getLocalString()
      Gets the localized string.
      Returns:
      the localized string
    • setLocalizedString

      public void setLocalizedString(String newString)
      Sets the localized string.
      Parameters:
      newString - the localized string
    • getLanguage

      public String getLanguage()
      Gets the language of the string.
      Returns:
      the language of the string
    • setLanguage

      public void setLanguage(String newLanguage)
      Sets the language of the string.
      Parameters:
      newLanguage - the language of the string
    • hashCode

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

      public boolean equals(Object obj)
      Determines if two LocalizedStrings are equal, that is, if both thier localized string and language have case-sentivite equality.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object this object is compared with
      Returns:
      true if the objects are equal, false if not
    • toString

      public String toString()
      Overrides:
      toString in class Object