01: package org.bouncycastle.i18n;
02:
03: import java.net.URL;
04: import java.net.URLClassLoader;
05: import java.util.Locale;
06:
07: public class MissingEntryException extends RuntimeException {
08:
09: protected final String resource;
10: protected final String key;
11: protected final ClassLoader loader;
12: protected final Locale locale;
13:
14: private String debugMsg;
15:
16: public MissingEntryException(String message, String resource,
17: String key, Locale locale, ClassLoader loader) {
18: super (message);
19: this .resource = resource;
20: this .key = key;
21: this .locale = locale;
22: this .loader = loader;
23: }
24:
25: public MissingEntryException(String message, Throwable cause,
26: String resource, String key, Locale locale,
27: ClassLoader loader) {
28: super (message, cause);
29: this .resource = resource;
30: this .key = key;
31: this .locale = locale;
32: this .loader = loader;
33: }
34:
35: public String getKey() {
36: return key;
37: }
38:
39: public String getResource() {
40: return resource;
41: }
42:
43: public ClassLoader getClassLoader() {
44: return loader;
45: }
46:
47: public Locale getLocale() {
48: return locale;
49: }
50:
51: public String getDebugMsg() {
52: if (debugMsg == null) {
53: debugMsg = "Can not find entry " + key
54: + " in resource file " + resource
55: + " for the locale " + locale + ".";
56: if (loader instanceof URLClassLoader) {
57: URL[] urls = ((URLClassLoader) loader).getURLs();
58: debugMsg += " The following entries in the classpath were searched: ";
59: for (int i = 0; i != urls.length; i++) {
60: debugMsg += urls[i] + " ";
61: }
62: }
63: }
64: return debugMsg;
65: }
66:
67: }
|