Top Description Fields Constructors Methods
org.apache.catalina.util

public final Class URLEncoder

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStreamWriter, java.nio.charset.Charset, java.util.BitSet

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
Authors
Craig R. McClanahan, Remy Maucherat

Field Summary

Modifier and TypeField and Description
public static final URLEncoder
private boolean
private static final char[]
public static final URLEncoder
private final BitSet

Constructor Summary

AccessConstructor and Description
public
private
URLEncoder(BitSet safeCharacters)

Method Summary

Modifier and TypeMethod and Description
public void
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public String

Returns:

The encoded path
encode
(String
The path to encode
path
,
Charset
The character set to use to convert the path to bytes
charset
)

URL encodes the provided path using the given character set.

public void
public void
setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus)

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULTback to summary
public static final URLEncoder DEFAULT
encodeSpaceAsPlusback to summary
private boolean encodeSpaceAsPlus
hexadecimalback to summary
private static final char[] hexadecimal
QUERYback to summary
public static final URLEncoder QUERY
safeCharactersback to summary
private final BitSet safeCharacters

Constructor Detail

URLEncoderback to summary
public URLEncoder()
URLEncoderback to summary
private URLEncoder(BitSet safeCharacters)

Method Detail

addSafeCharacterback to summary
public void addSafeCharacter(char c)
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
encodeback to summary
public String encode(String path, Charset charset)

URL encodes the provided path using the given character set.

Parameters
path:String

The path to encode

charset:Charset

The character set to use to convert the path to bytes

Returns:String

The encoded path

removeSafeCharacterback to summary
public void removeSafeCharacter(char c)
setEncodeSpaceAsPlusback to summary
public void setEncodeSpaceAsPlus(boolean encodeSpaceAsPlus)