Class URLUtils


  • public final class URLUtils
    extends Object

    Class to deal with URLs

    • Constructor Summary

      Constructors 
      Constructor Description
      URLUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String appendParamsToUrl​(String url, String params)
      Convenience call to add parameters to a url.
      static String decodeValue​(String val)
      Wrapper for URLDecoder.decode(val, "UTF-8");
      static String encodeValue​(String val)
      Wrapper for URLEncoder.encode(val, "UTF-8");
      static String getParamValue​(java.util.Map params, String key)
      Helper funtion to get single value from multiple value parameter Map
      static java.util.Map parseQueryStr​(String queryString, boolean doDecode)
      Parse query string part of url into Map of Lists (to support multiple values) of query parameters
      static String pathToFileURL​(String basePath)
      Convert a path to a url (file://[path])
      static String urlToId​(java.net.URL url)
      Create a MD5 message digest hash of a url
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • URLUtils

        public URLUtils()
    • Method Detail

      • pathToFileURL

        public static String pathToFileURL​(String basePath)
        Convert a path to a url (file://[path])
        Parameters:
        basePath - path
        Returns:
        file url
      • urlToId

        public static String urlToId​(java.net.URL url)
        Create a MD5 message digest hash of a url
        Parameters:
        url - url to hash
        Returns:
        hashed url
      • appendParamsToUrl

        public static String appendParamsToUrl​(String url,
                                               String params)
        Convenience call to add parameters to a url. If already has ? add &.
        Parameters:
        url - input url
        params - parameters in the form param1=val1¶m2=val2
        Returns:
        appended url
      • encodeValue

        public static String encodeValue​(String val)
        Wrapper for URLEncoder.encode(val, "UTF-8");
        Parameters:
        val - value to encode
        Returns:
        encoded value
      • decodeValue

        public static String decodeValue​(String val)
        Wrapper for URLDecoder.decode(val, "UTF-8");
        Parameters:
        val - value to decode
        Returns:
        decoded value
      • parseQueryStr

        public static java.util.Map parseQueryStr​(String queryString,
                                                  boolean doDecode)
        Parse query string part of url into Map of Lists (to support multiple values) of query parameters
        Parameters:
        queryString - query string
        doDecode - true to use URLDecoder.decode() to decode parameters
        Returns:
        Map of Lists
      • getParamValue

        public static String getParamValue​(java.util.Map params,
                                           String key)
        Helper funtion to get single value from multiple value parameter Map
        Parameters:
        params - params Map
        key - key string
        Returns:
        first value