Class URLEncDec


  • public class URLEncDec
    extends Object
    • Constructor Detail

      • URLEncDec

        public URLEncDec()
    • Method Detail

      • encode

        public static String encode​(String s)
        Translates a string into application/x-www-form-urlencoded format using the UTF-8 encoding scheme. The World Wide Web Consortium Recommendation states that UTF-8 should be used to ensure compatibilities.
        Parameters:
        s - String to be translated.
        Returns:
        the translated String.
      • appendQueryParameter

        public static String appendQueryParameter​(String url,
                                                  String name,
                                                  String value)
        Puts a query parameter on a URL, encoding it and keeping it in front of the fragment.

        A plain concatenation puts the parameter inside the fragment of a URL such as /openam/XUI/#login, where the server never gets to see it, and leaves any reserved character in the value to be read back as part of the query string.

        An occurrence of the same name already on the URL is dropped rather than appended next to. Every consumer reads the parameter back with ServletRequest.getParameter(String), where the first occurrence wins, so a caller who put one there first would otherwise stay in charge of the value.

        Parameters:
        url - The URL to put the parameter on, may be null.
        name - The name of the parameter, in its decoded form. A null or empty name leaves the URL as it stands: there is no parameter to put on it.
        value - The value of the parameter, in its decoded form. A null value is written as an empty one, the way a parameter carrying nothing is spelled on a query string.
        Returns:
        The URL carrying the query parameter, or null if the URL was.
      • decode

        public static String decode​(String s)
        Decodes a application/x-www-form-urlencoded string using the UTF-8 encoding scheme. The World Wide Web Consortium Recommendation states that UTF-8 should be used to ensure compatibilities.
        Parameters:
        s - the String to decode
        Returns:
        the newly decoded String
      • encodeLDAPUrl

        public static String encodeLDAPUrl​(String s)