Top Description Inners Fields Constructors Methods
org.apache.tomcat.util.buf

public final Class UEncoder

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.charset.StandardCharsets, java.util.BitSet

Efficient implementation of a UTF-8 encoder. This class is not thread safe - you need one encoder per thread. The encoder will save and recycle the internal objects, avoiding garbage. You can add extra characters that you want preserved, for example while encoding a URL you can add "/".
Author
Costin Manolache

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private ByteChunk
private C2BConverter
private CharChunk
private CharChunk
private BitSet

Constructor Summary

AccessConstructor and Description
public
UEncoder(UEncoder.SafeCharsSet
safe characters for this encoder
safeCharsSet
)

Create a UEncoder with an unmodifiable safe character set.

Method Summary

Modifier and TypeMethod and Description
public CharChunk

Returns:

A new CharChunk contained the URL encoded string
encodeURL
(String
string to be encoded
s
,
int
the beginning index, inclusive
start
,
int
the ending index, exclusive
end
)

URL Encode string, using a specified encoding.

private static BitSet
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bbback to summary
private ByteChunk bb
c2bback to summary
private C2BConverter c2b
cbback to summary
private CharChunk cb
outputback to summary
private CharChunk output
safeCharsback to summary
private BitSet safeChars

Constructor Detail

UEncoderback to summary
public UEncoder(UEncoder.SafeCharsSet safeCharsSet)

Create a UEncoder with an unmodifiable safe character set.

Parameters
safeCharsSet:UEncoder.SafeCharsSet

safe characters for this encoder

Method Detail

encodeURLback to summary
public CharChunk encodeURL(String s, int start, int end) throws IOException

URL Encode string, using a specified encoding.

Parameters
s:String

string to be encoded

start:int

the beginning index, inclusive

end:int

the ending index, exclusive

Returns:CharChunk

A new CharChunk contained the URL encoded string

Exceptions
IOException:
If an I/O error occurs
initialSafeCharsback to summary
private static BitSet initialSafeChars()
urlEncodeback to summary
protected void urlEncode(CharChunk out, ByteChunk bb) throws IOException
org.apache.tomcat.util.buf back to summary

public final Enum UEncoder.SafeCharsSet

extends Enum<UEncoder.SafeCharsSet>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final UEncoder.SafeCharsSet
private final BitSet
public static final UEncoder.SafeCharsSet

Constructor Summary

AccessConstructor and Description
private
SafeCharsSet(String additionalSafeChars)

Method Summary

Modifier and TypeMethod and Description
private BitSet
public static UEncoder.SafeCharsSet
public static UEncoder.SafeCharsSet[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DEFAULTback to summary
public static final UEncoder.SafeCharsSet DEFAULT
safeCharsback to summary
private final BitSet safeChars
WITH_SLASHback to summary
public static final UEncoder.SafeCharsSet WITH_SLASH

Constructor Detail

SafeCharsSetback to summary
private SafeCharsSet(String additionalSafeChars)

Method Detail

getSafeCharsback to summary
private BitSet getSafeChars()
valueOfback to summary
public static UEncoder.SafeCharsSet valueOf(String name)
valuesback to summary
public static UEncoder.SafeCharsSet[] values()