if (keyword == null) {
throw new IllegalArgumentException("keyword == null!");
}
int numListeners = warningListeners.size();
for (int i = 0; i < numListeners; i++) {
IIOReadWarningListener listener =
(IIOReadWarningListener)warningListeners.get(i);
Locale locale = (Locale)warningLocales.get(i);
if (locale == null) {
locale = Locale.getDefault();
}
/**
* If an applet supplies an implementation of ImageReader and
* resource bundles, then the resource bundle will need to be
* accessed via the applet class loader. So first try the context
* class loader to locate the resource bundle.
* If that throws MissingResourceException, then try the
* system class loader.
*/
ClassLoader loader = (ClassLoader)
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return Thread.currentThread().getContextClassLoader();
}
});
ResourceBundle bundle = null;
try {
bundle = ResourceBundle.getBundle(baseName, locale, loader);
} catch (MissingResourceException mre) {
try {
bundle = ResourceBundle.getBundle(baseName, locale);
} catch (MissingResourceException mre1) {
throw new IllegalArgumentException("Bundle not found!");
}
}
String warning = null;
try {
warning = bundle.getString(keyword);
} catch (ClassCastException cce) {
throw new IllegalArgumentException("Resource is not a String!");
} catch (MissingResourceException mre) {
throw new IllegalArgumentException("Resource is missing!");
}
listener.warningOccurred(this, warning);
}
}