Top Description Fields Constructors Methods
org.glassfish.grizzly.http.util

public final Class UEncoder

extends Object
Class Inheritance
Imports
java.io.CharArrayWriter, .IOException, .Writer, java.util.BitSet, java.util.logging.Level, .Logger, org.glassfish.grizzly.Grizzly

Efficient implementation for encoders. 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

Field Summary

Modifier and TypeField and Description
private ByteChunk
private C2BConverter
private static final int
private String
private static final BitSet
private static final Logger
private final BitSet

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public String
encodeURL(String url)

Utility funtion to re-encode the URL.

public String
encodeURL(String
the URI to encode.
uri
,
boolean
the hex string will be in upper case
toHexUpperCase
)

Utility function to re-encode the URL.

private static void
private static void
public void
public void
urlEncode(Writer
the Writer to write the encoded result to.
buf
,
String
the String to encode.
s
)

URL Encode string, using a specified encoding.

public void
urlEncode(Writer
the Writer to write the encoded result to.
buf
,
String
the String to encode.
s
,
boolean
the hex string will be in upper case
toHexUpperCase
)

URL Encode string, using a specified encoding.

public void
urlEncode(Writer buf, byte[] bytes, int off, int len)

public void
urlEncode(Writer buf, byte[] bytes, int off, int len, boolean toHexUpperCase)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bbback to summary
private ByteChunk bb
c2bback to summary
private C2BConverter c2b
debugback to summary
private static final int debug
encodingback to summary
private String encoding
initialSafeCharsback to summary
private static final BitSet initialSafeChars
loggerback to summary
private static final Logger logger
safeCharsback to summary
private final BitSet safeChars

Constructor Detail

UEncoderback to summary
public UEncoder()

Method Detail

addSafeCharacterback to summary
public void addSafeCharacter(char c)
encodeURLback to summary
public String encodeURL(String url)

Utility funtion to re-encode the URL. Still has problems with charset, since UEncoder mostly ignores it.

encodeURLback to summary
public String encodeURL(String uri, boolean toHexUpperCase)

Utility function to re-encode the URL. Still has problems with charset, since UEncoder mostly ignores it.

Parameters
uri:String

the URI to encode.

toHexUpperCase:boolean

the hex string will be in upper case

initSafeCharsback to summary
private static void initSafeChars()
logback to summary
private static void log(String s)
setEncodingback to summary
public void setEncoding(String s)
urlEncodeback to summary
public void urlEncode(Writer buf, String s) throws IOException

URL Encode string, using a specified encoding.

Parameters
buf:Writer

the Writer to write the encoded result to.

s:String

the String to encode.

urlEncodeback to summary
public void urlEncode(Writer buf, String s, boolean toHexUpperCase) throws IOException

URL Encode string, using a specified encoding.

Parameters
buf:Writer

the Writer to write the encoded result to.

s:String

the String to encode.

toHexUpperCase:boolean

the hex string will be in upper case

urlEncodeback to summary
public void urlEncode(Writer buf, byte[] bytes, int off, int len) throws IOException
urlEncodeback to summary
public void urlEncode(Writer buf, byte[] bytes, int off, int len, boolean toHexUpperCase) throws IOException