} /** * Broadcasts the start of an sequence of image reads to all * registered <code>IIOReadProgressListener</code>s by calling * their <code>sequenceStarted</code> method. Subclasses may use * this method as a convenience. * * @param minIndex the lowest index being read. */ protected void processSequenceStarted(int minIndex) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.sequenceStarted(this, minIndex); } } /** * Broadcasts the completion of an sequence of image reads to all * registered <code>IIOReadProgressListener</code>s by calling * their <code>sequenceComplete</code> method. Subclasses may use * this method as a convenience. */ protected void processSequenceComplete() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.sequenceComplete(this); } } /** * Broadcasts the start of an image read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>imageStarted</code> method. Subclasses may use this * method as a convenience. * * @param imageIndex the index of the image about to be read. */ protected void processImageStarted(int imageIndex) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.imageStarted(this, imageIndex); } } /** * Broadcasts the current percentage of image completion to all * registered <code>IIOReadProgressListener</code>s by calling * their <code>imageProgress</code> method. Subclasses may use * this method as a convenience. * * @param percentageDone the current percentage of completion, * as a <code>float</code>. */ protected void processImageProgress(float percentageDone) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.imageProgress(this, percentageDone); } } /** * Broadcasts the completion of an image read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>imageComplete</code> method. Subclasses may use this * method as a convenience. */ protected void processImageComplete() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.imageComplete(this); } } /** * Broadcasts the start of a thumbnail read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>thumbnailStarted</code> method. Subclasses may use this * method as a convenience. * * @param imageIndex the index of the image associated with the * thumbnail. * @param thumbnailIndex the index of the thumbnail. */ protected void processThumbnailStarted(int imageIndex, int thumbnailIndex) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.thumbnailStarted(this, imageIndex, thumbnailIndex); } } /** * Broadcasts the current percentage of thumbnail completion to * all registered <code>IIOReadProgressListener</code>s by calling * their <code>thumbnailProgress</code> method. Subclasses may * use this method as a convenience. * * @param percentageDone the current percentage of completion, * as a <code>float</code>. */ protected void processThumbnailProgress(float percentageDone) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.thumbnailProgress(this, percentageDone); } } /** * Broadcasts the completion of a thumbnail read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>thumbnailComplete</code> method. Subclasses may use this * method as a convenience. */ protected void processThumbnailComplete() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.thumbnailComplete(this); } } /** * Broadcasts that the read has been aborted to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>readAborted</code> method. Subclasses may use this * method as a convenience. */ protected void processReadAborted() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.readAborted(this); } } /** * Broadcasts the beginning of a progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>passStarted</code> method. Subclasses may use this * method as a convenience. * * @param theImage the <code>BufferedImage</code> being updated. * @param pass the index of the current pass, starting with 0. * @param minPass the index of the first pass that will be decoded. * @param maxPass the index of the last pass that will be decoded. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processPassStarted(BufferedImage theImage, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.passStarted(this, theImage, pass, minPass, maxPass, minX, minY, periodX, periodY, bands); } } /** * Broadcasts the update of a set of samples to all registered * <code>IIOReadUpdateListener</code>s by calling their * <code>imageUpdate</code> method. Subclasses may use this * method as a convenience. * * @param theImage the <code>BufferedImage</code> being updated. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param width the total width of the area being updated, including * pixels being skipped if <code>periodX > 1</code>. * @param height the total height of the area being updated, * including pixels being skipped if <code>periodY > 1</code>. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processImageUpdate(BufferedImage theImage, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.imageUpdate(this, theImage, minX, minY, width, height, periodX, periodY, bands); } } /** * Broadcasts the end of a progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>passComplete</code> method. Subclasses may use this * method as a convenience. * * @param theImage the <code>BufferedImage</code> being updated. */ protected void processPassComplete(BufferedImage theImage) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.passComplete(this, theImage); } } /** * Broadcasts the beginning of a thumbnail progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>thumbnailPassStarted</code> method. Subclasses may use this * method as a convenience. * * @param theThumbnail the <code>BufferedImage</code> thumbnail * being updated. * @param pass the index of the current pass, starting with 0. * @param minPass the index of the first pass that will be decoded. * @param maxPass the index of the last pass that will be decoded. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processThumbnailPassStarted(BufferedImage theThumbnail, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.thumbnailPassStarted(this, theThumbnail, pass, minPass, maxPass, minX, minY, periodX, periodY, bands); } } /** * Broadcasts the update of a set of samples in a thumbnail image * to all registered <code>IIOReadUpdateListener</code>s by * calling their <code>thumbnailUpdate</code> method. Subclasses may * use this method as a convenience. * * @param theThumbnail the <code>BufferedImage</code> thumbnail * being updated. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param width the total width of the area being updated, including * pixels being skipped if <code>periodX > 1</code>. * @param height the total height of the area being updated, * including pixels being skipped if <code>periodY > 1</code>. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processThumbnailUpdate(BufferedImage theThumbnail, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.thumbnailUpdate(this, theThumbnail, minX, minY, width, height, periodX, periodY, bands); } } /** * Broadcasts the end of a thumbnail progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>thumbnailPassComplete</code> method. Subclasses may use this * method as a convenience. * * @param theThumbnail the <code>BufferedImage</code> thumbnail * being updated. */ protected void processThumbnailPassComplete(BufferedImage theThumbnail) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.thumbnailPassComplete(this, theThumbnail); } } /** * Broadcasts a warning message to all registered * <code>IIOReadWarningListener</code>s by calling their * <code>warningOccurred</code> method. Subclasses may use this * method as a convenience. * * @param warning the warning message to send. * * @exception IllegalArgumentException if <code>warning</code> * is <code>null</code>. */ protected void processWarningOccurred(String warning) { if (warningListeners == null) { return; } if (warning == null) { throw new IllegalArgumentException("warning == null!"); } int numListeners = warningListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadWarningListener listener = (IIOReadWarningListener)warningListeners.get(i); listener.warningOccurred(this, warning); } } /** * Broadcasts a localized warning message to all registered * <code>IIOReadWarningListener</code>s by calling their * <code>warningOccurred</code> method with a string taken * from a <code>ResourceBundle</code>. Subclasses may use this * method as a convenience. * * @param baseName the base name of a set of * <code>ResourceBundle</code>s containing localized warning * messages. * @param keyword the keyword used to index the warning message * within the set of <code>ResourceBundle</code>s. * * @exception IllegalArgumentException if <code>baseName</code> * is <code>null</code>. * @exception IllegalArgumentException if <code>keyword</code> * is <code>null</code>. * @exception IllegalArgumentException if no appropriate * <code>ResourceBundle</code> may be located. * @exception IllegalArgumentException if the named resource is * not found in the located <code>ResourceBundle</code>. * @exception IllegalArgumentException if the object retrieved * from the <code>ResourceBundle</code> is not a * <code>String</code>. */ protected void processWarningOccurred(String baseName, String keyword) { if (warningListeners == null) { return; } if (baseName == null) { throw new IllegalArgumentException("baseName == null!"); } 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); } } // State management Lines 2001–2500 of 2898. Previous lines Load more
} /** * Broadcasts the start of an sequence of image reads to all * registered <code>IIOReadProgressListener</code>s by calling * their <code>sequenceStarted</code> method. Subclasses may use * this method as a convenience. * * @param minIndex the lowest index being read. */ protected void processSequenceStarted(int minIndex) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.sequenceStarted(this, minIndex); } } /** * Broadcasts the completion of an sequence of image reads to all * registered <code>IIOReadProgressListener</code>s by calling * their <code>sequenceComplete</code> method. Subclasses may use * this method as a convenience. */ protected void processSequenceComplete() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.sequenceComplete(this); } } /** * Broadcasts the start of an image read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>imageStarted</code> method. Subclasses may use this * method as a convenience. * * @param imageIndex the index of the image about to be read. */ protected void processImageStarted(int imageIndex) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.imageStarted(this, imageIndex); } } /** * Broadcasts the current percentage of image completion to all * registered <code>IIOReadProgressListener</code>s by calling * their <code>imageProgress</code> method. Subclasses may use * this method as a convenience. * * @param percentageDone the current percentage of completion, * as a <code>float</code>. */ protected void processImageProgress(float percentageDone) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.imageProgress(this, percentageDone); } } /** * Broadcasts the completion of an image read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>imageComplete</code> method. Subclasses may use this * method as a convenience. */ protected void processImageComplete() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.imageComplete(this); } } /** * Broadcasts the start of a thumbnail read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>thumbnailStarted</code> method. Subclasses may use this * method as a convenience. * * @param imageIndex the index of the image associated with the * thumbnail. * @param thumbnailIndex the index of the thumbnail. */ protected void processThumbnailStarted(int imageIndex, int thumbnailIndex) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.thumbnailStarted(this, imageIndex, thumbnailIndex); } } /** * Broadcasts the current percentage of thumbnail completion to * all registered <code>IIOReadProgressListener</code>s by calling * their <code>thumbnailProgress</code> method. Subclasses may * use this method as a convenience. * * @param percentageDone the current percentage of completion, * as a <code>float</code>. */ protected void processThumbnailProgress(float percentageDone) { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.thumbnailProgress(this, percentageDone); } } /** * Broadcasts the completion of a thumbnail read to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>thumbnailComplete</code> method. Subclasses may use this * method as a convenience. */ protected void processThumbnailComplete() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.thumbnailComplete(this); } } /** * Broadcasts that the read has been aborted to all registered * <code>IIOReadProgressListener</code>s by calling their * <code>readAborted</code> method. Subclasses may use this * method as a convenience. */ protected void processReadAborted() { if (progressListeners == null) { return; } int numListeners = progressListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadProgressListener listener = (IIOReadProgressListener)progressListeners.get(i); listener.readAborted(this); } } /** * Broadcasts the beginning of a progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>passStarted</code> method. Subclasses may use this * method as a convenience. * * @param theImage the <code>BufferedImage</code> being updated. * @param pass the index of the current pass, starting with 0. * @param minPass the index of the first pass that will be decoded. * @param maxPass the index of the last pass that will be decoded. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processPassStarted(BufferedImage theImage, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.passStarted(this, theImage, pass, minPass, maxPass, minX, minY, periodX, periodY, bands); } } /** * Broadcasts the update of a set of samples to all registered * <code>IIOReadUpdateListener</code>s by calling their * <code>imageUpdate</code> method. Subclasses may use this * method as a convenience. * * @param theImage the <code>BufferedImage</code> being updated. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param width the total width of the area being updated, including * pixels being skipped if <code>periodX > 1</code>. * @param height the total height of the area being updated, * including pixels being skipped if <code>periodY > 1</code>. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processImageUpdate(BufferedImage theImage, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.imageUpdate(this, theImage, minX, minY, width, height, periodX, periodY, bands); } } /** * Broadcasts the end of a progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>passComplete</code> method. Subclasses may use this * method as a convenience. * * @param theImage the <code>BufferedImage</code> being updated. */ protected void processPassComplete(BufferedImage theImage) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.passComplete(this, theImage); } } /** * Broadcasts the beginning of a thumbnail progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>thumbnailPassStarted</code> method. Subclasses may use this * method as a convenience. * * @param theThumbnail the <code>BufferedImage</code> thumbnail * being updated. * @param pass the index of the current pass, starting with 0. * @param minPass the index of the first pass that will be decoded. * @param maxPass the index of the last pass that will be decoded. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processThumbnailPassStarted(BufferedImage theThumbnail, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.thumbnailPassStarted(this, theThumbnail, pass, minPass, maxPass, minX, minY, periodX, periodY, bands); } } /** * Broadcasts the update of a set of samples in a thumbnail image * to all registered <code>IIOReadUpdateListener</code>s by * calling their <code>thumbnailUpdate</code> method. Subclasses may * use this method as a convenience. * * @param theThumbnail the <code>BufferedImage</code> thumbnail * being updated. * @param minX the X coordinate of the upper-left pixel included * in the pass. * @param minY the X coordinate of the upper-left pixel included * in the pass. * @param width the total width of the area being updated, including * pixels being skipped if <code>periodX > 1</code>. * @param height the total height of the area being updated, * including pixels being skipped if <code>periodY > 1</code>. * @param periodX the horizontal separation between pixels. * @param periodY the vertical separation between pixels. * @param bands an array of <code>int</code>s indicating the * set of affected bands of the destination. */ protected void processThumbnailUpdate(BufferedImage theThumbnail, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.thumbnailUpdate(this, theThumbnail, minX, minY, width, height, periodX, periodY, bands); } } /** * Broadcasts the end of a thumbnail progressive pass to all * registered <code>IIOReadUpdateListener</code>s by calling their * <code>thumbnailPassComplete</code> method. Subclasses may use this * method as a convenience. * * @param theThumbnail the <code>BufferedImage</code> thumbnail * being updated. */ protected void processThumbnailPassComplete(BufferedImage theThumbnail) { if (updateListeners == null) { return; } int numListeners = updateListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadUpdateListener listener = (IIOReadUpdateListener)updateListeners.get(i); listener.thumbnailPassComplete(this, theThumbnail); } } /** * Broadcasts a warning message to all registered * <code>IIOReadWarningListener</code>s by calling their * <code>warningOccurred</code> method. Subclasses may use this * method as a convenience. * * @param warning the warning message to send. * * @exception IllegalArgumentException if <code>warning</code> * is <code>null</code>. */ protected void processWarningOccurred(String warning) { if (warningListeners == null) { return; } if (warning == null) { throw new IllegalArgumentException("warning == null!"); } int numListeners = warningListeners.size(); for (int i = 0; i < numListeners; i++) { IIOReadWarningListener listener = (IIOReadWarningListener)warningListeners.get(i); listener.warningOccurred(this, warning); } } /** * Broadcasts a localized warning message to all registered * <code>IIOReadWarningListener</code>s by calling their * <code>warningOccurred</code> method with a string taken * from a <code>ResourceBundle</code>. Subclasses may use this * method as a convenience. * * @param baseName the base name of a set of * <code>ResourceBundle</code>s containing localized warning * messages. * @param keyword the keyword used to index the warning message * within the set of <code>ResourceBundle</code>s. * * @exception IllegalArgumentException if <code>baseName</code> * is <code>null</code>. * @exception IllegalArgumentException if <code>keyword</code> * is <code>null</code>. * @exception IllegalArgumentException if no appropriate * <code>ResourceBundle</code> may be located. * @exception IllegalArgumentException if the named resource is * not found in the located <code>ResourceBundle</code>. * @exception IllegalArgumentException if the object retrieved * from the <code>ResourceBundle</code> is not a * <code>String</code>. */ protected void processWarningOccurred(String baseName, String keyword) { if (warningListeners == null) { return; } if (baseName == null) { throw new IllegalArgumentException("baseName == null!"); } 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); } } // State management