com.mckoi.util
Class StringUtil

java.lang.Object
  extended by com.mckoi.util.StringUtil

public class StringUtil
extends java.lang.Object

Various String utilities.

Author:
Tobias Downer

Constructor Summary
StringUtil()
           
 
Method Summary
static java.util.List explode(java.lang.String source, java.lang.String deliminator)
          Performs an 'explode' operation on the given source string.
static int find(java.lang.String source, java.lang.String find)
          Finds the index of the given string in the source string.
static java.lang.String implode(java.util.List list, java.lang.String deliminator)
          This is the inverse of 'explode'.
static java.lang.String searchAndReplace(java.lang.String source, java.lang.String search, java.lang.String replace)
          Searches for various instances of the 'search' string and replaces them with the 'replace' string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtil

public StringUtil()
Method Detail

find

public static int find(java.lang.String source,
                       java.lang.String find)
Finds the index of the given string in the source string.

Returns:
-1 if the 'find' string could not be found.

explode

public static java.util.List explode(java.lang.String source,
                                     java.lang.String deliminator)
Performs an 'explode' operation on the given source string. This algorithm finds all instances of the deliminator string, and returns an array of sub-strings of between the deliminator. For example, explode("10:30:40:55", ":") = ({"10", "30", "40", "55"})


implode

public static java.lang.String implode(java.util.List list,
                                       java.lang.String deliminator)
This is the inverse of 'explode'. It forms a string by concatinating each string in the list and seperating each with a deliminator string. For example, implode(({"1", "150", "500"}), ",") = "1,150,500"


searchAndReplace

public static java.lang.String searchAndReplace(java.lang.String source,
                                                java.lang.String search,
                                                java.lang.String replace)
Searches for various instances of the 'search' string and replaces them with the 'replace' string.