org.vizzini.util
Class StringUtilities

java.lang.Object
  extended by org.vizzini.util.StringUtilities

public class StringUtilities
extends Object

Provides convenience methods for string handling.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Method Summary
 boolean containsWord(String search, String word)
          Try to find a word within a String.
 String convertAmpersands(String value)
          Convert ampersands (&) in the given string to their XML/HTML equivalents.
 String convertApostrophes(String value)
          Convert apostophes (') in the given string to their XML/HTML equivalents.
 String convertBrackets(String value)
          Convert brackets (<,>) in the given string to their XML/HTML equivalents.
 String convertNewlines(String value)
          Convert newlines (\\n) in the given string to their XML/HTML equivalents.
 String convertQuotes(String value)
          Convert quotes (") in the given string to their XML/HTML equivalents.
 String convertSpaces(String value)
          Convert spaces ( ) in the given string to their XML/HTML equivalents.
 int countOccurrences(String value, String key)
          Return the count of occurrences of the given key in the given value.
static StringUtilities getInstance()
          Return the singleton instance of this class.
 boolean isNullOrEmpty(String stringToTest)
          Tests if the given string is null or empty (length is zero).
 int occurrenceCount(String source, String substring)
          Return the number of times the given substring occurs in the given source string.
 String removePunctuation(String string)
          Remove punctuation from the given string.
 String removeSpaces(String string)
          Remove spaces from the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static StringUtilities getInstance()
Return the singleton instance of this class.

Returns:
The single instance.
Since:
v0.3

containsWord

public boolean containsWord(String search,
                            String word)
Try to find a word within a String. For these purposes, a word is consecutive characters without any whitespace. Punctuation is not filtered out, only whitespace is.

Parameters:
search - The string to search a word for
word - The string/word to search for
Returns:
true if word is equal to a word within the search string, otherwise false.
Since:
v0.3

convertAmpersands

public String convertAmpersands(String value)
Convert ampersands (&) in the given string to their XML/HTML equivalents.

Parameters:
value - The original string.
Returns:
The string with ampersands converted.
Since:
v0.3

convertApostrophes

public String convertApostrophes(String value)
Convert apostophes (') in the given string to their XML/HTML equivalents.

Parameters:
value - The original string.
Returns:
The string with apostrophes converted.
Since:
v0.3

convertBrackets

public String convertBrackets(String value)
Convert brackets (<,>) in the given string to their XML/HTML equivalents.

Parameters:
value - The original string.
Returns:
The string with brackets converted.
Since:
v0.3

convertNewlines

public String convertNewlines(String value)
Convert newlines (\\n) in the given string to their XML/HTML equivalents.

Parameters:
value - The original string.
Returns:
The string with newlines converted.
Since:
v0.3

convertQuotes

public String convertQuotes(String value)
Convert quotes (") in the given string to their XML/HTML equivalents.

Parameters:
value - The original string.
Returns:
The string with quotes converted.
Since:
v0.3

convertSpaces

public String convertSpaces(String value)
Convert spaces ( ) in the given string to their XML/HTML equivalents.

Parameters:
value - The original string.
Returns:
The string with spaces converted.
Since:
v0.3

countOccurrences

public int countOccurrences(String value,
                            String key)
Return the count of occurrences of the given key in the given value.

Parameters:
value - Value.
key - Key to count.
Since:
v0.3

isNullOrEmpty

public boolean isNullOrEmpty(String stringToTest)
Tests if the given string is null or empty (length is zero).

Parameters:
stringToTest - String to test for null or empty.
Returns:
true if the string is null or empty, otherwise false.
Since:
v0.3

occurrenceCount

public int occurrenceCount(String source,
                           String substring)
Return the number of times the given substring occurs in the given source string.

Parameters:
source - Source string.
substring - Substring.
Since:
v0.3

removePunctuation

public String removePunctuation(String string)
Remove punctuation from the given string.

Since:
v0.3

removeSpaces

public String removeSpaces(String string)
Remove spaces from the given string.

Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02