Class LocaleFormatter

java.lang.Object
com.appiancorp.suiteapi.common.exceptions.LocaleFormatter
All Implemented Interfaces:
AppianErrorCodeStaticMessageFormatter, AppianErrorCodeTitleFormatter, AppianErrorCodeFormatter

ErrorCodeFormatter based upon a Locale.
  • Constructor Details

    • LocaleFormatter

      public LocaleFormatter(Locale locale)
  • Method Details

    • format

      public String format(AppianErrorCode errorCode, Object... arguments)
      Specified by:
      format in interface AppianErrorCodeFormatter
    • formatTitle

      public String formatTitle(AppianErrorCode errorCode, Object... arguments)
      Returns the localized title, rendered with the included arguments if the error title supports them. If the title does not exist, the method returns "".
      Specified by:
      formatTitle in interface AppianErrorCodeTitleFormatter
      Parameters:
      errorCode - The code corresponding to the thrown exception
      arguments - Additional parameters required to render the title
      Returns:
      The title, localized and rendered with the included arguments where applicable.
    • formatStaticMessage

      public String formatStaticMessage(AppianErrorCode errorCode)
      Returns the localized static message if it exists. Note that currently only ErrorCode objects have staticMessage set
      Specified by:
      formatStaticMessage in interface AppianErrorCodeStaticMessageFormatter
      Parameters:
      errorCode - The code corresponding to the thrown exception
      Returns:
      The static message, localized.
    • getStaticMessageFromErrorCode

      public String getStaticMessageFromErrorCode(String errorCode)
      Returns the localized static message for a given error code string This method should NOT be used for strings that don't correspond to an ErrorCode (i.e. this will not work on ValidationCode)
      Specified by:
      getStaticMessageFromErrorCode in interface AppianErrorCodeStaticMessageFormatter
      Parameters:
      errorCode - string representation of an error code (should be equivalent to ErrorCode#toString)
      Returns:
      the localized static message for that error code
    • getText

      public static String getText(Class<?> clazz, Locale targetLocale, String key, Object[] params)
      Manually fetch error code text Useful in case that the locale is not available in context and error code is not automatically converted to correct locale text
    • getText

      public static String getText(Class<?> clazz, Locale targetLocale, String key)