org.apache.xmlgraphics.image.loader.spi

## Class ImageImplRegistry

- java.lang.Object
- - org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry

-     public class ImageImplRegistry
      extends java.lang.Object

  This class is the registry for all implementations of the various service provider interfaces for the image package.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `INFINITE_PENALTY` Infinite penalty value which shall force any implementation to become ineligible.
    `protected static org.apache.commons.logging.Log` | `log` logger

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ImageImplRegistry()` Main constructor.
    `ImageImplRegistry(boolean discover)` Main constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `discoverClasspathImplementations()` Discovers all implementations in the application's classpath.
    `Penalty` | `getAdditionalPenalty(java.lang.String className)` Returns the additional penalty value set for a particular implementation class.
    `java.lang.String` | `getIccConverter()`
    `int` | `getImageConverterModifications()` Returns the number of modifications to the collection of registered ImageConverter instances.
    `java.util.Collection` | `getImageConverters()` Returns the Collection of registered ImageConverter instances.
    `ImageLoaderFactory[]` | `getImageLoaderFactories(ImageInfo imageInfo, ImageFlavor flavor)` Returns an array of `ImageLoaderFactory` instances that support the MIME type indicated by an `ImageInfo` object and can generate the given image flavor.
    `ImageLoaderFactory[]` | `getImageLoaderFactories(java.lang.String mime)` Returns an array of ImageLoaderFactory instances which support the given MIME type.
    `ImageLoaderFactory` | `getImageLoaderFactory(ImageInfo imageInfo, ImageFlavor flavor)` Returns the best ImageLoaderFactory supporting the `ImageInfo` and image flavor.
    `java.util.Iterator` | `getPreloaderIterator()` Returns an iterator over all registered ImagePreloader instances.
    `static ImageImplRegistry` | `newInstance()` Returns the default instance of the Image implementation registry.
    `void` | `registerConverter(ImageConverter converter)` Registers a new ImageConverter.
    `void` | `registerLoaderFactory(ImageLoaderFactory loaderFactory)` Registers a new ImageLoaderFactory.
    `void` | `registerPreloader(ImagePreloader preloader)` Registers a new ImagePreloader.
    `void` | `setAdditionalPenalty(java.lang.String className, Penalty penalty)` Sets an additional penalty for a particular implementation class for any of the interface administered by this registry class.
    `void` | `setICCConverter(java.lang.String iccConverter)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### log

          protected static final org.apache.commons.logging.Log log

      logger

    - #### INFINITE_PENALTY

          public static final int INFINITE_PENALTY

      Infinite penalty value which shall force any implementation to become ineligible.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ImageImplRegistry

          public ImageImplRegistry(boolean discover)

      Main constructor. This constructor allows to disable plug-in discovery for testing purposes.
      Parameters:
        `discover` - true if implementation classes shall automatically be discovered.

    - #### ImageImplRegistry

          public ImageImplRegistry()

      Main constructor.

  - ### Method Detail

    - #### newInstance

          public static ImageImplRegistry newInstance()

      Returns the default instance of the Image implementation registry.
      Returns:
        the default instance

    - #### discoverClasspathImplementations

          public void discoverClasspathImplementations()

      Discovers all implementations in the application's classpath.

    - #### registerPreloader

          public void registerPreloader(ImagePreloader preloader)

      Registers a new ImagePreloader.
      Parameters:
        `preloader` - An ImagePreloader instance

    - #### registerLoaderFactory

          public void registerLoaderFactory(ImageLoaderFactory loaderFactory)

      Registers a new ImageLoaderFactory.
      Parameters:
        `loaderFactory` - An ImageLoaderFactory instance

    - #### getImageConverters

          public java.util.Collection getImageConverters()

      Returns the Collection of registered ImageConverter instances.
      Returns:
        a Collection<ImageConverter>

    - #### getImageConverterModifications

          public int getImageConverterModifications()

      Returns the number of modifications to the collection of registered ImageConverter instances. This is used to detect changes in the registry concerning ImageConverters.
      Returns:
        the number of modifications

    - #### registerConverter

          public void registerConverter(ImageConverter converter)

      Registers a new ImageConverter.
      Parameters:
        `converter` - An ImageConverter instance

    - #### getPreloaderIterator

          public java.util.Iterator getPreloaderIterator()

      Returns an iterator over all registered ImagePreloader instances.
      Returns:
        an iterator over ImagePreloader instances.

    - #### getImageLoaderFactory

          public ImageLoaderFactory getImageLoaderFactory(ImageInfo imageInfo,
                                                          ImageFlavor flavor)

      Returns the best ImageLoaderFactory supporting the `ImageInfo` and image flavor. If there are multiple ImageLoaderFactories the one with the least usage penalty is selected.
      Parameters:
        `imageInfo` - the image info object
        `flavor` - the image flavor.
      Returns:
        an ImageLoaderFactory instance or null, if no suitable implementation was found

    - #### getImageLoaderFactories

          public ImageLoaderFactory[] getImageLoaderFactories(ImageInfo imageInfo,
                                                              ImageFlavor flavor)

      Returns an array of `ImageLoaderFactory` instances that support the MIME type indicated by an `ImageInfo` object and can generate the given image flavor.
      Parameters:
        `imageInfo` - the image info object
        `flavor` - the target image flavor
      Returns:
        the array of image loader factories

    - #### getImageLoaderFactories

          public ImageLoaderFactory[] getImageLoaderFactories(java.lang.String mime)

      Returns an array of ImageLoaderFactory instances which support the given MIME type. The instances are returned in no particular order.
      Parameters:
        `mime` - the MIME type to find ImageLoaderFactories for
      Returns:
        the array of ImageLoaderFactory instances

    - #### setAdditionalPenalty

          public void setAdditionalPenalty(java.lang.String className,
                                           Penalty penalty)

      Sets an additional penalty for a particular implementation class for any of the interface administered by this registry class. No checking is performed to verify if the className parameter is valid.
      Parameters:
        `className` - the fully qualified class name of the implementation class
        `penalty` - the additional penalty or null to clear any existing value

    - #### getAdditionalPenalty

          public Penalty getAdditionalPenalty(java.lang.String className)

      Returns the additional penalty value set for a particular implementation class. If no such value is set, 0 is returned.
      Parameters:
        `className` - the fully qualified class name of the implementation class
      Returns:
        the additional penalty value

    - #### setICCConverter

          public void setICCConverter(java.lang.String iccConverter)

    - #### getIccConverter

          public java.lang.String getIccConverter()

Copyright 1999-2025 The Apache Software Foundation. All Rights Reserved.