harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r954730 - in /harmony/enhanced/java/trunk/classlib/modules/imageio/src: main/java/javax/imageio/spi/ServiceRegistry.java test/java/javax/imageio/spi/ServiceRegistryTest.java
Date Tue, 15 Jun 2010 07:38:22 GMT
Author: aaf
Date: Tue Jun 15 07:38:22 2010
New Revision: 954730

URL: http://svn.apache.org/viewvc?rev=954730&view=rev
Log:
Committed Lang's patch for HARMONY-6551: implemented ServiceRegistry.contains().

Modified:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java?rev=954730&r1=954729&r2=954730&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/ServiceRegistry.java
Tue Jun 15 07:38:22 2010
@@ -112,9 +112,12 @@ public class ServiceRegistry {
         //deregisterAll();
     }
 
-    public boolean contains(Object provider) throws NotImplementedException {
-        // TODO: implement
-        throw new NotImplementedException();
+    public boolean contains(Object provider) {
+        if (provider == null) {
+            throw new IllegalArgumentException(Messages.getString("imageio.5E"));
+        }
+        
+        return categories.contains(provider);
     }
 
     public Iterator<Class<?>> getCategories() {
@@ -134,6 +137,17 @@ public class ServiceRegistry {
             this.registry = registry;
         }
 
+        boolean contains(Object provider) {
+            for (Map.Entry<Class<?>, ProvidersMap> e : categories.entrySet())
{
+                ProvidersMap providers = e.getValue();
+                if (providers.contains(provider)) {
+                    return true;
+                }
+            }
+            
+            return false;
+        }
+
         <T> boolean setOrdering(Class<T> category, T firstProvider, T secondProvider)
{
             ProvidersMap providers = categories.get(category);
             
@@ -269,6 +283,10 @@ public class ServiceRegistry {
             return true;
         }
 
+        boolean contains(Object provider) {
+            return providers.containsValue(provider);
+        }
+
         boolean removeProvider(Object provider,
                 ServiceRegistry registry, Class<?> category) {
             

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java?rev=954730&r1=954729&r2=954730&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/test/java/javax/imageio/spi/ServiceRegistryTest.java
Tue Jun 15 07:38:22 2010
@@ -31,6 +31,21 @@ import javax.imageio.spi.ImageWriterSpi;
 
 public class ServiceRegistryTest extends TestCase {
     
+	public void testContains() {
+		Class[] CATEGORIES = new Class[] {
+                ImageReaderSpi.class };
+        
+        ServiceRegistry registry = new ServiceRegistry(Arrays.<Class<?>> asList(CATEGORIES).iterator());
+        
+        ImageReaderSpi reader1 = new SampleImageReaderSpi();
+        ImageReaderSpi reader2 = new SampleImageReaderSpi();
+        
+        registry.registerServiceProvider(reader1, CATEGORIES[0]);
+        
+        assertTrue("Failed to check if reader1 registered", registry.contains(reader1));
+        assertFalse("Failed to check if reader2 registered", registry.contains(reader2));
       
+	}
+	
     public void testGetServiceProviders() {
         Class[] CATEGORIES = new Class[] {
                 ImageReaderSpi.class };



Mime
View raw message