arlut.csd.Util
Class StringUtils

java.lang.Object
  |
  +--arlut.csd.Util.StringUtils

public class StringUtils
extends java.lang.Object

This class contains a variety of utility String manipulating static methods for use in Ganymede.


Constructor Summary
StringUtils()
           
 
Method Summary
static boolean containsOnly(java.lang.String inputString, java.lang.String legalChars)
          This method tests to see if inputString consists of only characters contained within the legalChars string.
static int count(java.lang.String inputString, java.lang.String patternString)
          This method takes an inputString and counts the number of times that patternString occurs within it.
static java.lang.String replaceStr(java.lang.String inputString, java.lang.String splitString, java.lang.String joinString)
          This method behaves like String.replace(), but replaces substrings rather than chars.
static java.lang.String[] split(java.lang.String inputString, java.lang.String splitString)
          This method takes a (possibly multiline) inputString containing subsequences matching splitString and returns an array of Strings which contain the contents of the inputString between instances of the splitString.
static java.lang.String strip(java.lang.String inputString, java.lang.String legalChars)
          This method strips out any characters from inputString that are not present in legalChars.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils()
Method Detail

strip

public static java.lang.String strip(java.lang.String inputString,
                                     java.lang.String legalChars)

This method strips out any characters from inputString that are not present in legalChars.

This method will always return a non-null String.


containsOnly

public static boolean containsOnly(java.lang.String inputString,
                                   java.lang.String legalChars)

This method tests to see if inputString consists of only characters contained within the legalChars string. If inputString contains no characters not contained within legalChars, containsOnly() will return true, otherwise it will return false.

Note that containsOnly will always return true if inputString is null.


count

public static int count(java.lang.String inputString,
                        java.lang.String patternString)

This method takes an inputString and counts the number of times that patternString occurs within it.


split

public static java.lang.String[] split(java.lang.String inputString,
                                       java.lang.String splitString)

This method takes a (possibly multiline) inputString containing subsequences matching splitString and returns an array of Strings which contain the contents of the inputString between instances of the splitString. The splitString divider will not be returned in the split strings.

In particular, this can be used to split a multiline String into an array of Strings by using a splitString of "\n". The resulting strings will not include their terminating newlines.


replaceStr

public static java.lang.String replaceStr(java.lang.String inputString,
                                          java.lang.String splitString,
                                          java.lang.String joinString)

This method behaves like String.replace(), but replaces substrings rather than chars.