net.firstpartners.nounit.utility
Class TextUtil

java.lang.Object
  |
  +--net.firstpartners.nounit.utility.TextUtil

public class TextUtil
extends java.lang.Object

Performs common , but tricky tasks. e.g. Stripping of spaces from Files


Constructor Summary
TextUtil()
           
 
Method Summary
static java.lang.String find(java.lang.String fullText, int startIndex, java.lang.String startMarker, java.lang.String endMarker)
          Finds (start and end) markers in piece of text extracts text (note including markers) in between
static java.lang.String removeAll(java.lang.String inputString, java.lang.String removeString)
          Remove all instances of input string from Output
static java.lang.String removeTrailing(java.lang.String inString, java.lang.String toRemove)
          Strip out any trailing characters
static java.lang.String replace(java.lang.String string, java.lang.String oldSubstring, java.lang.String newSubstring)
          Replace the first occurrence of oldSubstring in string, if there is one, with newSubstring.
static java.lang.String replaceAll(java.lang.String string, java.lang.String oldSubstring, java.lang.String newSubstring)
          Replaces all occurrences of oldSubstring in string, if there are any, with newSubstring.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextUtil

public TextUtil()
Method Detail

replace

public static java.lang.String replace(java.lang.String string,
                                       java.lang.String oldSubstring,
                                       java.lang.String newSubstring)
Replace the first occurrence of oldSubstring in string, if there is one, with newSubstring.
Parameters:
string - - Replace a substring of this String
oldSubstring - - The substring of string to be replaced
newSubstring - - The string to put into string
Returns:
A new String which is a copy of string with the first occurrence of oldSubstring in string, if there is one, with newSubstring. Returns null if string is null. Returns string if either substring is null or oldSubstring is empty

replaceAll

public static java.lang.String replaceAll(java.lang.String string,
                                          java.lang.String oldSubstring,
                                          java.lang.String newSubstring)
Replaces all occurrences of oldSubstring in string, if there are any, with newSubstring.
Parameters:
string - - Replace substrings of this String
oldSubstring - - The substring of string to be replaced
newSubstring - - The string to put into string
Returns:
A new String which is a copy of string with all occurrences of oldSubstring in string, if there are any, with newSubstring. Returns null if string is null. Returns string if either substring is null or oldSubstring is empty

find

public static java.lang.String find(java.lang.String fullText,
                                    int startIndex,
                                    java.lang.String startMarker,
                                    java.lang.String endMarker)
Finds (start and end) markers in piece of text extracts text (note including markers) in between
Parameters:
fullText - to search in
startIndex - ignore text before this point
startMarker - start marker for the piece of text to extract
endMarker - end marker
Returns:
foundText , empty String if nothing found

removeAll

public static java.lang.String removeAll(java.lang.String inputString,
                                         java.lang.String removeString)
Remove all instances of input string from Output
Parameters:
inputString -  
removeString -  
Returns:
updateString

removeTrailing

public static java.lang.String removeTrailing(java.lang.String inString,
                                              java.lang.String toRemove)
Strip out any trailing characters
Parameters:
inString - to be operated on
toRemove - string to remove at end if found
Returns:
inString with end removed