/[classpath]/classpath/javax/imageio/spi/ServiceRegistry.java
ViewVC logotype

Diff of /classpath/javax/imageio/spi/ServiceRegistry.java

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

revision 1.1.2.4 by gnu_andrew, Tue Aug 2 20:12:35 2005 UTC revision 1.1.2.5 by tromey, Thu Dec 1 15:09:47 2005 UTC
# Line 121  public class ServiceRegistry Line 121  public class ServiceRegistry
121     * @throws ClassCastException if <code>categories</code> does not     * @throws ClassCastException if <code>categories</code> does not
122     * iterate over instances of {@link java.lang.Class}.     * iterate over instances of {@link java.lang.Class}.
123     */     */
124    public ServiceRegistry(Iterator categories)    public ServiceRegistry(Iterator<Class<?>> categories)
125    {    {
126      ArrayList cats = new ArrayList(/* expected size */ 10);      ArrayList cats = new ArrayList(/* expected size */ 10);
127    
# Line 178  public class ServiceRegistry Line 178  public class ServiceRegistry
178     * @throws IllegalArgumentException if <code>spi</code> is     * @throws IllegalArgumentException if <code>spi</code> is
179     * <code>null</code>.     * <code>null</code>.
180     */     */
181    public static Iterator lookupProviders(Class spi,    public static <T> Iterator<T> lookupProviders(Class<T> spi,
182                                           ClassLoader loader)                                                  ClassLoader loader)
183    {    {
184      return ServiceFactory.lookupProviders(spi, loader);      return ServiceFactory.lookupProviders(spi, loader);
185    }    }
# Line 200  public class ServiceRegistry Line 200  public class ServiceRegistry
200     *     *
201     * @see #lookupProviders(Class, ClassLoader)     * @see #lookupProviders(Class, ClassLoader)
202     */     */
203    public static Iterator lookupProviders(Class spi)    public static <T> Iterator<T> lookupProviders(Class<T> spi)
204    {    {
205      return ServiceFactory.lookupProviders(spi);      return ServiceFactory.lookupProviders(spi);
206    }    }
# Line 212  public class ServiceRegistry Line 212  public class ServiceRegistry
212     * @return an unmodifiable {@link     * @return an unmodifiable {@link
213     * java.util.Iterator}&lt;{@link java.lang.Class}&gt;.     * java.util.Iterator}&lt;{@link java.lang.Class}&gt;.
214     */     */
215    public Iterator getCategories()    public Iterator<Class<?>> getCategories()
216    {    {
217      return new Iterator()      return new Iterator()
218        {        {
# Line 317  public class ServiceRegistry Line 317  public class ServiceRegistry
317     * @throws ClassCastException if <code>provider</code> does not     * @throws ClassCastException if <code>provider</code> does not
318     * implement <code>category</code>.     * implement <code>category</code>.
319     */     */
320    public synchronized boolean registerServiceProvider(Object provider,    public synchronized <T> boolean registerServiceProvider(T provider,
321                                                        Class category)                                                            Class<T> category)
322    {    {
323      for (int i = 0; i < categories.length; i++)      for (int i = 0; i < categories.length; i++)
324        if (categories[i] == category)        if (categories[i] == category)
# Line 383  public class ServiceRegistry Line 383  public class ServiceRegistry
383     * #ServiceRegistry(Iterator) constructor} of this     * #ServiceRegistry(Iterator) constructor} of this
384     * <code>ServiceRegistry</code>.     * <code>ServiceRegistry</code>.
385     */     */
386    public synchronized void registerServiceProviders(Iterator providers)    public synchronized void registerServiceProviders(Iterator<?> providers)
387    {    {
388      if (providers == null)      if (providers == null)
389        throw new IllegalArgumentException();        throw new IllegalArgumentException();
# Line 467  public class ServiceRegistry Line 467  public class ServiceRegistry
467     * @throws ClassCastException if <code>provider</code> does not     * @throws ClassCastException if <code>provider</code> does not
468     * implement <code>category</code>.     * implement <code>category</code>.
469     */     */
470    public synchronized boolean deregisterServiceProvider(Object provider,    public synchronized <T> boolean deregisterServiceProvider(T provider,
471                                                          Class category)                                                              Class<T> category)
472    {    {
473      for (int i = 0; i < categories.length; i++)      for (int i = 0; i < categories.length; i++)
474        if (categories[i] == category)        if (categories[i] == category)
# Line 663  public class ServiceRegistry Line 663  public class ServiceRegistry
663     *     *
664     * @see #getServiceProviders(Class, Filter, boolean)     * @see #getServiceProviders(Class, Filter, boolean)
665     */     */
666    public Iterator getServiceProviders(Class category, boolean useOrdering)    public <T> Iterator<T> getServiceProviders(Class<T> category,
667                                                 boolean useOrdering)
668    {    {
669      return getServiceProviders(category, null, useOrdering);      return getServiceProviders(category, null, useOrdering);
670    }    }
# Line 691  public class ServiceRegistry Line 692  public class ServiceRegistry
692     * #ServiceRegistry(Iterator) constructor} of this     * #ServiceRegistry(Iterator) constructor} of this
693     * <code>ServiceRegistry</code>.     * <code>ServiceRegistry</code>.
694     */     */
695    public synchronized Iterator getServiceProviders(Class category,    public synchronized <T> Iterator<T> getServiceProviders(Class<T> category,
696                                                     Filter filter,                                                            Filter filter,
697                                                     boolean useOrdering)                                                            boolean useOrdering)
698    {    {
699      int catid;      int catid;
700      LinkedList provs;      LinkedList provs;
# Line 751  public class ServiceRegistry Line 752  public class ServiceRegistry
752     *     *
753     * @param providerClass a class to search for.     * @param providerClass a class to search for.
754     */     */
755    public synchronized Object getServiceProviderByClass(Class providerClass)    public synchronized <T> T getServiceProviderByClass(Class<T> providerClass)
756    {    {
757      if (providerClass == null)      if (providerClass == null)
758        throw new IllegalArgumentException();        throw new IllegalArgumentException();
# Line 772  public class ServiceRegistry Line 773  public class ServiceRegistry
773            {            {
774              Object provider = iter.next();              Object provider = iter.next();
775              if (providerClass.isInstance(provider))              if (providerClass.isInstance(provider))
776                return provider;                return (T) provider;
777            }            }
778        }        }
779    
# Line 799  public class ServiceRegistry Line 800  public class ServiceRegistry
800     * @see #unsetOrdering     * @see #unsetOrdering
801     * @see #getServiceProviders(Class, Filter, boolean)     * @see #getServiceProviders(Class, Filter, boolean)
802     */     */
803    public synchronized boolean setOrdering(Class category,    public synchronized <T> boolean setOrdering(Class<T> category,
804                                            Object firstProvider,                                                T firstProvider,
805                                            Object secondProvider)                                                T secondProvider)
806    {    {
807      return addConstraint(getCategoryID(category), firstProvider,      return addConstraint(getCategoryID(category), firstProvider,
808                           secondProvider);                           secondProvider);
# Line 826  public class ServiceRegistry Line 827  public class ServiceRegistry
827     *     *
828     * @see #setOrdering     * @see #setOrdering
829     */     */
830    public synchronized boolean unsetOrdering(Class category,    public synchronized <T> boolean unsetOrdering(Class<T> category,
831                                              Object firstProvider,                                                  T firstProvider,
832                                              Object secondProvider)                                                  T secondProvider)
833    {    {
834      return removeConstraint(getCategoryID(category),      return removeConstraint(getCategoryID(category),
835                              firstProvider, secondProvider);                              firstProvider, secondProvider);

Legend:
Removed from v.1.1.2.4  
changed lines
  Added in v.1.1.2.5

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