com.isti.util
Class URLRefEncoder

java.lang.Object
  extended by com.isti.util.URLRefEncoder

public class URLRefEncoder
extends java.lang.Object

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:

Since:
JDK1.0
Version:
1.28, 01/23/03
Author:
Herb Jellinek

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

UTF8_ENC_STR

public static final java.lang.String UTF8_ENC_STR
The "UTF-8" character-encoding-specification string.

See Also:
Constant Field Values

dontNeedEncoding

static java.util.BitSet dontNeedEncoding

caseDiff

static final int caseDiff
See Also:
Constant Field Values
Method Detail

encode

public static java.lang.String encode(java.lang.String s)
Translates a string into x-www-form-urlencoded format. This method uses "UTF-8" encoding as the encoding scheme to obtain the bytes for unsafe characters.

Parameters:
s - String to be translated.
Returns:
the translated String.

encode

public static java.lang.String encode(java.lang.String s,
                                      java.lang.String enc)
                               throws java.io.UnsupportedEncodingException
Translates a string into 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.

Parameters:
s - String to be translated.
enc - The name of a supported character encoding.
Returns:
the translated String.
Throws:
java.io.UnsupportedEncodingException - If the named encoding is not supported.