2444 throw new IllegalArgumentException("keyword == null!"); 2445 } 2446 int numListeners = warningListeners.size(); 2447 for (int i = 0; i < numListeners; i++) { 2448 IIOReadWarningListener listener = 2449 warningListeners.get(i); 2450 Locale locale = warningLocales.get(i); 2451 if (locale == null) { 2452 locale = Locale.getDefault(); 2453 } 2454 2455 /* 2456 * Only the plugin knows the messages that are provided, so we 2457 * can always locate the resource bundles from the same loader 2458 * as that for the plugin code itself. 2459 */ 2460 ResourceBundle bundle = null; 2461 try { 2462 bundle = ResourceBundle.getBundle(baseName, locale, this.getClass().getModule()); 2463 } catch (MissingResourceException mre) { 2464 throw new IllegalArgumentException("Bundle not found!"); 2465 } 2466 2467 String warning = null; 2468 try { 2469 warning = bundle.getString(keyword); 2470 } catch (ClassCastException cce) { 2471 throw new IllegalArgumentException("Resource is not a String!"); 2472 } catch (MissingResourceException mre) { 2473 throw new IllegalArgumentException("Resource is missing!"); 2474 } 2475 2476 listener.warningOccurred(this, warning); 2477 } 2478 } 2479 2480 // State management 2481 2482 /** 2483 * Restores the {@code ImageReader} to its initial state. 2484 * 2485 * <p> The default implementation calls 2486 * {@code setInput(null, false)}, 2487 * {@code setLocale(null)}, 2488 * {@code removeAllIIOReadUpdateListeners()}, 2489 * {@code removeAllIIOReadWarningListeners()}, 2490 * {@code removeAllIIOReadProgressListeners()}, and 2491 * {@code clearAbortRequest}. 2492 */ 2493 public void reset() { | 2444 throw new IllegalArgumentException("keyword == null!"); 2445 } 2446 int numListeners = warningListeners.size(); 2447 for (int i = 0; i < numListeners; i++) { 2448 IIOReadWarningListener listener = 2449 warningListeners.get(i); 2450 Locale locale = warningLocales.get(i); 2451 if (locale == null) { 2452 locale = Locale.getDefault(); 2453 } 2454 2455 /* 2456 * Only the plugin knows the messages that are provided, so we 2457 * can always locate the resource bundles from the same loader 2458 * as that for the plugin code itself. 2459 */ 2460 ResourceBundle bundle = null; 2461 try { 2462 bundle = ResourceBundle.getBundle(baseName, locale, this.getClass().getModule()); 2463 } catch (MissingResourceException mre) { 2464 throw new IllegalArgumentException("Bundle not found!", mre); 2465 } 2466 2467 String warning = null; 2468 try { 2469 warning = bundle.getString(keyword); 2470 } catch (ClassCastException cce) { 2471 throw new IllegalArgumentException("Resource is not a String!", cce); 2472 } catch (MissingResourceException mre) { 2473 throw new IllegalArgumentException("Resource is missing!", mre); 2474 } 2475 2476 listener.warningOccurred(this, warning); 2477 } 2478 } 2479 2480 // State management 2481 2482 /** 2483 * Restores the {@code ImageReader} to its initial state. 2484 * 2485 * <p> The default implementation calls 2486 * {@code setInput(null, false)}, 2487 * {@code setLocale(null)}, 2488 * {@code removeAllIIOReadUpdateListeners()}, 2489 * {@code removeAllIIOReadWarningListeners()}, 2490 * {@code removeAllIIOReadProgressListeners()}, and 2491 * {@code clearAbortRequest}. 2492 */ 2493 public void reset() { |