Class AbstractI18nException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CommunicationException, ConfigurationException

@NonNullByDefault public abstract class AbstractI18nException extends RuntimeException
Provides an exception class for openHAB that incorporates support for internationalization
Author:
Laurent Garnier - Initial contribution
See Also:
  • Constructor Details

    • AbstractI18nException

      protected AbstractI18nException(String message, @Nullable Object @Nullable ... msgParams)
      Parameters:
      message - the exception message; use "@text/key" to reference "key" entry in the properties file
      msgParams - the optional arguments of the message defined in the properties file
    • AbstractI18nException

      protected AbstractI18nException(String message, @Nullable Throwable cause, @Nullable Object @Nullable ... msgParams)
      Parameters:
      message - the exception message; use "@text/key" to reference "key" entry in the properties file
      cause - the cause (which is saved for later retrieval by the getCause() method). A null value is permitted, and indicates that the cause is nonexistent or unknown.
      msgParams - the optional arguments of the message defined in the properties file
    • AbstractI18nException

      protected AbstractI18nException(Throwable cause)
      Parameters:
      cause - the cause (which is saved for later retrieval by the getCause() method).
  • Method Details

    • getMessage

      public @Nullable String getMessage(@Nullable org.osgi.framework.Bundle bundle, @Nullable TranslationProvider i18nProvider)
      Returns the detail message string of this exception. In case the message starts with "@text/" and the parameters bundle and i18nProvider are not null, the translation provider is used to look for the message key in the English properties file of the provided bundle.
      Parameters:
      bundle - the bundle containing the i18n properties
      i18nProvider - the translation provider
      Returns:
      the detail message string of this exception instance (which may be null)
    • getLocalizedMessage

      public @Nullable String getLocalizedMessage(@Nullable org.osgi.framework.Bundle bundle, @Nullable TranslationProvider i18nProvider, @Nullable Locale locale)
      Returns a localized description of this exception. In case the message starts with "@text/" and the parameters bundle and i18nProvider are not null, the translation provider is used to look for the message key in the properties file of the provided bundle containing strings for the requested language. English language is considered if no language is provided.
      Parameters:
      bundle - the bundle containing the i18n properties
      i18nProvider - the translation provider
      locale - the language to use for localizing the message
      Returns:
      the localized description of this exception instance (which may be null)
    • getRawMessage

      public @Nullable String getRawMessage()
      Provides the raw message If the message does not start with "@text/", it returns the same as the getMessage() method. If the message starts with "@text/" and no optional arguments are set, it returns a string of this kind: @text/key If the message starts with "@text/" and optional arguments are set, it returns a string of this kind: @text/key [ "param1", "param2" ]
      Returns:
      the raw message or null if the message is undefined