Class UrlDecoder


  • public class UrlDecoder
    extends java.lang.Object
    Adapted from java.net.URLDecoder, but defines instances for query string decoding versus URL path component decoding.

    The difference is important because a space is encoded as a + in a query string, but this is a valid value in a path component (and is therefore not decode back to a space).

    Author:
    Doug Donohoe
    See Also:
    URLDecoder, RFC-2396
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static UrlDecoder PATH_INSTANCE
      Encoder used to decode components of a path.

      For example: http://org.acme/foo/thispart/orthispart?butnot=thispart
      static UrlDecoder QUERY_INSTANCE
      Encoder used to decode name or value components of a query string.

      For example: http://org.acme/notthis/northis/oreventhis?buthis=isokay&asis=thispart
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String decode​(java.lang.String s, java.lang.String enc)  
      java.lang.String decode​(java.lang.String s, java.nio.charset.Charset enc)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • QUERY_INSTANCE

        public static final UrlDecoder QUERY_INSTANCE
        Encoder used to decode name or value components of a query string.

        For example: http://org.acme/notthis/northis/oreventhis?buthis=isokay&asis=thispart
      • PATH_INSTANCE

        public static final UrlDecoder PATH_INSTANCE
        Encoder used to decode components of a path.

        For example: http://org.acme/foo/thispart/orthispart?butnot=thispart
    • Method Detail

      • decode

        public java.lang.String decode​(java.lang.String s,
                                       java.nio.charset.Charset enc)
        Parameters:
        s - string to decode
        enc - encoding to decode with
        Returns:
        decoded string
        See Also:
        URLDecoder.decode(String, String)
      • decode

        public java.lang.String decode​(java.lang.String s,
                                       java.lang.String enc)
        Parameters:
        s - string to decode
        enc - encoding to decode with
        Returns:
        decoded string
        See Also:
        URLDecoder.decode(String, String)