Package com.gargoylesoftware.base.util
Class StringUtil
- java.lang.Object
-
- com.gargoylesoftware.base.util.StringUtil
-
public class StringUtil extends java.lang.ObjectA collection of utility methods dealing with strings- Version:
- $Revision: 1.3 $
-
-
Constructor Summary
Constructors Modifier Constructor Description privateStringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidassertNotNull(java.lang.String fieldName, java.lang.Object object)static java.lang.StringexpandTabs(java.lang.String inputString, int numberOfSpaces)Expand each tab character into the specified numbers of spaces.static java.lang.Stringjoin(byte[] array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.Stringjoin(double[] array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.Stringjoin(float[] array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.Stringjoin(int[] array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.Stringjoin(long[] array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.Stringjoin(java.lang.Object[] array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.Stringjoin(java.util.Collection collection, java.lang.String separator)Create a string based on all the objects in the collection separated by the separator string.private static java.lang.StringjoinArray(java.lang.Object array, java.lang.String separator)Create a string based on all the objects in the array separated by the separator string.static java.lang.StringnCopies(int copyCount, char charToCopy)Return a string containing the specified number of charToCopystatic java.lang.Stringreplace(java.lang.String sourceString, java.lang.String match, java.lang.String replace)Perform text substitutions in the source stringstatic java.lang.String[]split(java.lang.String line, java.lang.String separator)Split the specified line into strings, spliting at each instance of separator.static java.lang.String[]splitAtFirst(java.lang.String line, java.lang.String separator)Split the specified line into two strings, spliting at the first instance of separator.
-
-
-
Method Detail
-
expandTabs
public static java.lang.String expandTabs(java.lang.String inputString, int numberOfSpaces)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
public static java.lang.String nCopies(int copyCount, char charToCopy)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
private static java.lang.String joinArray(java.lang.Object array, java.lang.String separator)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
public static java.lang.String join(int[] array, java.lang.String separator)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
public static java.lang.String join(long[] array, java.lang.String separator)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
public static java.lang.String join(float[] array, java.lang.String separator)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
public static java.lang.String join(double[] array, java.lang.String separator)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
public static java.lang.String join(byte[] array, java.lang.String separator)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
public static java.lang.String join(java.lang.Object[] array, java.lang.String separator)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
public static java.lang.String join(java.util.Collection collection, java.lang.String separator)Create a string based on all the objects in the collection separated by the separator string.- Parameters:
separator- The separator string.collection- The collection containing the objects to join- Returns:
- The new concatenated string.
-
splitAtFirst
public static java.lang.String[] splitAtFirst(java.lang.String line, java.lang.String separator)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
public static java.lang.String[] split(java.lang.String line, java.lang.String separator)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
public static java.lang.String replace(java.lang.String sourceString, java.lang.String match, java.lang.String 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
private static void assertNotNull(java.lang.String fieldName, java.lang.Object object)
-
-