com.filenet.wcm.toolkit.util
Class WcmEncodingUtil

java.lang.Object
  extended bycom.filenet.wcm.toolkit.util.WcmEncodingUtil

public class WcmEncodingUtil
extends java.lang.Object

Utility class designed to handle various encoding tasks. This class cannot be instantiated.


Method Summary
static java.lang.String decodeBase64(java.util.Locale locale, java.lang.String str)
          Explicitly decodes text from base64.
static java.lang.String decodeBase64(java.lang.String str)
          Explicitly decodes text from base64.
static java.lang.String decodeHTML(java.lang.String source)
           
static java.lang.String decodeLabel(java.lang.String str)
          Decodes a String generated by encodeLabel() method
static java.lang.String decodePath(java.lang.String str)
          Decodes a String generated by encodePath() method
static java.lang.String decodeUTF8URL(java.lang.String s)
          Decodes UTF-8 encoded URL parameter.
static java.lang.String encodeBase64(java.lang.String str)
          Explicitly encodes text to base64.
static java.lang.String encodeHTML(java.lang.String source)
          Encodes the source string into HTML.
static java.lang.String encodeLabel(java.lang.String str)
          Encodes any String object so it can be used as a part of a URL
static java.lang.String encodePath(java.lang.String str)
          Encodes any String object so it can be used as a path in a URL * (asteric) is used as an escape character.
static java.lang.String encodeURL(java.lang.String str)
          URL-encodes the string.
static java.lang.String encodeUTF8URL(java.lang.String s)
          URL-encodes the string in UTF 8.
static java.lang.String getRandomNumber()
          creates a random number as a string
static java.lang.String translateHTML(java.lang.String source)
          Translates special characters into HTML sequences.
static java.lang.String unescapeXml(java.lang.String source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeHTML

public static java.lang.String encodeHTML(java.lang.String source)
Encodes the source string into HTML. For example, if you pass in the string "<test>", it will be converted to "&lt;test&gt;"

If you wish to translate and encode a string, you must perform the encoding before the translation. If you don't, the translated characters will be encoded.

Parameters:
source - The String to be encoded.
Returns:
the encoded String

decodeHTML

public static java.lang.String decodeHTML(java.lang.String source)

unescapeXml

public static java.lang.String unescapeXml(java.lang.String source)

translateHTML

public static java.lang.String translateHTML(java.lang.String source)
Translates special characters into HTML sequences. For example, if you pass in the string: "\n", it will be converted to "<br>". If you pass in the string: "\t", it will be converted to four "&nbsp;".

The only characters translated are newline (\n) and tab (\t).

If you wish to translate and encode a string, you must perform the encoding before the translation. If you don't, the translated characters will be encoded.

Parameters:
source - The String to be translated.
Returns:
the translated String

encodeURL

public static java.lang.String encodeURL(java.lang.String str)
URL-encodes the string. If the string is null, returns "".

Parameters:
str - String to be encoded
Returns:
encoded String

decodeBase64

public static java.lang.String decodeBase64(java.util.Locale locale,
                                            java.lang.String str)
                                     throws java.lang.Exception
Explicitly decodes text from base64.

Parameters:
locale - the client locale
str - string to be decoded
Returns:
decoded String
Throws:
java.lang.Exception

decodeBase64

public static java.lang.String decodeBase64(java.lang.String str)
                                     throws java.lang.Exception
Explicitly decodes text from base64.

Parameters:
str - string to be decoded
Returns:
decoded String
Throws:
java.lang.Exception

encodeBase64

public static java.lang.String encodeBase64(java.lang.String str)
                                     throws java.lang.Exception
Explicitly encodes text to base64.

Parameters:
str - String to be encoded
Returns:
encoded String
Throws:
java.lang.Exception

encodeLabel

public static java.lang.String encodeLabel(java.lang.String str)
Encodes any String object so it can be used as a part of a URL

Parameters:
str - string to be encoded
Returns:
encoded String

decodeLabel

public static java.lang.String decodeLabel(java.lang.String str)
Decodes a String generated by encodeLabel() method

Parameters:
str - String to be decoded
Returns:
decoded String

encodePath

public static java.lang.String encodePath(java.lang.String str)
Encodes any String object so it can be used as a path in a URL * (asteric) is used as an escape character. / (forward slash) is not encoded

Parameters:
str - string to be encoded
Returns:
encoded String

decodePath

public static java.lang.String decodePath(java.lang.String str)
Decodes a String generated by encodePath() method

Parameters:
str - String to be decoded
Returns:
decoded String

getRandomNumber

public static java.lang.String getRandomNumber()
creates a random number as a string

Returns:
String random number

encodeUTF8URL

public static java.lang.String encodeUTF8URL(java.lang.String s)
URL-encodes the string in UTF 8. If the string is null, returns "".

Parameters:
s - String to be encoded
Returns:
encoded String

decodeUTF8URL

public static java.lang.String decodeUTF8URL(java.lang.String s)
Decodes UTF-8 encoded URL parameter. This is done automatically by request.getParameter() method, so using this method is not needed in most cases. This is the same as URLDecoder.decode(s, "UTF-8") in JDK 1.4+. The code for this method is copied from JDK 1.4 source.

Parameters:
s - the String to decode
Returns:
the newly decoded String


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.