org.apache.catalina.util

## Class URLEncoder

- java.lang.Object
- - org.apache.catalina.util.URLEncoder

- All Implemented Interfaces:
    Cloneable

      public class URLEncoder
      extends Object
      implements Cloneable

  This class is very similar to the java.net.URLEncoder class. Unfortunately, with java.net.URLEncoder there is no way to specify to the java.net.URLEncoder which characters should NOT be encoded. This code was moved from DefaultServlet.java
  Author:
    Craig R. McClanahan, Remy Maucherat

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static URLEncoder` | `DEFAULT`
    `protected static char[]` | `hexadecimal`
    `static URLEncoder` | `QUERY`
    `protected BitSet` | `safeCharacters`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `URLEncoder()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSafeCharacter(char c)`
    `Object` | `clone()`
    `String` | `encode(String path)` Deprecated. Use `encode(String, String)`
    `String` | `encode(String path, String encoding)` URL encodes the provided path using the given encoding.
    `void` | `removeSafeCharacter(char c)`
    `void` | `setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus)`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### hexadecimal

          protected static final char[] hexadecimal

    - #### DEFAULT

          public static final URLEncoder DEFAULT

    - #### QUERY

          public static final URLEncoder QUERY

    - #### safeCharacters

          protected BitSet safeCharacters

  - ### Constructor Detail

    - #### URLEncoder

          public URLEncoder()

  - ### Method Detail

    - #### addSafeCharacter

          public void addSafeCharacter(char c)

    - #### removeSafeCharacter

          public void removeSafeCharacter(char c)

    - #### setEncodeSpaceAsPlus

          public void setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus)

    - #### encode

          @Deprecated
          public String encode(String path)

      Deprecated. Use `encode(String, String)`
      URL encodes the provided path using UTF-8.
      Parameters:
        `path` - The path to encode
      Returns:
        The encoded path

    - #### encode

          public String encode(String path,
                      String encoding)

      URL encodes the provided path using the given encoding.
      Parameters:
        `path` - The path to encode
        `encoding` - The encoding to use to convert the path to bytes
      Returns:
        The encoded path

    - #### clone

          public Object clone()

      Overrides:
        `clone` in class `Object`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.