com.sun.grizzly.util.buf
Class UEncoder
java.lang.Object
com.sun.grizzly.util.buf.UEncoder
public final class UEncoder
- extends 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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UEncoder
public UEncoder()
setEncoding
public void setEncoding(String s)
addSafeCharacter
public void addSafeCharacter(char c)
urlEncode
public void urlEncode(Writer buf,
String s)
throws IOException
- URL Encode string, using a specified encoding.
- Parameters:
s
- string to be encodedenc
- character encoding, for chars >%80 ( use UTF8 if not set,
as recommended in RFCs)reserved
- extra characters to preserve ( "/" - if s is a URL )
- Throws:
IOException
urlEncode
public void urlEncode(Writer buf,
byte[] bytes,
int off,
int len)
throws IOException
- Throws:
IOException
encodeURL
public String encodeURL(String uri)
- Utility funtion to re-encode the URL.
Still has problems with charset, since UEncoder mostly
ignores it.
Copyright © 2010 SUN Microsystems. All Rights Reserved.