Example usage for java.util MissingResourceException getLocalizedMessage

List of usage examples for java.util MissingResourceException getLocalizedMessage

Introduction

In this page you can find the example usage for java.util MissingResourceException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:de.rrze.idmone.utils.jidgen.Messages.java

/**
 * Returns the localized message for this key. If the key is not found its
 * value is returned surrounded by exclamation marks.
 * // w  w w  . j  a v a  2s.c o m
 * @param key the key to be searched for in the resource bundle
 * @return the localized value for the key
 */
public static String getString(String key) {
    try {
        String ret = RESOURCE_BUNDLE.getString(key);
        return ret;
    } catch (MissingResourceException e) {
        logger.debug(e.getLocalizedMessage());
        return '!' + key + '!';
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Create the application./* w  w w .ja v a  2s.  c om*/
 * 
 * @throws ConfigReadWriteException
 * @throws IOException
 */
public MainCommGUI() throws IOException, ConfigReadWriteException {
    lg = SpxPcloggerProgramConfig.LOGGER;
    setDefaultLookAndFeelDecorated(isDefaultLookAndFeelDecorated());
    // Konfiguration aus der Datei einlesen
    // bercksichtigt schon per CLI angegebene Werte als gesetzt
    new ReadConfig();
    makeLogger();
    //
    // gib ein paar informationen
    //
    lg.info("Operating System: <" + OperatingSystemDetector.getOsName() + ">");
    lg.info("Java VM Datamodel: " + OperatingSystemDetector.getDataModel() + " bits");
    lg.info("Java VM Datamodel: <" + OperatingSystemDetector.getArch() + ">");
    //
    // Grundstzliche Sachen einstellen
    //
    try {
        ResourceBundle.clearCache();
        if (SpxPcloggerProgramConfig.langCode != null) {
            lg.info("try make locale from cmd options <" + SpxPcloggerProgramConfig.langCode + ">...");
            programLocale = new Locale(SpxPcloggerProgramConfig.langCode);
        } else {
            lg.debug("try get locale from system...");
            programLocale = Locale.getDefault();
        }
        LangStrings.setLocale(programLocale);
        lg.debug(String.format("getLocale says: Display Language :<%s>, lang: <%s>",
                programLocale.getDisplayLanguage(), programLocale.getLanguage()));
        stringsBundle = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.messages", programLocale);
        if (stringsBundle.getLocale().equals(programLocale)) {
            lg.debug("language accepted..");
        } else {
            lg.debug("language fallback default...");
            programLocale = Locale.ENGLISH;
            Locale.setDefault(programLocale);
            stringsBundle = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.messages",
                    programLocale);
        }
        checkDatabaseDirectory();
    } catch (MissingResourceException ex) {
        lg.error("ERROR get resources <" + ex.getMessage() + "> try standart Strings...");
        System.err.println("ERROR get resources <" + ex.getMessage() + "> try standart Strings...");
        try {
            lg.debug("try get  default english locale from system...");
            programLocale = Locale.ENGLISH;
            Locale.setDefault(programLocale);
            stringsBundle = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.messages_en");
        } catch (Exception ex1) {
            lg.error("ERROR get resources <" + ex1.getMessage() + "> give up...");
            System.exit(-1);
        }
    } catch (NoDatabaseException ex) {
        showErrorDialog(ex.getLocalizedMessage());
        System.exit(-1);
    }
    //
    // jetzt die wichtigen anderen Sachen, die dauern.
    //
    prepareDatabase();
    currentConfig.setLogger(lg);
    btComm = new BTCommunication(databaseUtil);
    btComm.addActionListener(this);
    try {
        initializeGUI();
    } catch (SQLException ex) {
        lg.error("SQL ERROR <" + ex.getMessage() + "> give up...");
        System.err.println("ERROR while create GUI: <" + ex.getLocalizedMessage() + ">");
        ex.printStackTrace();
        System.exit(-1);
    } catch (ClassNotFoundException ex) {
        lg.error("CLASS NOT FOUND EXCEPTION <" + ex.getMessage() + "> give up...");
        System.err.println("ERROR while create GUI: <" + ex.getLocalizedMessage() + ">");
        ex.printStackTrace();
        System.exit(-1);
    }
    // Listener setzen (braucht auch die Maps)
    setGlobalChangeListener();
    //
    initLanuageMenu(programLocale);
    if (!SpxPcloggerProgramConfig.developDebug) {
        configPanel.setAllConfigPanlelsEnabled(false);
        logListPanel.setAllLogPanelsEnabled(false);
        setElementsConnected(false);
    }
    if (setLanguageStrings() < 1) {
        lg.error("setLanguageStrings() faild. give up...");
        System.exit(-1);
    }
    connectionPanel.setVirtDevicesBoxEnabled(false);
    startVirtualPortFinder(null);
    waitForMessage = 0;
}