classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: FYI: genericize javax.imageio


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: FYI: genericize javax.imageio
Date: 01 Dec 2005 08:01:14 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

I'm checking this in on the generics branch.

This genericizes javax.imageio.  There are a couple minor bug fixes
that were found when doing this.

I think this is the last set of packages that needed to be
genericized.

Tom

2005-12-01  Tom Tromey  <address@hidden>

        * javax/imageio/spi/RegisterableService.java (onRegistration):
        Genericized.
        (onDeregistration): Likewise.
        * javax/imageio/spi/ServiceRegistry.java (ServiceRegistry):
        Genericized.
        (deregisterServiceProvider): Likewise.
        (getCategories): Likewise.
        (getServiceProviderByClass): Likewise.
        (getServiceProviders): Likewise.
        (lookupProviders): Likewise.
        (registerServiceProvider): Likewise.
        (registerServiceProviders): Likewise.
        (setOrdering): Likewise.
        (unsetOrdering): Likewise.
        * javax/imageio/spi/ImageOutputStreamSpi.java (outputClass):
        Genericized.
        (ImageOutputStreamSpi): Likewise.
        (getOutputClass): Likewise.
        * javax/imageio/spi/ImageInputStreamSpi.java (inputClass):
        Genericized.
        (ImageInputStreamSpi): Likewise.
        (getInputClass): Likewise.
        * javax/imageio/metadata/IIOMetadataFormatImpl.java (addAttribute):
        Genericized.
        (addObjectValue): Likewise.
        * javax/imageio/metadata/IIOMetadataFormat.java (getObjectClass):
        Genericized.
        (getObjectMaxValue): Likewise.
        (getObjectMinValue): Likewise.
        * javax/imageio/ImageIO.java (getImageReaders): Genericized.
        (getImageReadersByFormatName): Likewise.
        (getImageReadersByMIMEType): Likewise.
        (getImageTranscoders): Likewise.
        (getImageWritersByFormatName): Likewise.
        (getImageWritersByMIMEType): Likewise.
        (getImageWritersBySuffix): Likewise.
        (getImageReader): Use getOriginatingProvider.
        (getImageWriter): Likewise.
        * javax/imageio/ImageWriter.java (progressListeners): Genericized.
        (warningListeners): Likewise.
        (warningLocales): Likewise.
        (prepareInsertEmpty): Likewise.
        (prepareWriteEmpty): Likewise.
        * javax/imageio/ImageReader.java (progressListeners): Genericized.
        (updateListeners): Likewise.
        (warningListeners): Likewise.
        (warningLocales): Likewise.
        (getDestination): Likewise.
        (getImageMetadata): Likewise.
        (getImageTypes): Likewise.
        (getStreamMetadata): Likewise.
        (readAll): Likewise.
        * javax/imageio/IIOImage.java (IIOImage): Genericized.
        (thumbnails): Likewise.
        (getThumbnails): Likewise.
        (setThumbnails): Likewise.

Index: javax/imageio/IIOImage.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/IIOImage.java,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 IIOImage.java
--- javax/imageio/IIOImage.java 2 Nov 2005 00:43:38 -0000       1.1.2.3
+++ javax/imageio/IIOImage.java 1 Dec 2005 14:59:21 -0000
@@ -79,8 +79,7 @@
   /**
    * A list of BufferedImage thumbnails of this image.
    */
-  // for 1.5 these lists are List<? extends BufferedImage>
-  protected List thumbnails;
+  protected List<? extends BufferedImage> thumbnails;
 
   /**
    * Construct an IIOImage containing raster image data, thumbnails
@@ -92,7 +91,8 @@
    *
    * @exception IllegalArgumentException if raster is null
    */
-  public IIOImage (Raster raster, List thumbnails, IIOMetadata metadata)
+  public IIOImage (Raster raster, List<? extends BufferedImage> thumbnails,
+                   IIOMetadata metadata)
   {
     if (raster == null)
       throw new IllegalArgumentException ("raster may not be null");
@@ -112,7 +112,8 @@
    *
    * @exception IllegalArgumentException if image is null
    */
-  public IIOImage (RenderedImage image, List thumbnails, IIOMetadata metadata)
+  public IIOImage (RenderedImage image, List<? extends BufferedImage> 
thumbnails,
+                   IIOMetadata metadata)
   {
     if (image == null)
       throw new IllegalArgumentException ("image may not be null");
@@ -192,7 +193,7 @@
    *
    * @return a list of thumbnails or null
    */
-  public List getThumbnails()
+  public List<? extends BufferedImage> getThumbnails()
   {
     return thumbnails;
   }
@@ -260,7 +261,7 @@
    *
    * @param thumbnails a new list of thumbnails or null
    */
-  public void setThumbnails (List thumbnails)
+  public void setThumbnails (List<? extends BufferedImage> thumbnails)
   {
     this.thumbnails = thumbnails;
   }
Index: javax/imageio/ImageIO.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageIO.java,v
retrieving revision 1.4.2.7
diff -u -r1.4.2.7 ImageIO.java
--- javax/imageio/ImageIO.java  2 Nov 2005 00:43:38 -0000       1.4.2.7
+++ javax/imageio/ImageIO.java  1 Dec 2005 14:59:22 -0000
@@ -436,7 +436,7 @@
    *
    * @exception IllegalArgumentException if formatName is null
    */
-  public static Iterator getImageReadersByFormatName(String formatName)
+  public static Iterator<ImageReader> getImageReadersByFormatName(String 
formatName)
   {
     if (formatName == null)
       throw new IllegalArgumentException("formatName may not be null");
@@ -457,7 +457,7 @@
    *
    * @exception IllegalArgumentException if MIMEType is null
    */
-  public static Iterator getImageReadersByMIMEType(String MIMEType)
+  public static Iterator<ImageReader> getImageReadersByMIMEType(String 
MIMEType)
   {
     if (MIMEType == null)
       throw new IllegalArgumentException("MIMEType may not be null");
@@ -497,7 +497,7 @@
    *
    * @exception IllegalArgumentException if formatName is null
    */
-  public static Iterator getImageWritersByFormatName(String formatName)
+  public static Iterator<ImageWriter> getImageWritersByFormatName(String 
formatName)
   {
     if (formatName == null)
       throw new IllegalArgumentException("formatName may not be null");
@@ -518,7 +518,7 @@
    *
    * @exception IllegalArgumentException if MIMEType is null
    */
-  public static Iterator getImageWritersByMIMEType(String MIMEType)
+  public static Iterator<ImageWriter> getImageWritersByMIMEType(String 
MIMEType)
   {
     if (MIMEType == null)
       throw new IllegalArgumentException("MIMEType may not be null");
@@ -538,7 +538,7 @@
    *
    * @exception IllegalArgumentException if fileSuffix is null
    */
-  public static Iterator getImageWritersBySuffix(String fileSuffix)
+  public static Iterator<ImageWriter> getImageWritersBySuffix(String 
fileSuffix)
   {
     if (fileSuffix == null)
       throw new IllegalArgumentException("fileSuffix may not be null");
@@ -1068,8 +1068,7 @@
     if (writer == null)
       throw new IllegalArgumentException ("null argument");
 
-    ImageWriterSpi spi = (ImageWriterSpi) getRegistry()
-      .getServiceProviderByClass(writer.getClass());
+    ImageWriterSpi spi = writer.getOriginatingProvider();
 
     String[] readerSpiNames = spi.getImageReaderSpiNames();
 
@@ -1098,12 +1097,12 @@
    *
    * @return an iterator over a collection of image readers
    */
-  public static Iterator getImageReaders (Object input)
+  public static Iterator<ImageReader> getImageReaders (Object input)
   {
     if (input == null)
       throw new IllegalArgumentException ("null argument");
 
-    return getRegistry().getServiceProviders (ImageReaderSpi.class,
+    return getRegistry().getServiceProviders (ImageReader.class,
                                              new ReaderObjectFilter(input),
                                              true);
   }
@@ -1149,8 +1148,7 @@
     if (reader == null)
       throw new IllegalArgumentException ("null argument");
 
-    ImageReaderSpi spi = (ImageReaderSpi) getRegistry()
-      .getServiceProviderByClass(reader.getClass());
+    ImageReaderSpi spi = reader.getOriginatingProvider();
 
     String[] writerSpiNames = spi.getImageWriterSpiNames();
 
@@ -1184,13 +1182,13 @@
    * @exception IllegalArgumentException if either reader or writer is
    * null
    */
-  public static Iterator getImageTranscoders (ImageReader reader,
-                                             ImageWriter writer)
+  public static Iterator<ImageTranscoder> getImageTranscoders (ImageReader 
reader,
+                                                               ImageWriter 
writer)
   {
     if (reader == null || writer == null)
       throw new IllegalArgumentException ("null argument");
 
-    return getRegistry().getServiceProviders (ImageTranscoderSpi.class,
+    return getRegistry().getServiceProviders (ImageTranscoder.class,
                                              new TranscoderFilter (reader,
                                                                     writer),
                                              true);
Index: javax/imageio/ImageReader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageReader.java,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 ImageReader.java
--- javax/imageio/ImageReader.java      2 Nov 2005 00:43:39 -0000       1.1.2.4
+++ javax/imageio/ImageReader.java      1 Dec 2005 14:59:22 -0000
@@ -116,7 +116,7 @@
    * A list of installed progress listeners.  Initially null, meaning
    * no installed listeners.
    */
-  protected List progressListeners = null;
+  protected List<IIOReadProgressListener> progressListeners = null;
 
   /**
    * true if this reader should only read data further ahead in the
@@ -129,19 +129,19 @@
    * A list of installed update listeners.  Initially null, meaning no
    * installed listeners.
    */
-  protected List updateListeners = null;
+  protected List<IIOReadUpdateListener> updateListeners = null;
 
   /**
    * A list of installed warning listeners.  Initially null, meaning
    * no installed listeners.
    */
-  protected List warningListeners = null;
+  protected List<IIOReadWarningListener> warningListeners = null;
 
   /**
    * A list of warning locales corresponding with the list of
    * installed warning listeners.  Initially null, meaning no locales.
    */
-  protected List warningLocales = null;
+  protected List<Locale> warningLocales = null;
 
   /**
    * Construct an image reader.
@@ -371,7 +371,7 @@
    * out-of-bounds
    * @exception IOException if a read error occurs
    */
-  public abstract Iterator getImageTypes(int imageIndex)
+  public abstract Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
     throws IOException;
 
   /**
@@ -1594,7 +1594,7 @@
    * height is greater than Integer.MAX_VALUE
    */
   protected static BufferedImage getDestination (ImageReadParam param,
-                                                Iterator imageTypes,
+                                                Iterator<ImageTypeSpecifier> 
imageTypes,
                                                 int width,
                                                 int height)
     throws IIOException
@@ -1694,7 +1694,7 @@
    */
   public IIOMetadata getImageMetadata (int imageIndex,
                                        String formatName,
-                                       Set nodeNames)
+                                       Set<String> nodeNames)
     throws IOException
   {
     if (formatName == null || nodeNames == null)
@@ -1808,7 +1808,7 @@
    * @exception IOException if a read error occurs
    */
   public IIOMetadata getStreamMetadata (String formatName,
-                                        Set nodeNames)
+                                        Set<String> nodeNames)
     throws IOException
   {
     if (formatName == null || nodeNames == null)
@@ -1915,7 +1915,7 @@
    * destination image regions are empty
    * @exception IOException if a read error occurs
    */
-  public Iterator readAll (Iterator params)
+  public Iterator<IIOImage> readAll (Iterator<? extends ImageReadParam> params)
     throws IOException
   {
     List l = new ArrayList ();
Index: javax/imageio/ImageWriter.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageWriter.java,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 ImageWriter.java
--- javax/imageio/ImageWriter.java      2 Nov 2005 00:43:39 -0000       1.1.2.4
+++ javax/imageio/ImageWriter.java      1 Dec 2005 14:59:22 -0000
@@ -40,6 +40,7 @@
 
 import java.awt.Dimension;
 import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
 import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
 import java.io.IOException;
@@ -102,19 +103,19 @@
    * A list of installed progress listeners.  Initially null, meaning
    * no installed listeners.
    */
-  protected List progressListeners = null;
+  protected List<IIOWriteProgressListener> progressListeners = null;
 
   /**
    * A list of installed warning listeners.  Initially null, meaning
    * no installed listeners.
    */
-  protected List warningListeners = null;
+  protected List<IIOWriteWarningListener> warningListeners = null;
 
   /**
    * A list of warning locales corresponding with the list of
    * installed warning listeners.  Initially null, meaning no locales.
    */
-  protected List warningLocales = null;
+  protected List<Locale> warningLocales = null;
 
   /**
    * Construct an image writer.
@@ -1076,7 +1077,7 @@
   public void prepareInsertEmpty (int imageIndex, ImageTypeSpecifier imageType,
                                   int width, int height,
                                   IIOMetadata imageMetadata,
-                                  List thumbnails,
+                                  List<? extends BufferedImage> thumbnails,
                                   ImageWriteParam param)
     throws IOException
   {
@@ -1149,7 +1150,7 @@
                                  ImageTypeSpecifier imageType,
                                  int width, int height,
                                  IIOMetadata imageMetadata,
-                                 List thumbnails,
+                                 List<? extends BufferedImage> thumbnails,
                                  ImageWriteParam param)
     throws IOException
   {
Index: javax/imageio/metadata/IIOMetadataFormat.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/imageio/metadata/IIOMetadataFormat.java,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 IIOMetadataFormat.java
--- javax/imageio/metadata/IIOMetadataFormat.java       2 Aug 2005 20:12:35 
-0000       1.3.2.2
+++ javax/imageio/metadata/IIOMetadataFormat.java       1 Dec 2005 14:59:22 
-0000
@@ -106,15 +106,15 @@
 
   int getObjectArrayMinLength (String elementName);
 
-  Class getObjectClass (String elementName);
+  Class<?> getObjectClass (String elementName);
 
   Object getObjectDefaultValue (String elementName);
 
   Object[] getObjectEnumerations (String elementName);
 
-  Comparable getObjectMaxValue (String elementName);
+  Comparable<?> getObjectMaxValue (String elementName);
 
-  Comparable getObjectMinValue (String elementName);
+  Comparable<?> getObjectMinValue (String elementName);
 
   int getObjectValueType (String elementName);
 
Index: javax/imageio/metadata/IIOMetadataFormatImpl.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/imageio/metadata/IIOMetadataFormatImpl.java,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 IIOMetadataFormatImpl.java
--- javax/imageio/metadata/IIOMetadataFormatImpl.java   2 Nov 2005 00:43:39 
-0000       1.1.2.3
+++ javax/imageio/metadata/IIOMetadataFormatImpl.java   1 Dec 2005 14:59:23 
-0000
@@ -462,7 +462,7 @@
                                int dataType,
                                boolean required,
                                String defaultValue,
-                               List enumeratedValues)
+                               List<String> enumeratedValues)
   {
     IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
     node.setAttributeNode (new IIOMetadataNodeAttrEnumerated (node,
@@ -568,8 +568,8 @@
     node.setUserObject (null);
   }
 
-  protected void addObjectValue (String elementName, Class classType,
-                                 boolean required, Object defaultValue)
+  protected <T> void addObjectValue (String elementName, Class<T> classType,
+                                     boolean required, T defaultValue)
   {
     IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
     addNodeObject (node, new NodeObject (node,
@@ -578,9 +578,9 @@
                                          defaultValue));
   }
 
-  protected void addObjectValue (String elementName, Class classType,
-                                 boolean required, Object defaultValue,
-                                 List enumeratedValues)
+  protected <T> void addObjectValue (String elementName, Class<T> classType,
+                                     boolean required, T defaultValue,
+                                     List<? extends T> enumeratedValues)
   {
     IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
     addNodeObject (node, new NodeObjectEnumerated (node,
@@ -590,12 +590,12 @@
                                                    enumeratedValues));
   }
 
-  protected void addObjectValue (String elementName, Class classType,
-                                 Object defaultValue,
-                                 Comparable minValue,
-                                 Comparable maxValue,
-                                 boolean minInclusive,
-                                 boolean maxInclusive)
+  protected <T> void addObjectValue (String elementName, Class<T> classType,
+                                     T defaultValue,
+                                     Comparable<? super T> minValue,
+                                     Comparable<? super T> maxValue,
+                                     boolean minInclusive,
+                                     boolean maxInclusive)
   {
     IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
     addNodeObject (node, new NodeObjectBounded (node,
@@ -607,7 +607,7 @@
                                                 maxInclusive));
   }
 
-  protected void addObjectValue (String elementName, Class classType,
+  protected void addObjectValue (String elementName, Class<?> classType,
                                  int arrayMinLength, int arrayMaxLength)
   {
     IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
Index: javax/imageio/spi/ImageInputStreamSpi.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/imageio/spi/ImageInputStreamSpi.java,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 ImageInputStreamSpi.java
--- javax/imageio/spi/ImageInputStreamSpi.java  2 Aug 2005 20:12:35 -0000       
1.1.2.3
+++ javax/imageio/spi/ImageInputStreamSpi.java  1 Dec 2005 14:59:23 -0000
@@ -59,7 +59,7 @@
    * Indicates which kind of input is processable by the streams
    * created by address@hidden #createInputStreamInstance(Object)}.
    */
-  protected Class inputClass;
+  protected Class<?> inputClass;
 
 
   /**
@@ -80,7 +80,7 @@
    * or <code>version</code> is <code>null</code>.
    */
   public ImageInputStreamSpi(String vendorName, String version,
-                             Class inputClass)
+                             Class<?> inputClass)
   {
     super(vendorName, version);
     this.inputClass = inputClass;
@@ -91,7 +91,7 @@
    * Determines which kind of input is processable by the streams
    * created by address@hidden #createInputStreamInstance(Object)}.
    */
-  public Class getInputClass()
+  public Class<?> getInputClass()
   {
     return inputClass;
   }
Index: javax/imageio/spi/ImageOutputStreamSpi.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/imageio/spi/ImageOutputStreamSpi.java,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 ImageOutputStreamSpi.java
--- javax/imageio/spi/ImageOutputStreamSpi.java 2 Aug 2005 20:12:35 -0000       
1.1.2.3
+++ javax/imageio/spi/ImageOutputStreamSpi.java 1 Dec 2005 14:59:23 -0000
@@ -59,7 +59,7 @@
    * Indicates which kind of output is produced by the streams
    * created by address@hidden #createOutputStreamInstance(Object)}.
    */
-  protected Class outputClass;
+  protected Class<?> outputClass;
 
 
   /**
@@ -80,7 +80,7 @@
    * or <code>version</code> is <code>null</code>.
    */
   public ImageOutputStreamSpi(String vendorName, String version,
-                              Class outputClass)
+                              Class<?> outputClass)
   {
     super(vendorName, version);
     this.outputClass = outputClass;
@@ -91,7 +91,7 @@
    * Determines which kind of output is produced by the streams
    * created by address@hidden #createOutputStreamInstance(Object)}.
    */
-  public Class getOutputClass()
+  public Class<?> getOutputClass()
   {
     return outputClass;
   }
Index: javax/imageio/spi/RegisterableService.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/imageio/spi/RegisterableService.java,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 RegisterableService.java
--- javax/imageio/spi/RegisterableService.java  2 Aug 2005 20:12:35 -0000       
1.1.2.2
+++ javax/imageio/spi/RegisterableService.java  1 Dec 2005 14:59:23 -0000
@@ -62,7 +62,7 @@
    * @param category the service category for which this provider has
    * been registered as an implementor.
    */
-  void onRegistration(ServiceRegistry registry, Class category);
+  void onRegistration(ServiceRegistry registry, Class<?> category);
 
 
   /**
@@ -78,6 +78,6 @@
    * @param category the service category for which this provider has
    * been registered as an implementor.
    */
-  void onDeregistration(ServiceRegistry registry, Class category);
+  void onDeregistration(ServiceRegistry registry, Class<?> category);
 }
 
Index: javax/imageio/spi/ServiceRegistry.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/spi/ServiceRegistry.java,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 ServiceRegistry.java
--- javax/imageio/spi/ServiceRegistry.java      2 Aug 2005 20:12:35 -0000       
1.1.2.4
+++ javax/imageio/spi/ServiceRegistry.java      1 Dec 2005 14:59:23 -0000
@@ -121,7 +121,7 @@
    * @throws ClassCastException if <code>categories</code> does not
    * iterate over instances of address@hidden java.lang.Class}.
    */
-  public ServiceRegistry(Iterator categories)
+  public ServiceRegistry(Iterator<Class<?>> categories)
   {
     ArrayList cats = new ArrayList(/* expected size */ 10);
 
@@ -178,8 +178,8 @@
    * @throws IllegalArgumentException if <code>spi</code> is
    * <code>null</code>.
    */
-  public static Iterator lookupProviders(Class spi,
-                                         ClassLoader loader)
+  public static <T> Iterator<T> lookupProviders(Class<T> spi,
+                                                ClassLoader loader)
   {
     return ServiceFactory.lookupProviders(spi, loader);
   }
@@ -200,7 +200,7 @@
    *
    * @see #lookupProviders(Class, ClassLoader)
    */
-  public static Iterator lookupProviders(Class spi)
+  public static <T> Iterator<T> lookupProviders(Class<T> spi)
   {
     return ServiceFactory.lookupProviders(spi);
   }
@@ -212,7 +212,7 @@
    * @return an unmodifiable address@hidden
    * java.util.Iterator}&lt;address@hidden java.lang.Class}&gt;.
    */
-  public Iterator getCategories()
+  public Iterator<Class<?>> getCategories()
   {
     return new Iterator()
       {
@@ -317,8 +317,8 @@
    * @throws ClassCastException if <code>provider</code> does not
    * implement <code>category</code>.
    */
-  public synchronized boolean registerServiceProvider(Object provider,
-                                                      Class category)
+  public synchronized <T> boolean registerServiceProvider(T provider,
+                                                          Class<T> category)
   {
     for (int i = 0; i < categories.length; i++)
       if (categories[i] == category)
@@ -383,7 +383,7 @@
    * #ServiceRegistry(Iterator) constructor} of this
    * <code>ServiceRegistry</code>.
    */
-  public synchronized void registerServiceProviders(Iterator providers)
+  public synchronized void registerServiceProviders(Iterator<?> providers)
   {
     if (providers == null)
       throw new IllegalArgumentException();
@@ -467,8 +467,8 @@
    * @throws ClassCastException if <code>provider</code> does not
    * implement <code>category</code>.
    */
-  public synchronized boolean deregisterServiceProvider(Object provider,
-                                                        Class category)
+  public synchronized <T> boolean deregisterServiceProvider(T provider,
+                                                            Class<T> category)
   {
     for (int i = 0; i < categories.length; i++)
       if (categories[i] == category)
@@ -663,7 +663,8 @@
    *
    * @see #getServiceProviders(Class, Filter, boolean)
    */
-  public Iterator getServiceProviders(Class category, boolean useOrdering)
+  public <T> Iterator<T> getServiceProviders(Class<T> category,
+                                             boolean useOrdering)
   {
     return getServiceProviders(category, null, useOrdering);
   }
@@ -691,9 +692,9 @@
    * #ServiceRegistry(Iterator) constructor} of this
    * <code>ServiceRegistry</code>.
    */
-  public synchronized Iterator getServiceProviders(Class category,
-                                                   Filter filter,
-                                                   boolean useOrdering)
+  public synchronized <T> Iterator<T> getServiceProviders(Class<T> category,
+                                                          Filter filter,
+                                                          boolean useOrdering)
   {
     int catid;
     LinkedList provs;
@@ -751,7 +752,7 @@
    * 
    * @param providerClass a class to search for.
    */
-  public synchronized Object getServiceProviderByClass(Class providerClass)
+  public synchronized <T> T getServiceProviderByClass(Class<T> providerClass)
   {
     if (providerClass == null)
       throw new IllegalArgumentException();
@@ -772,7 +773,7 @@
           {
             Object provider = iter.next();
             if (providerClass.isInstance(provider))
-              return provider;
+              return (T) provider;
           }
       }
 
@@ -799,9 +800,9 @@
    * @see #unsetOrdering
    * @see #getServiceProviders(Class, Filter, boolean)
    */
-  public synchronized boolean setOrdering(Class category,
-                                          Object firstProvider,
-                                          Object secondProvider)
+  public synchronized <T> boolean setOrdering(Class<T> category,
+                                              T firstProvider,
+                                              T secondProvider)
   {
     return addConstraint(getCategoryID(category), firstProvider,
                          secondProvider);
@@ -826,9 +827,9 @@
    *
    * @see #setOrdering
    */
-  public synchronized boolean unsetOrdering(Class category,
-                                            Object firstProvider,
-                                            Object secondProvider)
+  public synchronized <T> boolean unsetOrdering(Class<T> category,
+                                                T firstProvider,
+                                                T secondProvider)
   {
     return removeConstraint(getCategoryID(category),
                             firstProvider, secondProvider);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]