Class OBMessageUtils


  • public class OBMessageUtils
    extends Object
    • Constructor Detail

      • OBMessageUtils

        public OBMessageUtils()
    • Method Detail

      • messageBD

        public static String messageBD​(String strCode,
                                       boolean escape)
      • messageBD

        public static String messageBD​(String strCode)
        Translate the given code into some message from the application dictionary. It searches first in AD_Message table and if there are not matchings then in AD_Element table.
        Parameters:
        strCode - String with the search key to search.
        Returns:
        String with the translated message.
      • messageBD

        public static String messageBD​(String strCode,
                                       boolean ignoreCase,
                                       boolean escape)
        Parameters:
        strCode - String with the search key to search.
        ignoreCase - Ignore Case while finding message.
        escape - Escape \n and " characters
        Returns:
        String with the translated message.
      • messageBD

        public static String messageBD​(ConnectionProvider conn,
                                       String strCode,
                                       String strLanguage,
                                       boolean escape)
        Translate the given code into some message from the application dictionary.
        Parameters:
        conn - Handler for the database connection.
        strCode - String with the code to search.
        strLanguage - String with the translation language.
        escape - Escape \n and " characters
        Returns:
        String with the translated message.
      • formatMessageBDToHtml

        public static String formatMessageBDToHtml​(String message)
        Formats a message String into a String for html presentation. Escapes the &, <, >, " and ®, and replace the \n by <br/> and \r for space. IMPORTANT! : this method is designed to transform the output of Utility.messageBD method, and this method replaces \n by \\n and \" by &quote. Because of that, the first replacements revert this previous replacements.
        Parameters:
        message - message with java formating
        Returns:
        html format message
      • parseTranslation

        public static String parseTranslation​(String text)
        Parse the text searching @ parameters to translate.
        Parameters:
        text - String with the text to translate.
        Returns:
        String translated.
      • parseTranslation

        public static String parseTranslation​(String text,
                                              Map<String,​String> map)
        Parse the text searching @ parameters to translate.
        Parameters:
        text - String with the text to translate.
        map - optional Map containing replacement values for the tokens
        Returns:
        String translated.
      • parseTranslation

        public static String parseTranslation​(ConnectionProvider conn,
                                              VariablesSecureApp vars,
                                              String language,
                                              String text)
        Parse the text searching @ parameters to translate.
        Parameters:
        conn - Handler for the database connection.
        vars - Handler for the session info.
        language - String with the language to translate.
        text - String with the text to translate.
        Returns:
        String translated.
      • parseTranslation

        public static String parseTranslation​(ConnectionProvider conn,
                                              VariablesSecureApp vars,
                                              Map<String,​String> replaceMap,
                                              String language,
                                              String text)
        Parse the text searching @ parameters to translate. If replaceMap is not null and contains a replacement value for a token then it will be used, otherwise the return value of the translate method will be used for the translation.
        Parameters:
        conn - Handler for the database connection.
        vars - Handler for the session info.
        replaceMap - optional Map containing replacement values for the tokens
        language - String with the language to translate.
        text - String with the text to translate.
        Returns:
        String translated.
      • translate

        public static String translate​(ConnectionProvider conn,
                                       VariablesSecureApp vars,
                                       String token,
                                       String language)
        For each token found in the parseTranslation method, this method is called to find the correct translation.
        Parameters:
        conn - Handler for the database connection.
        vars - Handler for the session info.
        token - String with the token to translate.
        language - String with the language to translate.
        Returns:
        String with the token translated.
      • getProcessInstanceMessage

        public static OBError getProcessInstanceMessage​(ProcessInstance pInstance)
        Gets the Message for the instance of the processes.
        Parameters:
        pInstance - ProcessInstance object
        Returns:
        Object with the message.
      • translateError

        public static OBError translateError​(String message)
        Translate the message, searching the @ parameters, and making use of the ErrorTextParser class to get the appropriated message.
        Parameters:
        message - String with the message to translate.
      • translateError

        public static OBError translateError​(ConnectionProvider conn,
                                             VariablesSecureApp vars,
                                             String strLanguage,
                                             String _message)
        Translate the message, searching the @ parameters, and making use of the ErrorTextParser class to get the appropriated message.
        Parameters:
        conn - Handler for the database connection.
        vars - Handler for the session info.
        strLanguage - Language to translate.
        _message - String with the message to translate.
        Returns:
        Object with the message.
      • locateMessage

        public static FieldProvider locateMessage​(ConnectionProvider conn,
                                                  String strCode,
                                                  String strLanguage)
        Search a message in the database.
        Parameters:
        conn - Handler for the database connection.
        strCode - Message to search.
        strLanguage - Language to translate.
        Returns:
        FieldProvider with the message info.
      • getI18NMessage

        public static String getI18NMessage​(String key,
                                            String[] params)
        Returns a message in the right language with parameter substitution. Each occurence of a % parameter (%0, %1 etc) is replaced with the corresponding parameter value. in the params array.
        Parameters:
        key - the key of the message
        params - the parameters to substitute in the message
        Returns:
        the translated message with the parameters substituted