Package com.gargoylesoftware.base.util
Class StringUtil
java.lang.Object
com.gargoylesoftware.base.util.StringUtil
A collection of utility methods dealing with strings
- Version:
- $Revision: 1.3 $
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
assertNotNull
(String fieldName, Object object) static String
expandTabs
(String inputString, int numberOfSpaces) Expand each tab character into the specified numbers of spaces.static String
Create a string based on all the objects in the array separated by the separator string.static String
Create a string based on all the objects in the array separated by the separator string.static String
Create a string based on all the objects in the array separated by the separator string.static String
Create a string based on all the objects in the array separated by the separator string.static String
Create a string based on all the objects in the array separated by the separator string.static String
Create a string based on all the objects in the array separated by the separator string.static String
join
(Collection collection, String separator) Create a string based on all the objects in the collection separated by the separator string.private static String
Create a string based on all the objects in the array separated by the separator string.static String
nCopies
(int copyCount, char charToCopy) Return a string containing the specified number of charToCopystatic String
Perform text substitutions in the source stringstatic String[]
Split the specified line into strings, spliting at each instance of separator.static String[]
splitAtFirst
(String line, String separator) Split the specified line into two strings, spliting at the first instance of separator.
-
Constructor Details
-
StringUtil
private StringUtil()
-
-
Method Details
-
expandTabs
Expand each tab character into the specified numbers of spaces.- Parameters:
inputString
- The string to be expanded.numberOfSpaces
- The number of space characters to be used for each substitution.- Returns:
- The new string with expanded tabs.
-
nCopies
Return a string containing the specified number of charToCopy- Parameters:
copyCount
- The number of times to copy the character.charToCopy
- The character that will be copied.- Returns:
- The new string.
-
joinArray
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the array separated by the separator string.- Parameters:
array
- The items that will be concatenated togetherseparator
- The separator string.- Returns:
- The new concatenated string.
-
join
Create a string based on all the objects in the collection separated by the separator string.- Parameters:
collection
- The collection containing the objects to joinseparator
- The separator string.- Returns:
- The new concatenated string.
-
splitAtFirst
Split the specified line into two strings, spliting at the first instance of separator.- Parameters:
line
- The line to be split.separator
- The separator that will be used to split the string.- Returns:
- An array containing the two strings.
-
split
Split the specified line into strings, spliting at each instance of separator.- Parameters:
line
- The line to be split.separator
- The separator that will be used to split the string.- Returns:
- An array containing the strings
-
replace
Perform text substitutions in the source string- Parameters:
sourceString
- The original stringmatch
- The string to replacereplace
- The new content to replace with- Returns:
- A new string with all the substitutions done
-
assertNotNull
-