KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > util > ResourceManager


1 package org.enhydra.shark.util;
2
3
4 import java.util.*;
5 import org.enhydra.shark.api.RootError;
6
7 /**
8 * Implements the static methods used to get the multilanguage support.
9 */

10 public class ResourceManager {
11    private static ResourceBundle resourceBundle;
12
13    static {
14       try {
15          /*resourceBundle = ResourceBundle.
16           getBundle("org.enhydra.shark.resources.SharkServer",new Locale(""));*/

17          resourceBundle = ResourceBundle.
18             getBundle("org.enhydra.shark.resources.SharkServer");
19
20          // chose the default system settings at the start
21
} catch (MissingResourceException mre) {
22 System.err.println("ResourceManager -> org.enhydra.shark.resources.SharkServer.properties not found");
23          throw new RootError("No property file!",mre);
24       }
25    }
26
27    /**
28     * Gets a language dependent string from the resource bundle.<p> Resource bundle
29     * represents the <i>property file</i>. For example, if property file
30     * contains something like this:<BR><CENTER>menubar=file edit help</CENTER>
31     * method call getLanguageDependentString("menubar") will give the string
32     * <i>file edit help</i> as a result. <BR> This method reads information
33     * from property file. If can't find desired resource, returns <b>null</b>.
34     * @param nm name of the resource to fetch.
35     * @return String value of named resource.
36     */

37    public static String JavaDoc getLanguageDependentString (String JavaDoc nm) {
38       String JavaDoc str;
39       try {
40          str=resourceBundle.getString(nm);
41       } catch (MissingResourceException mre) {
42          str="";
43       }
44       return str;
45    }
46
47 }
48
Popular Tags