Class CssUrlReplacer

  • All Implemented Interfaces:
    ICssCompressor, IScopeAwareTextResourceProcessor, ITextResourceCompressor

    public class CssUrlReplacer
    extends java.lang.Object
    implements IScopeAwareTextResourceProcessor, ICssCompressor
    This compressor is used to replace URLs within CSS files with URLs created from PackageResourceReferences that belongs to their corresponding resources (e.g images).The scope of the CSS file is used to create the PackageResourceReferences. The compress method is not compressing any content, but replacing the URLs with Wicket representatives.

    Usage:
     this.getResourceSettings().setCssCompressor(new CssUrlReplacer());
     
    Since:
    6.20.0
    Author:
    Tobias Soloschenko
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EMBED_BASE64
      Used to be append to CSS URLs (background-image: url('Beer.gif?embedBase64');).
    • Constructor Summary

      Constructors 
      Constructor Description
      CssUrlReplacer()
      Creates a css url replacer
      CssUrlReplacer​(java.util.Collection<java.lang.String> excludes)
      Creates a css url replacer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String compress​(java.lang.String original)
      Remove comments and white spaces from the text resource
      java.util.Collection<java.lang.String> getExcludes()
      Gets excluded css file names
      java.lang.String process​(java.lang.String input, java.lang.Class<?> scope, java.lang.String name)
      Replaces the URLs of CSS resources with Wicket representatives.
      void setExcludes​(java.util.Collection<java.lang.String> excludes)
      Sets a list of css file names to be excluded
      • Methods inherited from class java.lang.Object

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

      • EMBED_BASE64

        public static final java.lang.String EMBED_BASE64
        Used to be append to CSS URLs (background-image: url('Beer.gif?embedBase64');). The CssUrlReplacer embeds the base64 content instead of using an URL.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CssUrlReplacer

        public CssUrlReplacer()
        Creates a css url replacer
      • CssUrlReplacer

        public CssUrlReplacer​(java.util.Collection<java.lang.String> excludes)
        Creates a css url replacer
        Parameters:
        excludes - css file names to be excluded
    • Method Detail

      • process

        public java.lang.String process​(java.lang.String input,
                                        java.lang.Class<?> scope,
                                        java.lang.String name)
        Replaces the URLs of CSS resources with Wicket representatives.
        Specified by:
        process in interface IScopeAwareTextResourceProcessor
        Parameters:
        input - The original input to process
        scope - The scope class of the package resource
        name - The name of the package resource
        Returns:
        The processed input
      • compress

        public java.lang.String compress​(java.lang.String original)
        Description copied from interface: ITextResourceCompressor
        Remove comments and white spaces from the text resource
        Specified by:
        compress in interface ITextResourceCompressor
        Returns:
        compressed text resource
      • getExcludes

        public java.util.Collection<java.lang.String> getExcludes()
        Gets excluded css file names
        Returns:
        a list with css file names to be excluded
      • setExcludes

        public void setExcludes​(java.util.Collection<java.lang.String> excludes)
        Sets a list of css file names to be excluded
        Parameters:
        excludes - a list with css file names to be excluded