/[classpath]/classpath/javax/imageio/ImageWriter.java
ViewVC logotype

Diff of /classpath/javax/imageio/ImageWriter.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by andreast, Tue Oct 4 15:43:32 2005 UTC revision 1.9 by fitzsim, Tue Oct 4 18:31:41 2005 UTC
# Line 47  import java.util.ArrayList; Line 47  import java.util.ArrayList;
47  import java.util.Iterator;  import java.util.Iterator;
48  import java.util.List;  import java.util.List;
49  import java.util.Locale;  import java.util.Locale;
50    import java.util.ResourceBundle;
51    import java.util.MissingResourceException;
52    
53  import javax.imageio.event.IIOWriteProgressListener;  import javax.imageio.event.IIOWriteProgressListener;
54  import javax.imageio.event.IIOWriteWarningListener;  import javax.imageio.event.IIOWriteWarningListener;
# Line 698  public abstract class ImageWriter Line 700  public abstract class ImageWriter
700     * when the warning was raised     * when the warning was raised
701     * @param warning the warning message     * @param warning the warning message
702     *     *
703     * @throw IllegalArgumentException if warning is null     * @exception IllegalArgumentException if warning is null
704     */     */
705    protected void processWarningOccurred(int imageIndex, String warning)    protected void processWarningOccurred(int imageIndex, String warning)
706    {    {
# Line 706  public abstract class ImageWriter Line 708  public abstract class ImageWriter
708        {        {
709          Iterator it = warningListeners.iterator();          Iterator it = warningListeners.iterator();
710    
711            while (it.hasNext())
712              {
713                IIOWriteWarningListener listener =
714                  (IIOWriteWarningListener) it.next();
715                listener.warningOccurred(this, imageIndex, warning);
716              }
717          }
718      }
719    
720      /**
721       * Notify all installed warning listeners, by calling their
722       * warningOccurred methods, that a warning message has been raised.
723       * The warning message is retrieved from a resource bundle, using
724       * the given basename and keyword.
725       *
726       * @param imageIndex the index of the image that was being written
727       * when the warning was raised
728       * @param baseName the basename of the resource from which to
729       * retrieve the warning message
730       * @param keyword the keyword used to retrieve the warning from the
731       * resource bundle
732       *
733       * @exception IllegalArgumentException if either baseName or keyword
734       * is null
735       * @exception IllegalArgumentException if no resource bundle is
736       * found using baseName
737       * @exception IllegalArgumentException if the given keyword produces
738       * no results from the resource bundle
739       * @exception IllegalArgumentException if the retrieved object is
740       * not a String
741       */
742      protected void processWarningOccurred(int imageIndex,
743                                            String baseName,
744                                            String keyword)
745      {
746        if (baseName == null || keyword == null)
747          throw new IllegalArgumentException ("null argument");
748    
749        ResourceBundle b = null;
750    
751        try
752          {
753            b = ResourceBundle.getBundle(baseName, getLocale());
754          }
755        catch (MissingResourceException e)
756          {
757            throw new IllegalArgumentException ("no resource bundle found");
758          }
759    
760        Object str = null;
761    
762        try
763          {
764            str = b.getObject(keyword);
765          }
766        catch (MissingResourceException e)
767          {
768            throw new IllegalArgumentException ("no results found for keyword");
769          }
770    
771        if (! (str instanceof String))
772          throw new IllegalArgumentException ("retrieved object not a String");
773    
774        String warning = (String) str;
775    
776        if (warningListeners != null)
777          {
778            Iterator it = warningListeners.iterator();
779    
780          while (it.hasNext())          while (it.hasNext())
781            {            {
782              IIOWriteWarningListener listener =              IIOWriteWarningListener listener =

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26