harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r927838 - in /harmony/enhanced/trunk/classlib/modules/imageio/src/main/java: javax/imageio/ImageIO.java javax/imageio/spi/ImageReaderSpi.java org/apache/harmony/x/imageio/internal/nls/messages.properties
Date Fri, 26 Mar 2010 13:22:02 GMT
Author: tellison
Date: Fri Mar 26 13:22:02 2010
New Revision: 927838

URL: http://svn.apache.org/viewvc?rev=927838&view=rev
Log:
Apply modified patch for HARMONY-6482 (Implementation of getImageWriter, getImageReader)

Modified:
    harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java
    harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
    harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties

Modified: harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java?rev=927838&r1=927837&r2=927838&view=diff
==============================================================================
--- harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java
(original)
+++ harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/ImageIO.java
Fri Mar 26 13:22:02 2010
@@ -217,14 +217,63 @@ public final class ImageIO {
                 new MIMETypeFilter(MIMEType), true));
     }
 
-    public static ImageWriter getImageWriter(ImageReader reader) throws NotImplementedException
{
-        // TODO: implement
-        throw new NotImplementedException();
+    public static ImageWriter getImageWriter(ImageReader reader) {
+        if (reader == null) {
+            // imageio.97=Reader cannot be null
+            throw new IllegalArgumentException(Messages.getString("imageio.97")); //$NON-NLS-1$
+        }
+
+        ImageReaderSpi readerSpi = reader.getOriginatingProvider();
+        if (readerSpi.getImageWriterSpiNames() == null) {
+            return null;
+        }
+
+        String writerSpiName = readerSpi.getImageWriterSpiNames()[0];
+
+        Iterator<ImageWriterSpi> writerSpis;
+        writerSpis = registry.getServiceProviders(ImageWriterSpi.class, true);
+
+        try {
+            while (writerSpis.hasNext()) {
+                ImageWriterSpi writerSpi = writerSpis.next();
+                if (writerSpi.getClass().getName().equals(writerSpiName)) {
+                    return writerSpi.createWriterInstance();
+                }
+            }
+        } catch (IOException e) {
+            // Ignored
+        }
+
+        return null;
     }
 
-    public static ImageReader getImageReader(ImageWriter writer) throws NotImplementedException
{
-        // TODO: implement
-        throw new NotImplementedException();
+    public static ImageReader getImageReader(ImageWriter writer) {
+        if (writer == null) {
+            // imageio.96=Writer cannot be null
+            throw new IllegalArgumentException(Messages.getString("imageio.96")); //$NON-NLS-1$
+        }
+        ImageWriterSpi writerSpi = writer.getOriginatingProvider();
+        if (writerSpi.getImageReaderSpiNames() == null) {
+            return null;
+        }
+
+        String readerSpiName = writerSpi.getImageReaderSpiNames()[0];
+
+        Iterator<ImageReaderSpi> readerSpis;
+        readerSpis = registry.getServiceProviders(ImageReaderSpi.class, true);
+
+        try {
+            while (readerSpis.hasNext()) {
+                ImageReaderSpi readerSpi = readerSpis.next();
+                if (readerSpi.getClass().getName().equals(readerSpiName)) {
+                    return readerSpi.createReaderInstance();
+                }
+            }
+        } catch (IOException e) {
+            // Ignored
+        }
+
+        return null;
     }
 
     public static Iterator<ImageWriter> getImageWriters(ImageTypeSpecifier type,

Modified: harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java?rev=927838&r1=927837&r2=927838&view=diff
==============================================================================
--- harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
(original)
+++ harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ImageReaderSpi.java
Fri Mar 26 13:22:02 2010
@@ -83,8 +83,7 @@ public abstract class ImageReaderSpi ext
         throw new NotImplementedException();
     }
 
-    public String[] getImageWriterSpiNames() throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public String[] getImageWriterSpiNames() {
+        return writerSpiNames;
     }
 }

Modified: harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties?rev=927838&r1=927837&r2=927838&view=diff
==============================================================================
--- harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties
(original)
+++ harmony/enhanced/trunk/classlib/modules/imageio/src/main/java/org/apache/harmony/x/imageio/internal/nls/messages.properties
Fri Mar 26 13:22:02 2010
@@ -164,3 +164,6 @@ imageio.92=Unknown category: {0}
 imageio.93=Illegal table size: {0}
 imageio.94=Output {0} is not supported
 imageio.95=Input is not an instance of java.io.RandomAccessFile
+imageio.96=Writer cannot be null
+imageio.97=Reader cannot be null
+



Mime
View raw message