Class URLUtils


  • public class URLUtils
    extends Object
    • Field Detail

      • LOG

        protected static final org.slf4j.Logger LOG
    • Constructor Detail

      • URLUtils

        public URLUtils()
    • Method Detail

      • addParameterToURL

        public static String addParameterToURL​(String url,
                                               String paramName,
                                               String paramValue,
                                               boolean useEncoding)
      • getFullRequestUrl

        public static String getFullRequestUrl​(javax.servlet.http.HttpServletRequest request)
        Similar to HttpServletRequest.getRequestURL(), but also includes the query string parameters.
        Parameters:
        request - A servlet request to process.
        Returns:
        The reconstructed full request URL.
      • getFullRequestUri

        public static String getFullRequestUri​(javax.servlet.http.HttpServletRequest request)
        Similar to HttpServletRequest.getRequestURI(), but also includes the query string parameters.
        Parameters:
        request - A servlet request to process.
        Returns:
        The reconstructed full request URI.
      • setParameter

        public static String setParameter​(String url,
                                          String paramName,
                                          String paramValue,
                                          boolean useEncoding)
      • changeScheme

        public static String changeScheme​(String url,
                                          String newScheme)
        Changes the scheme of a URL (such as https) to the given schema.
        Parameters:
        url - URL to modify.
        newScheme - New schema for the URL.
        Returns:
        The URL with the new scheme.
      • removeParameter

        public static String removeParameter​(String url,
                                             String paramName)
      • removeParameter

        public static String removeParameter​(String url,
                                             String paramName,
                                             boolean useEncoding)
      • removeAllParametersAndFragment

        public static String removeAllParametersAndFragment​(String url)
        Parameters:
        url - A URL to process.
        Returns:
        The given URL with the fragment and all query parameters removed.
      • addQueryStringToURL

        public static String addQueryStringToURL​(String url,
                                                 String queryString)
      • addQueryStringToURL

        @Deprecated
        public static String addQueryStringToURL​(String url,
                                                 String queryString,
                                                 de.xima.cmn.filter.IGenericFilter<String> predicate)
        Adds each query parameter from the query string to which the predicate applies to the given URL.
        Parameters:
        url - URL to process.
        queryString - A query string to add to the URL, such as {@link ?foo=bar&hello=world}.
        predicate - Predicate that checks whether the parameter should be added. Only parameters to which the predicate applies are added.
        Returns:
        The given URL with the query parameters to which the predicate applies added.
      • addQueryStringToUrl

        public static String addQueryStringToUrl​(String url,
                                                 String queryString,
                                                 Predicate<String> predicate)
        Adds each query parameter from the query string to which the predicate applies to the given URL.
        Parameters:
        url - URL to process.
        queryString - A query string to add to the URL, such as {@link ?foo=bar&hello=world}.
        predicate - Predicate that checks whether the parameter should be added. Only parameters to which the predicate applies are added.
        Returns:
        The given URL with the query parameters to which the predicate applies added.
      • addQueryStringToURL

        public static String addQueryStringToURL​(String url,
                                                 Map<String,​String[]> queryStringParams)
        Adds all query parameters to the given URL.
        Parameters:
        url - URL to process.
        queryStringParams - Query parameters to add. applies are added.
        Returns:
        The given URL with the parameters added.
      • addQueryStringToURL

        @Deprecated
        public static String addQueryStringToURL​(String url,
                                                 Map<String,​String[]> queryStringParams,
                                                 de.xima.cmn.filter.IGenericFilter<String> predicate)
        Adds all query parameters to the given URL.
        Parameters:
        url - URL to process.
        queryStringParams - Query parameters to add.
        predicate - Predicate that checks whether the parameter should be added. Only parameters to which the predicate applies are added.
        Returns:
        The given URL with the parameters to which the predicate applies.
      • addQueryStringToUrl

        public static String addQueryStringToUrl​(String url,
                                                 Map<String,​String[]> queryStringParams,
                                                 Predicate<String> predicate)
        Parameters:
        url - URL to process.
        queryStringParams - Query parameters to add.
        predicate - Predicate that checks whether the parameter should be added. Only parameters to which the predicate applies are added.
        Returns:
        The given URL with the parameters to which the predicate applies..
      • encrypt

        public static String encrypt​(String str)
        Methode zum Verschlüsseln eines Strings
        Parameters:
        str - String to encrypt
        Returns:
        the encrypted String
      • getDataUriBytes

        public static URLUtils.DataUriBinary getDataUriBytes​(String dataUri)
        Fetches the binary data from a data URI. This will always returns the plain bytes, regardless of the encoding specified by the data URI.
        Parameters:
        dataUri - A data URI to parse.
        Returns:
        The binary data contained in the data URI.
      • decrypt

        public static String decrypt​(String str)
        Methode zum Entschlüsseln eines Strings
        Parameters:
        str - String to decrypt
        Returns:
        the decrypted String
      • decodeUrlArrayToList

        public static List<String> decodeUrlArrayToList​(String[] urlArray)
        Decodes a array of urls to a list of all decoded urls.
        Parameters:
        urlArray - A array of urls.
        Returns:
        decodedUrlList Decoded url list.