Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.MissingResourceException;

import java.util.ResourceBundle;

public class Main {
    private static ResourceBundle defaultResources;
    private static ResourceBundle choosenResources;

    /**
     * Gets a resource string from the resource bundle.<p> Resource bundle
     * represents the <i>property file</i>. For example, if property file
     * contains something like this:<BR><CENTER>menubar=file edit help</CENTER>
     * method call getLanguageDependentString("menubar") will give the string
     * <i>file edit help</i> as a result. <BR> This method reads information
     * from property file. If can't find desired resource, returns <b>null</b>.
     * @param nm name of the resource to fetch.
     * @return String value of named resource.
     */
    public static String getLanguageDependentString(String nm) {
        String str;
        try {
            str = choosenResources.getString(nm);
        } catch (MissingResourceException mre) {
            try {
                str = defaultResources.getString(nm);
            } catch (MissingResourceException mre1) {
                str = null;
            } catch (NullPointerException npe) {
                str = null;
            }
        } catch (NullPointerException npe) {
            /*ResourceBundle orig=ResourceBundle.
             getBundle("org.enhydra.shark.xpdl.resources.SharkXPDL",new Locale(""));*/
            ResourceBundle orig = ResourceBundle.getBundle("org.enhydra.shark.xpdl.resources.SharkXPDL");
            try {
                str = orig.getString(nm);
            } catch (Exception ex) {
                str = null;
            }
        }
        return str;
    }
}