/** * Translate the given code into some message from the application dictionary. * * @param conn Handler for the database connection. * @param strCode String with the code to search. * @param strLanguage String with the translation language. * @param escape Escape \n and " characters * @return String with the translated message. */ public static String messageBD( ConnectionProvider conn, String strCode, String strLanguage, boolean escape) { String strMessage = ""; if (strLanguage == null || strLanguage.equals("")) strLanguage = "en_US"; try { log4j.debug("Utility.messageBD - Message Code: " + strCode); strMessage = MessageBDData.message(conn, strLanguage, strCode); } catch (final Exception ignore) { log4j.error("Error getting message", ignore); } log4j.debug("Utility.messageBD - Message description: " + strMessage); if (strMessage == null || strMessage.equals("")) { try { strMessage = MessageBDData.columnname(conn, strLanguage, strCode); } catch (final Exception e) { log4j.error("Error getting message", e); strMessage = strCode; } } if (strMessage == null || strMessage.equals("")) { strMessage = strCode; } if (escape) { strMessage = Replace.replace(Replace.replace(strMessage, "\n", "\\n"), "\"", """); } return strMessage; }
/** * Search a message in the database. * * @param conn Handler for the database connection. * @param strCode Message to search. * @param strLanguage Language to translate. * @return FieldProvider with the message info. */ public static FieldProvider locateMessage( ConnectionProvider conn, String strCode, String strLanguage) { FieldProvider[] fldMessage = null; try { log4j.debug("locateMessage - Message Code: " + strCode); fldMessage = MessageBDData.messageInfo(conn, strLanguage, strCode); } catch (final Exception ignore) { } if (fldMessage != null && fldMessage.length > 0) { return fldMessage[0]; } else { return null; } }