[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: JAPI fixes for javax.imageio
From: |
Thomas Fitzsimmons |
Subject: |
[cp-patches] FYI: JAPI fixes for javax.imageio |
Date: |
Tue, 04 Oct 2005 14:35:07 -0400 |
Hi,
I committed these patches that fix some typos and add the resource
bundle variants of processWarningOccurred. This should eliminate the
JAPI errors in javax.imageio.
Tom
2005-10-04 Thomas Fitzsimmons <address@hidden>
* javax/imageio/ImageWriter.java
(processWarningOccurred(int,String,String)): New method.
* javax/imageio/ImageReader.java
(processWarningOccurred(String,String)): New method.
2005-10-04 Thomas Fitzsimmons <address@hidden>
* javax/imageio/ImageReader.java (getDestination): Throw
IIOException, not IOException.
* javax/imageio/ImageTypeSpecifier.java
(createGrayscale(int,int,boolean)): Rename from createGrayScale.
(createGrayscale(int,int,boolean,boolean)): Likewise.
(createIndexed): Rename from createIndex.
Index: javax/imageio/ImageReader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageReader.java,v
retrieving revision 1.8
diff -u -r1.8 ImageReader.java
--- javax/imageio/ImageReader.java 4 Oct 2005 18:05:08 -0000 1.8
+++ javax/imageio/ImageReader.java 4 Oct 2005 18:30:34 -0000
@@ -48,6 +48,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
import java.util.Set;
import javax.imageio.event.IIOReadProgressListener;
@@ -1137,12 +1139,78 @@
*
* @param warning the warning message
*
- * @throw IllegalArgumentException if warning is null
+ * @exception IllegalArgumentException if warning is null
*/
protected void processWarningOccurred(String warning)
{
if (warning == null)
throw new IllegalArgumentException ("null argument");
+ if (warningListeners != null)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadWarningListener listener =
+ (IIOReadWarningListener) it.next();
+ listener.warningOccurred(this, warning);
+ }
+ }
+ }
+
+ /**
+ * Notify all installed warning listeners, by calling their
+ * warningOccurred methods, that a warning message has been raised.
+ * The warning message is retrieved from a resource bundle, using
+ * the given basename and keyword.
+ *
+ * @param baseName the basename of the resource from which to
+ * retrieve the warning message
+ * @param keyword the keyword used to retrieve the warning from the
+ * resource bundle
+ *
+ * @exception IllegalArgumentException if either baseName or keyword
+ * is null
+ * @exception IllegalArgumentException if no resource bundle is
+ * found using baseName
+ * @exception IllegalArgumentException if the given keyword produces
+ * no results from the resource bundle
+ * @exception IllegalArgumentException if the retrieved object is
+ * not a String
+ */
+ protected void processWarningOccurred(String baseName,
+ String keyword)
+ {
+ if (baseName == null || keyword == null)
+ throw new IllegalArgumentException ("null argument");
+
+ ResourceBundle b = null;
+
+ try
+ {
+ b = ResourceBundle.getBundle(baseName, getLocale());
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no resource bundle found");
+ }
+
+ Object str = null;
+
+ try
+ {
+ str = b.getObject(keyword);
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no results found for keyword");
+ }
+
+ if (! (str instanceof String))
+ throw new IllegalArgumentException ("retrieved object not a String");
+
+ String warning = (String) str;
+
if (warningListeners != null)
{
Iterator it = warningListeners.iterator();
Index: javax/imageio/ImageWriter.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageWriter.java,v
retrieving revision 1.8
diff -u -r1.8 ImageWriter.java
--- javax/imageio/ImageWriter.java 4 Oct 2005 15:43:32 -0000 1.8
+++ javax/imageio/ImageWriter.java 4 Oct 2005 18:30:34 -0000
@@ -47,6 +47,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
import javax.imageio.event.IIOWriteProgressListener;
import javax.imageio.event.IIOWriteWarningListener;
@@ -698,11 +700,80 @@
* when the warning was raised
* @param warning the warning message
*
- * @throw IllegalArgumentException if warning is null
+ * @exception IllegalArgumentException if warning is null
*/
protected void processWarningOccurred(int imageIndex, String warning)
{
if (warningListeners != null)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteWarningListener listener =
+ (IIOWriteWarningListener) it.next();
+ listener.warningOccurred(this, imageIndex, warning);
+ }
+ }
+ }
+
+ /**
+ * Notify all installed warning listeners, by calling their
+ * warningOccurred methods, that a warning message has been raised.
+ * The warning message is retrieved from a resource bundle, using
+ * the given basename and keyword.
+ *
+ * @param imageIndex the index of the image that was being written
+ * when the warning was raised
+ * @param baseName the basename of the resource from which to
+ * retrieve the warning message
+ * @param keyword the keyword used to retrieve the warning from the
+ * resource bundle
+ *
+ * @exception IllegalArgumentException if either baseName or keyword
+ * is null
+ * @exception IllegalArgumentException if no resource bundle is
+ * found using baseName
+ * @exception IllegalArgumentException if the given keyword produces
+ * no results from the resource bundle
+ * @exception IllegalArgumentException if the retrieved object is
+ * not a String
+ */
+ protected void processWarningOccurred(int imageIndex,
+ String baseName,
+ String keyword)
+ {
+ if (baseName == null || keyword == null)
+ throw new IllegalArgumentException ("null argument");
+
+ ResourceBundle b = null;
+
+ try
+ {
+ b = ResourceBundle.getBundle(baseName, getLocale());
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no resource bundle found");
+ }
+
+ Object str = null;
+
+ try
+ {
+ str = b.getObject(keyword);
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no results found for keyword");
+ }
+
+ if (! (str instanceof String))
+ throw new IllegalArgumentException ("retrieved object not a String");
+
+ String warning = (String) str;
+
+ if (warningListeners != null)
{
Iterator it = warningListeners.iterator();
Index: javax/imageio/ImageReader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageReader.java,v
retrieving revision 1.7
diff -u -r1.7 ImageReader.java
--- javax/imageio/ImageReader.java 4 Oct 2005 15:43:32 -0000 1.7
+++ javax/imageio/ImageReader.java 4 Oct 2005 18:03:31 -0000
@@ -1529,7 +1529,7 @@
Iterator imageTypes,
int width,
int height)
- throws IOException
+ throws IIOException
{
if (imageTypes == null || !imageTypes.hasNext())
throw new IllegalArgumentException ("imageTypes null or empty");
Index: javax/imageio/ImageTypeSpecifier.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageTypeSpecifier.java,v
retrieving revision 1.4
diff -u -r1.4 ImageTypeSpecifier.java
--- javax/imageio/ImageTypeSpecifier.java 2 Oct 2005 05:29:55 -0000
1.4
+++ javax/imageio/ImageTypeSpecifier.java 4 Oct 2005 18:03:31 -0000
@@ -253,9 +253,9 @@
* @exception if bits is larger than the number of bits in the given
* data type
*/
- public static ImageTypeSpecifier createGrayScale (int bits, int dataType,
boolean isSigned)
+ public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
boolean isSigned)
{
- return createGrayScale (bits, dataType, isSigned, false);
+ return createGrayscale (bits, dataType, isSigned, false);
}
/**
@@ -277,7 +277,7 @@
* @exception if bits is larger than the number of bits in the given
* data type
*/
- public static ImageTypeSpecifier createGrayScale (int bits, int dataType,
+ public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
boolean isSigned,
boolean
isAlphaPremultiplied)
{
@@ -323,12 +323,12 @@
* @exception if bits is larger than the number of bits in the given
* data type
*/
- public static ImageTypeSpecifier createIndex (byte[] redLUT,
- byte[] greenLUT,
- byte[] blueLUT,
- byte[] alphaLUT,
- int bits,
- int dataType)
+ public static ImageTypeSpecifier createIndexed (byte[] redLUT,
+ byte[] greenLUT,
+ byte[] blueLUT,
+ byte[] alphaLUT,
+ int bits,
+ int dataType)
{
if (redLUT == null || greenLUT == null || blueLUT == null)
throw new IllegalArgumentException ("null colour table");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: JAPI fixes for javax.imageio,
Thomas Fitzsimmons <=