Class CssUrlReplacer


  • public final class CssUrlReplacer
    extends Object
    Helper for replacing URLs in CSS files.
    Since:
    8.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • pluginServletTransformer

        public static UnaryOperator<String> pluginServletTransformer​(String baseUrl,
                                                                     Mandant client,
                                                                     String pluginName)
        Creates a transformer, compatible with the replace* methods. When an URI has the scheme plugin-resource , the URI is transformed to a URI for a action servlet plugin. The path of the URI is added as a query parameter to the URI. Query parameters are preserved as-is. URIs with other schemes and opaque URIs are not changed.
        Parameters:
        baseUrl - Base URL for the formcycle app.
        client - Optional client for client scoped servlet action plugins. When null, generates an URL for a system scoped servlet action plugin.
        pluginName - Name of the servlet action plugin.
        Returns:
        A transformer that transforms plugin-resource: URIs to action servlet plugin URIs.
      • replaceIgnoreErrors

        public static String replaceIgnoreErrors​(String css,
                                                 UnaryOperator<String> transformer)
        Processes a CSS file. Passes all URLs in the CSS file to the given transformer, and replaces the URL with the result of the transformer. If the transformer returns null, no replacement is made. If any error occurs, the original CSS is returned.
        Parameters:
        css - CSS to process.
        transformer - Transformer for the URLs.
        Returns:
        The CSS with the transformed URLs.
      • replaceUriIgnoreErrors

        public static String replaceUriIgnoreErrors​(String css,
                                                    UnaryOperator<URI> transformer)
        Processes a CSS file. Passes all URLs in the CSS file to the given transformer, and replaces the URL with the result of the transformer. If the transformer returns null, no replacement is made. If any error occurs, the original CSS is returned.
        Parameters:
        css - CSS to process.
        transformer - Transformer for the URLs.
        Returns:
        The CSS with the transformed URLs.