Class ImageRemapperUtil


public class ImageRemapperUtil
extends Object
Utility class for working with image remapping.
  • Field Details

    • servletContext

      private static ServletContext servletContext
    • currentImageRemapper

      private static ImageRemapper currentImageRemapper
    • newMapperIsNeeded

      private static transient boolean newMapperIsNeeded
  • Constructor Details

    • ImageRemapperUtil

      public ImageRemapperUtil()
  • Method Details

    • init

      public static void init​(ServletContext context)
      Initialized at server startup.
    • getNewImageRemapperIfNeeded

      public static ImageRemapper getNewImageRemapperIfNeeded​(ServletContext context)
      Get a new image remapper if it is needed, otherwise null. Once the remapping is complete, use setCurrentMapper(ImageRemapper) to change the current image remapper.
    • getCurrentMapper

      public static ImageRemapper getCurrentMapper()
      Get the current image remapper. Can be null if remapping is not needed.
    • setCurrentMapper

      public static void setCurrentMapper​(ImageRemapper remapper)
      Changes the current image remapper. The remapping should have been complete before calling this method since the image remapper is not thread-safe for writing. If the new remapper size is 0 the current remapper is set to null.
    • remapAllTo

      public static void remapAllTo​(ImageRemapper mapper, String url)
      Scan the given url for images (png and gif) and remap them. The url can be a path that is relative the root of the server or root of the context. It should always start with a /. The remapping is done so that the given path is searched recursively and the subpaths found are remapped the full path. For example, if url is /extensions/example.jar/remap and this folder contains a subfolder with two images (images/baselogo.png and images/cancel.png) the following remap is done: /images/baselogo.png --> /extensions/example.jar/remap/images/baselogo.png /images/cancel.png --> /extensions/example.jar/remap/images/cancel.png