Class URLParameters


  • public class URLParameters
    extends Object
    Methods for creating and parsing URL-encoded parameter strings.
    • Constructor Detail

      • URLParameters

        public URLParameters()
    • Method Detail

      • getSortedParameterString

        public static String getSortedParameterString​(Map<String,​String> params)
        Creates a URL-encoded parameter string for the specified parameters. They will first be sorted by key. It uses UTF-8.
        Parameters:
        params - the parameters
        Returns:
        the parameter string
      • getParameterString

        public static String getParameterString​(Map<String,​String> params)
        Creates a URL-encoded parameter string for the specified parameters. It uses UTF-8.
        Parameters:
        params - the parameters
        Returns:
        the parameter string
      • parseParameterString

        public static Map<String,​String> parseParameterString​(String paramStr)
                                                             throws ParseException
        Parses a URL-encoded parameter string. It uses UTF-8.
        Parameters:
        paramStr - the parameter string
        Returns:
        the parameters
        Throws:
        ParseException - if the parameter string is invalid
      • extractParameterString

        public static String extractParameterString​(String url)
        Extracts a parameter string from the specified URL. It will search for a ? and return everything after that until a possible #. If there is no ? this method returns null.
        Parameters:
        url - the URL
        Returns:
        the parameter string or null
      • extractParameters

        public static Map<String,​String> extractParameters​(String url)
                                                          throws ParseException
        Extracts a parameter string from the specified URL and parses it into a map. It uses UTF-8. If the URL doesn't have a parameter string, this method returns null. This is a convenience method for extractParameterString() and parseParameterString().
        Parameters:
        url - the URL
        Returns:
        the parameter map or null
        Throws:
        ParseException - if the parameter string is invalid