dd.util
Class StringUtils

java.lang.Object
  extended bydd.util.StringUtils

public class StringUtils
extends java.lang.Object

Adds helper functions for dealing with strings. Java's class library is lacking in some important string manipulation methods, provided here.


Constructor Summary
StringUtils()
           
 
Method Summary
static java.lang.String capitalize(java.lang.String string)
          Capitalizes the first letter of a string.
static java.lang.Object duplicate(java.lang.Object o)
           
static java.lang.String encodeUrl(java.lang.String url)
          Removes illegal characters from URLs.
static java.lang.String readFile(java.lang.String fileName)
          Reads the contents of a file (generally text or html) into a String using a StringBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils()
Method Detail

duplicate

public static java.lang.Object duplicate(java.lang.Object o)

capitalize

public static java.lang.String capitalize(java.lang.String string)
Capitalizes the first letter of a string. For example, "test" becomes "Test".

Parameters:
string - String to capitalize
Returns:
a new string with the first letter capitalized.

readFile

public static java.lang.String readFile(java.lang.String fileName)
Reads the contents of a file (generally text or html) into a String using a StringBuffer. Returns null if the file cannot be read. The path is read relatively with respect to this class, using getResourceAsStream(), so the semantic rules for how that file loader works apply.

Parameters:
fileName - Filename, including path, of the file to read.
Returns:
a new string containing the contents of the file.

encodeUrl

public static java.lang.String encodeUrl(java.lang.String url)
Removes illegal characters from URLs. Specifically, this method removes spaces from a URL and replaces them with a plus character, as is the convention with CGIs.

Parameters:
url - String to convert to a legal URL
Returns:
the new string with illegal characters escaped.