Class ImageHandlerRegistry


  • public class ImageHandlerRegistry
    extends java.lang.Object
    This class holds references to various image handlers. It also supports automatic discovery of additional handlers available through the class path.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Comparator<ImageHandler> HANDLER_COMPARATOR  
      private java.util.List<ImageHandler> handlerList
      List containing the same handlers as above but ordered by priority
      private int handlerRegistrations  
      private java.util.Map<java.lang.Class<? extends org.apache.xmlgraphics.image.loader.Image>,​ImageHandler> handlers
      Map containing image handlers for various Image subclasses.
      private static org.apache.commons.logging.Log log
      the logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHandler​(java.lang.String classname)
      Add an PDFImageHandler.
      void addHandler​(ImageHandler handler)
      Add an image handler.
      private void discoverHandlers()
      Discovers ImageHandler implementations through the classpath and dynamically registers them.
      ImageHandler getHandler​(RenderingContext targetContext, org.apache.xmlgraphics.image.loader.Image image)
      Returns an ImageHandler which handles an specific image type given the MIME type of the image.
      org.apache.xmlgraphics.image.loader.ImageFlavor[] getSupportedFlavors​(RenderingContext context, org.apache.xmlgraphics.image.loader.Image image)
      Returns the ordered array of supported image flavors.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        private static org.apache.commons.logging.Log log
        the logger
      • HANDLER_COMPARATOR

        private static final java.util.Comparator<ImageHandler> HANDLER_COMPARATOR
      • handlers

        private java.util.Map<java.lang.Class<? extends org.apache.xmlgraphics.image.loader.Image>,​ImageHandler> handlers
        Map containing image handlers for various Image subclasses.
      • handlerList

        private java.util.List<ImageHandler> handlerList
        List containing the same handlers as above but ordered by priority
      • handlerRegistrations

        private int handlerRegistrations
    • Constructor Detail

      • ImageHandlerRegistry

        public ImageHandlerRegistry()
        Default constructor.
    • Method Detail

      • addHandler

        public void addHandler​(java.lang.String classname)
        Add an PDFImageHandler. The handler itself is inspected to find out what it supports.
        Parameters:
        classname - the fully qualified class name
      • addHandler

        public void addHandler​(ImageHandler handler)
        Add an image handler. The handler itself is inspected to find out what it supports.
        Parameters:
        handler - the ImageHandler instance
      • getHandler

        public ImageHandler getHandler​(RenderingContext targetContext,
                                       org.apache.xmlgraphics.image.loader.Image image)
        Returns an ImageHandler which handles an specific image type given the MIME type of the image.
        Parameters:
        targetContext - the target rendering context that is used for identifying compatibility
        image - the Image to be handled
        Returns:
        the image handler responsible for handling the image or null if none is available
      • getSupportedFlavors

        public org.apache.xmlgraphics.image.loader.ImageFlavor[] getSupportedFlavors​(RenderingContext context,
                                                                                     org.apache.xmlgraphics.image.loader.Image image)
        Returns the ordered array of supported image flavors. The array needs to be ordered by priority so the image loader framework can return the preferred image type.
        Parameters:
        context - the rendering context
        Returns:
        the array of image flavors
      • discoverHandlers

        private void discoverHandlers()
        Discovers ImageHandler implementations through the classpath and dynamically registers them.