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 methods to decode a URL encoded string to String, file to String, replace values in a String
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright field
    • Constructor Summary

      Constructors 
      Constructor and Description
      Utilities() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String decodeUrlEncoded(java.lang.String s)
      This method decodes a "x-www-form-url encoded" to a String.
      static java.lang.String fileToString(java.lang.String fileName)
      This method reads a file and returns 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)
      This method replaces all the occurrences of key in the String src with value.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        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)
        This method decodes a "x-www-form-url encoded" to a String.

        Note: Here we are not bothered about < or >

        Parameters:
        s - the String to decode
        Returns:
        the newly decoded String
        Throws:
        IllegalArgumentException: - Raised when a '#' character is not followed by a numerical string.
      • fileToString

        public static java.lang.String fileToString(java.lang.String fileName)
                                             throws java.lang.Exception
        This method reads a file and returns the content as a String
        Parameters:
        fileName - the file name of the file to 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)
        This method replaces all the occurrences 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 with.