Class UrlEncoder


  • public class UrlEncoder
    extends java.lang.Object
    A collection of utilities for encoding URLs.
    • Constructor Summary

      Constructors 
      Constructor Description
      UrlEncoder()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String urlDecode​(java.lang.String value)
      Decode a string for use in the path of a URL; uses URLDecoder.decode, which decodes a string for use in the query portion of a URL.
      static java.lang.String urlEncode​(java.lang.String value, boolean path)
      Encode a string for use in the path of a URL; uses URLEncoder.encode, (which encodes a string for use in the query portion of a URL), then applies some postfilters to fix things up per the RFC.
      • Methods inherited from class java.lang.Object

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

      • UrlEncoder

        public UrlEncoder()
    • Method Detail

      • urlEncode

        public static java.lang.String urlEncode​(java.lang.String value,
                                                 boolean path)
        Encode a string for use in the path of a URL; uses URLEncoder.encode, (which encodes a string for use in the query portion of a URL), then applies some postfilters to fix things up per the RFC. Can optionally handle strings which are meant to encode a path (ie include '/'es which should NOT be escaped).
        Parameters:
        value - the value to encode
        path - true if the value is intended to represent a path
        Returns:
        the encoded value
      • urlDecode

        public static java.lang.String urlDecode​(java.lang.String value)
        Decode a string for use in the path of a URL; uses URLDecoder.decode, which decodes a string for use in the query portion of a URL.
        Parameters:
        value - The value to decode
        Returns:
        The decoded value if parameter is not null, otherwise, null is returned.