Class URIUtil


  • public class URIUtil
    extends Object
    The URI escape and character encoding and decoding utility. It's compatible with {org.apache.commons.httpclient.HttpURL} rather than {org.apache.commons.httpclient.URI}.
    • Constructor Detail

      • URIUtil

        public URIUtil()
    • Method Detail

      • encodeQuery

        public static String encodeQuery​(String unescaped)
                                  throws org.apache.http.HttpException
        Escape and encode a string regarded as the query component of an URI with the default protocol charset. When a query string is not misunderstood the reserved special characters ("&", "=", "+", ",", and "$") within a query component, this method is recommended to use in encoding the whole query.
        Parameters:
        unescaped - an unescaped string
        Returns:
        the escaped string
        Throws:
        org.apache.http.HttpException - if the default protocol charset is not supported
        See Also:
        encode(java.lang.String, java.util.BitSet)
      • encodeQuery

        public static String encodeQuery​(String unescaped,
                                         String charset)
                                  throws org.apache.http.HttpException
        Escape and encode a string regarded as the query component of an URI with a given charset. When a query string is not misunderstood the reserved special characters ("&", "=", "+", ",", and "$") within a query component, this method is recommended to use in encoding the whole query.
        Parameters:
        unescaped - an unescaped string
        charset - the charset
        Returns:
        the escaped string
        Throws:
        org.apache.http.HttpException - if the charset is not supported
        See Also:
        encode(java.lang.String, java.util.BitSet)
      • encode

        public static String encode​(String unescaped,
                                    BitSet allowed)
                             throws org.apache.http.HttpException
        Escape and encode a given string with allowed characters not to be escaped and the default protocol charset.
        Parameters:
        unescaped - a string
        allowed - allowed characters not to be escaped
        Returns:
        the escaped string
        Throws:
        org.apache.http.HttpException - if the default protocol charset is not supported
      • encode

        public static String encode​(String unescaped,
                                    BitSet allowed,
                                    String charset)
                             throws org.apache.http.HttpException
        Escape and encode a given string with allowed characters not to be escaped and a given charset.
        Parameters:
        unescaped - a string
        allowed - allowed characters not to be escaped
        charset - the charset
        Returns:
        the escaped string
        Throws:
        org.apache.http.HttpException
      • decode

        public static String decode​(String escaped)
                             throws org.apache.http.HttpException
        Unescape and decode a given string regarded as an escaped string with the default protocol charset.
        Parameters:
        escaped - a string
        Returns:
        the unescaped string
        Throws:
        org.apache.http.HttpException - if the string cannot be decoded (invalid)
      • decode

        public static String decode​(String escaped,
                                    String charset)
                             throws org.apache.http.HttpException
        Unescape and decode a given string regarded as an escaped string.
        Parameters:
        escaped - a string
        charset - the charset
        Returns:
        the unescaped string
        Throws:
        org.apache.http.HttpException - if the charset is not supported