Class MessagesImpl

java.lang.Object
io.jmix.core.impl.MessagesImpl
All Implemented Interfaces:
Messages

@Component("core_Messages") public class MessagesImpl extends Object implements Messages
  • Field Details

    • messageSource

      @Autowired protected org.springframework.context.MessageSource messageSource
    • currentAuthentication

      @Autowired protected CurrentAuthentication currentAuthentication
  • Constructor Details

    • MessagesImpl

      public MessagesImpl()
  • Method Details

    • getMessage

      public String getMessage(String key)
      Description copied from interface: Messages
      Returns localized message.
      Locale is determined by the current user session.
      Specified by:
      getMessage in interface Messages
      Parameters:
      key - message key
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(String key, Locale locale)
      Description copied from interface: Messages
      Returns localized message.
      Specified by:
      getMessage in interface Messages
      Parameters:
      key - message key
      locale - message locale
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(Class caller, String key)
      Description copied from interface: Messages
      Returns localized message.
      Locale is determined by the current user session.
      Specified by:
      getMessage in interface Messages
      Parameters:
      caller - determines the message group as class' package name
      key - message key
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(Class caller, String key, Locale locale)
      Description copied from interface: Messages
      Returns localized message.
      Specified by:
      getMessage in interface Messages
      Parameters:
      caller - determines the message group as class' package name
      key - message key
      locale - message locale
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(Enum caller)
      Description copied from interface: Messages
      Returns localized message.
      Locale is determined by the current user session.
      Specified by:
      getMessage in interface Messages
      Parameters:
      caller - enum determining the message group and key:
      • group - enum's package name
      • key - enum's short class name (after last dot), plus dot, plus enum value
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(Enum caller, Locale locale)
      Description copied from interface: Messages
      Returns localized message.
      Specified by:
      getMessage in interface Messages
      Parameters:
      caller - enum determining the message group and key:
      • group - enum's package name
      • key - enum's short class name (after last dot), plus dot, plus enum value
      locale - message locale
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(String group, String key)
      Description copied from interface: Messages
      Returns localized message. Locale is determined by the current user session.
      Specified by:
      getMessage in interface Messages
      Parameters:
      group - message group
      key - message key
      Returns:
      localized message or the key if the message not found
    • getMessage

      public String getMessage(String group, String key, Locale locale)
      Description copied from interface: Messages
      Returns localized message.
      Specified by:
      getMessage in interface Messages
      Parameters:
      group - message group
      key - message key
      locale - message locale
      Returns:
      localized message or the key if the message not found
    • formatMessage

      public String formatMessage(Class caller, String key, Object... params)
      Description copied from interface: Messages
      Get localized message and use it as a format string for parameters provided.
      Locale is determined by the current user session.
      Specified by:
      formatMessage in interface Messages
      Parameters:
      caller - determines the message group as class' package name
      key - message key
      params - parameter values
      Returns:
      formatted string or the key in case of IllegalFormatException
    • formatMessage

      public String formatMessage(Class caller, String key, Locale locale, Object... params)
      Description copied from interface: Messages
      Get localized message and use it as a format string for parameters provided
      Specified by:
      formatMessage in interface Messages
      Parameters:
      caller - determines the message group as class' package name
      key - message key
      locale - message locale
      params - parameter values
      Returns:
      formatted string or the key in case of IllegalFormatException
    • formatMessage

      public String formatMessage(String group, String key, Object... params)
      Description copied from interface: Messages
      Get localized message and use it as a format string for parameters provided.
      Locale is determined by the current user session.
      Specified by:
      formatMessage in interface Messages
      Parameters:
      group - message group
      key - message key
      params - parameter values
      Returns:
      formatted string or the key in case of IllegalFormatException
    • formatMessage

      public String formatMessage(String group, String key, Locale locale, Object... params)
      Description copied from interface: Messages
      Get localized message and use it as a format string for parameters provided
      Specified by:
      formatMessage in interface Messages
      Parameters:
      group - message group
      key - message key
      locale - message locale
      params - parameter values
      Returns:
      formatted string or the key in case of IllegalFormatException
    • findMessage

      @Nullable public String findMessage(String key, @Nullable Locale locale)
      Description copied from interface: Messages
      Returns localized message or null if not found.
      Specified by:
      findMessage in interface Messages
      Parameters:
      key - message key
      locale - message locale. If null, current user locale is used.
      Returns:
      localized message or null if the message not found
    • findMessage

      @Nullable public String findMessage(String group, String key, @Nullable Locale locale)
      Description copied from interface: Messages
      Returns localized message or null if not found.
      Specified by:
      findMessage in interface Messages
      Parameters:
      group - message group
      key - message key
      locale - message locale. If null, current user locale is used.
      Returns:
      localized message or null if the message not found
    • clearCache

      public void clearCache()
      Specified by:
      clearCache in interface Messages
    • getCode

      protected String getCode(String group, String key)
    • getUserLocale

      protected Locale getUserLocale()
    • getDefaultLocale

      protected Locale getDefaultLocale()
    • getGroup

      protected String getGroup(Class c)
    • fallbackMessageOrKey

      protected String fallbackMessageOrKey(@Nullable String group, String key, Locale locale)
    • fallbackMessageOrNull

      @Nullable protected String fallbackMessageOrNull(@Nullable String group, String key, Locale locale)