org.apache.tomcat.util.buf

Class UEncoder


public final class UEncoder
extends java.lang.Object

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

Constructor Summary

UEncoder()

Method Summary

void
addSafeCharacter(char c)
String
encodeURL(String uri)
Utility funtion to re-encode the URL.
void
setEncoding(String s)
void
urlEncode(Writer buf, String s)
URL Encode string, using a specified encoding.
void
urlEncode(Writer buf, bytes[] , int off, int len)

Constructor Details

UEncoder

public UEncoder()

Method Details

addSafeCharacter

public void addSafeCharacter(char c)


encodeURL

public String encodeURL(String uri)
Utility funtion to re-encode the URL. Still has problems with charset, since UEncoder mostly ignores it.


setEncoding

public void setEncoding(String s)


urlEncode

public void urlEncode(Writer buf,
                      String s)
            throws IOException
URL Encode string, using a specified encoding.

Parameters:
s - string to be encoded


urlEncode

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


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.