Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboEncodeHelper

java.lang.Object
 |
 +--com.sssw.fw.util.EboEncodeHelper

public class EboEncodeHelper
extends Object

This utility class provides helper methods for url string encoding/decoding.


Field Summary
static String DEFAULT_ENCODING
          This is the default character encoding used for non-ASCII characters in URLs.
 
Constructor Summary
EboEncodeHelper()
           
 
Method Summary
static String escape(String s)
          Escapes a string (using the % escape character) for use as part of an URL.
static String escape(String s, String encoding)
          Escapes a string (using the % escape character) for use as part of an URL, using the specified character encoding.
static String escape(String s, String encoding, boolean spacesAsPluses, boolean encodePluses, boolean encodeSlashes)
          Escapes a string (using the % escape character) for use as part of an URL, using the specified character encoding.
static String unescape(String s)
          Undo the effects of the 'escape' method above.
static String unescape(String s, String encoding)
          Undo the effects of the 'escape' method above, using the specified encoding (usually UTF8, but may be overridden).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
This is the default character encoding used for non-ASCII characters in URLs. There are a couple of Internet drafts: draft-duerst-query-i18n-00.txt draft-masinter-url-i18n-01.txt from http://www.ics.uci.edu/pub/ietf/uri that describe the (proposed) scheme for encoding non-ASCII characters in URLs and in x-www-form-urlencoded forms.
Constructor Detail

EboEncodeHelper

public EboEncodeHelper()
Method Detail

escape

public static String escape(String s)
Escapes a string (using the % escape character) for use as part of an URL.

Note: Do not pass an URL to this function, as all reserved characters will be escaped .

Characters that will not be escaped are: alpha characters, digits, the plus character, and those in the SAFE and EXTRA lists, as defined in RFC1630, available at the time of this writing at: http://www.w3.org/pub/www/addressing/rfc1630.txt.

Parameters:
s - the string to escape
Returns:
the escaped string

escape

public static String escape(String s,
                            String encoding)
                     throws UnsupportedEncodingException
Escapes a string (using the % escape character) for use as part of an URL, using the specified character encoding. Most of the time, most systems should use UTF8 as the encoding, but this function supports the use of other encodings for backward compatibility -- e.g. with Japanese browswers. Note: Do not pass an URL to this function, as all reserved characters will be escaped .

Characters that will not be escaped are: alpha characters, digits, the plus character, and those in the SAFE and EXTRA lists, as defined in RFC1630, available at the time of this writing at: http://www.w3.org/pub/www/addressing/rfc1630.txt.

Parameters:
s - the string to escape
encoding - the encoding to use
Returns:
the escaped string

escape

public static String escape(String s,
                            String encoding,
                            boolean spacesAsPluses,
                            boolean encodePluses,
                            boolean encodeSlashes)
                     throws UnsupportedEncodingException
Escapes a string (using the % escape character) for use as part of an URL, using the specified character encoding. Most of the time, most systems should use UTF8 as the encoding, but this function supports the use of other encodings for backward compatibility -- e.g. with Japanese browswers. Note: Do not pass an URL to this function, as all reserved characters will be escaped .

Characters that will not be escaped are: alpha characters, digits, and those in the SAFE and EXTRA lists, as defined in RFC1630, available at the time of this writing at: http://www.w3.org/pub/www/addressing/rfc1630.txt.

Parameters:
s - the string to escape
encoding - the encoding to use
spacesAsPluses - specifies whether or not to encode spaces as plus signs
encodePluses - specifies whether or not to encode plus signs
encodeSlashes - specifies whether or not to encode slashes
Returns:
the escaped string

unescape

public static String unescape(String s)
Undo the effects of the 'escape' method above.
Note that this method will throw a StringIndexOutOfBoundsException or IllegalArgumentException if given an illegal string.

unescape

public static String unescape(String s,
                              String encoding)
                       throws UnsupportedEncodingException
Undo the effects of the 'escape' method above, using the specified encoding (usually UTF8, but may be overridden).
Note that this method will throw a StringIndexOutOfBoundsException or IllegalArgumentException if given an illegal string.

Novell exteNd
Director 5.2 API