com.ibm.commerce.me.datatype
Class Utilities

java.lang.Object
  |
  +--com.ibm.commerce.me.datatype.Utilities

public class Utilities
extends java.lang.Object

Utility class providing utility method to decode url encoded string to String, file to String, replace values in a String


Field Summary
static java.lang.String COPYRIGHT
          IBM Copyright field
 
Constructor Summary
Utilities()
           
 
Method Summary
static java.lang.String decodeUrlEncoded(java.lang.String s)
          Decodes a "x-www-form-urlencoded" to a String.
static java.lang.String fileToString(java.lang.String fileName)
          Reads file and return the content as a String
static void main(java.lang.String[] args)
          main entry point of the program.
static java.lang.String replaceString(java.lang.String src, java.lang.String key, java.lang.String value)
          Replaces all the occurances of 'key' in the String 'src' with 'value'.
 
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 COPYRIGHT
IBM Copyright field
See Also:
Constant Field Values
Constructor Detail

Utilities

public Utilities()
Method Detail

decodeUrlEncoded

public static java.lang.String decodeUrlEncoded(java.lang.String s)
Decodes a "x-www-form-urlencoded" to a String.

Note: Here we are not bothered about < or >

Parameters:
s - the String to decode
Returns:
the newly decoded String
Throws:
java.lang.IllegalArgumentException - Thrown when # is not followed by numerical String

fileToString

public static java.lang.String fileToString(java.lang.String fileName)
                                     throws java.lang.Exception
Reads file and return the content as a String
Parameters:
fileName - the file name of the file to be read.
Throws:
java.lang.Exception - Thrown when the file does not exist or any related IOException

main

public static void main(java.lang.String[] args)
main entry point of the program. used for unit testing only...

replaceString

public static java.lang.String replaceString(java.lang.String src,
                                             java.lang.String key,
                                             java.lang.String value)
Replaces all the occurances of 'key' in the String 'src' with 'value'.
Parameters:
src - the original source string.
key - the string which is to be replaced.
value - the string with which key will be replaced.