Object UrlEncoderUtil

  • All Implemented Interfaces:

    
    public class UrlEncoderUtil
    
                        

    Most defensive approach to URL encoding and decoding.

    • Rules determined by combining the unreserved character set from RFC 3986 with the percent-encode set from application/x-www-form-urlencoded.

    • Both specs above support percent decoding of two hexadecimal digits to a binary octet, however their unreserved set of characters differs and application/x-www-form-urlencoded adds conversion of space to +, which has the potential to be misunderstood.

    • This library encodes with rules that will be decoded correctly in either case.

    Author:

    Geert Bevin (gbevin(remove) at uwyn dot com)

    Erik C. Thauvin (erik@thauvin.net)

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String decode(String source, Boolean plusToSpace) Transforms a provided String into a new string, containing decoded URL characters in the UTF-8 encoding.
      final String encode(String source, String allow, Boolean spaceToPlus) Transforms a provided String object into a new string, containing only valid URL characters in the UTF-8 encoding.
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • decode

         final String decode(String source, Boolean plusToSpace)

        Transforms a provided String into a new string, containing decoded URL characters in the UTF-8 encoding.

      • encode

         final String encode(String source, String allow, Boolean spaceToPlus)

        Transforms a provided String object into a new string, containing only valid URL characters in the UTF-8 encoding.

        • Letters, numbers, unreserved (_-!.'()*) and allowed characters are left intact.