package discRack;
import java.awt.*;
import java.util.*;
import java.text.*;
import java.net.URL;
import javax.accessibility.*;
/**
* Implements the static methods that are used to implement
* multilanguage support.
*
* @author Sasa Bojanic
* @version 1.0
*/
public class ResourceManager {
private static final String resourcePath=
"discRack.resources.DiscRack";
public static ResourceBundle defaultResource;
static {
try {
defaultResource = ResourceBundle.
getBundle(resourcePath);
}
catch (MissingResourceException mre) {
System.err.println(resourcePath+".properties not found");
System.exit(1);
}
}
/**
* 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 getResourceString("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 getResourceString (String nm) {
String str;
try {
str=defaultResource.getString(nm);
} catch (MissingResourceException mre1) {
str = null;
}
return str;
}
/**
* Gets the url from a resource string.
* @param key the string key to the url in the resource bundle.
* @return the resource location.
* @see java.lang.Class#getResource
*/
public static URL getResource (String key) {
String name = getResourceString(key);
if (name != null) {
URL url = ResourceManager.class.getClassLoader().getResource(name);
return url;
}
return null;
}
}
|