Package org.apache.catalina.util
Class URLEncoder
- java.lang.Object
-
- org.apache.catalina.util.URLEncoder
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class URLEncoder extends java.lang.Object implements java.lang.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 Description static URLEncoder
DEFAULT
static URLEncoder
QUERY
-
Constructor Summary
Constructors Constructor Description URLEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSafeCharacter(char c)
java.lang.Object
clone()
java.lang.String
encode(java.lang.String path, java.nio.charset.Charset charset)
URL encodes the provided path using the given character set.void
removeSafeCharacter(char c)
void
setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus)
-
-
-
Field Detail
-
DEFAULT
public static final URLEncoder DEFAULT
-
QUERY
public static final URLEncoder QUERY
-
-
Method Detail
-
addSafeCharacter
public void addSafeCharacter(char c)
-
removeSafeCharacter
public void removeSafeCharacter(char c)
-
setEncodeSpaceAsPlus
public void setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus)
-
encode
public java.lang.String encode(java.lang.String path, java.nio.charset.Charset charset)
URL encodes the provided path using the given character set.- Parameters:
path
- The path to encodecharset
- The character set to use to convert the path to bytes- Returns:
- The encoded path
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
-