|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.isti.util.URLRefEncoder
public class URLRefEncoder
Class URLRefEncoder is a modified version of 'URLEncoder' that translates
a space to "%20" (instead of "+") and has a single-string 'encode()'
method that is not deprecated. The "%20" representation is appropriate
for HTML references. The code was modified after being lifted from the
"java.net.URLEncoder" class from Java 1.4.2_06.
Utility class for HTML form encoding. This class contains static methods
for converting a String to the application/x-www-form-urlencoded
MIME
format. For more information about HTML form encoding, consult the HTML
specification.
When encoding a String, the following rules apply:
a
" through
"z
", "A
" through
"Z
" and "0
"
through "9
" remain the same.
.
",
"-
", "*
", and
"_
" remain the same.
%xy
", where xy is the
two-digit hexadecimal representation of the byte.
The recommended encoding scheme to use is UTF-8.
Field Summary | |
---|---|
(package private) static int |
caseDiff
|
(package private) static java.util.BitSet |
dontNeedEncoding
|
static java.lang.String |
UTF8_ENC_STR
The "UTF-8" character-encoding-specification string. |
Method Summary | |
---|---|
static java.lang.String |
encode(java.lang.String s)
Translates a string into x-www-form-urlencoded
format. |
static java.lang.String |
encode(java.lang.String s,
java.lang.String enc)
Translates a string into application/x-www-form-urlencoded
format using a specific encoding scheme. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UTF8_ENC_STR
static java.util.BitSet dontNeedEncoding
static final int caseDiff
Method Detail |
---|
public static java.lang.String encode(java.lang.String s)
x-www-form-urlencoded
format. This method uses "UTF-8" encoding as the encoding
scheme to obtain the bytes for unsafe characters.
s
- String
to be translated.
String
.public static java.lang.String encode(java.lang.String s, java.lang.String enc) throws java.io.UnsupportedEncodingException
application/x-www-form-urlencoded
format using a specific encoding scheme. This method uses the
supplied encoding scheme to obtain the bytes for unsafe
characters.
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.
s
- String
to be translated.enc
- The name of a supported
character
encoding.
String
.
java.io.UnsupportedEncodingException
- If the named encoding is not supported.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |