Package org.glassfish.grizzly.http.util
Class UEncoder
- java.lang.Object
-
- org.glassfish.grizzly.http.util.UEncoder
-
public final class UEncoder extends java.lang.ObjectEfficient 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
Constructors Constructor Description UEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSafeCharacter(char c)java.lang.StringencodeURL(java.lang.String url)Utility funtion to re-encode the URL.java.lang.StringencodeURL(java.lang.String uri, boolean toHexUpperCase)Utility function to re-encode the URL.voidsetEncoding(java.lang.String s)voidurlEncode(java.io.Writer buf, byte[] bytes, int off, int len)voidurlEncode(java.io.Writer buf, byte[] bytes, int off, int len, boolean toHexUpperCase)voidurlEncode(java.io.Writer buf, java.lang.String s)URL Encode string, using a specified encoding.voidurlEncode(java.io.Writer buf, java.lang.String s, boolean toHexUpperCase)URL Encode string, using a specified encoding.
-
-
-
Method Detail
-
setEncoding
public void setEncoding(java.lang.String s)
-
addSafeCharacter
public void addSafeCharacter(char c)
-
urlEncode
public void urlEncode(java.io.Writer buf, java.lang.String s) throws java.io.IOExceptionURL Encode string, using a specified encoding.- Parameters:
buf- theWriterto write the encoded result to.s- the String to encode.- Throws:
java.io.IOException
-
urlEncode
public void urlEncode(java.io.Writer buf, java.lang.String s, boolean toHexUpperCase) throws java.io.IOExceptionURL Encode string, using a specified encoding.- Parameters:
buf- theWriterto write the encoded result to.s- the String to encode.toHexUpperCase- the hex string will be in upper case- Throws:
java.io.IOException
-
urlEncode
public void urlEncode(java.io.Writer buf, byte[] bytes, int off, int len) throws java.io.IOException- Throws:
java.io.IOException
-
urlEncode
public void urlEncode(java.io.Writer buf, byte[] bytes, int off, int len, boolean toHexUpperCase) throws java.io.IOException- Throws:
java.io.IOException
-
encodeURL
public java.lang.String encodeURL(java.lang.String url)
Utility funtion to re-encode the URL. Still has problems with charset, since UEncoder mostly ignores it.- Parameters:
url-
-
encodeURL
public java.lang.String encodeURL(java.lang.String uri, boolean toHexUpperCase)Utility function to re-encode the URL. Still has problems with charset, since UEncoder mostly ignores it.- Parameters:
uri- the URI to encode.toHexUpperCase- the hex string will be in upper case
-
-