Class StringUtil
- java.lang.Object
-
- com.veracode.jenkins.plugin.utils.StringUtil
-
public final class StringUtil extends Object
The StringUtil is a utility class for working with Strings.Includes some methods with signatures similar to those exposed by .NET's String class.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compare(String str1, String str2, boolean ignoreCase)
Compares two Strings.static String
getEmptyIfNull(String input)
Returns the empty string if the input String is null.static String
getNullIfEmpty(String input)
Returns null if the input String is empty.static boolean
isNullOrEmpty(String input)
Determines whether a string is null or empty.static String
join(String separator, String[] value)
Joins the elements of aString[]
using the specified separator.static String
padLeft(String input, int totalWidth)
Prepends spaces to a String.static String
padRight(String input, int totalWidth)
Appends spaces to a String.static String
repeatChar(char character, int count)
Returns a string that contains the specified character count times.
-
-
-
Field Detail
-
EMPTY
public static final String EMPTY
Returns the empty String "".
- See Also:
- Constant Field Values
-
NEWLINE
public static final String NEWLINE
Returns the new line String "\r\n".
- See Also:
- Constant Field Values
-
-
Method Detail
-
isNullOrEmpty
public static boolean isNullOrEmpty(String input)
Determines whether a string is null or empty.
- Parameters:
input
- aString
object.- Returns:
- a boolean.
-
getNullIfEmpty
public static String getNullIfEmpty(String input)
Returns null if the input String is empty. Otherwise the String.
-
getEmptyIfNull
public static String getEmptyIfNull(String input)
Returns the empty string if the input String is null. Otherwise the String.
-
repeatChar
public static String repeatChar(char character, int count)
Returns a string that contains the specified character count times.
- Parameters:
character
- a char.count
- a int.- Returns:
- a
String
object.
-
compare
public static int compare(String str1, String str2, boolean ignoreCase)
Compares two Strings.
StringUtil.compare(null, null) = 0 StringUtil.compare(null, "...") = -1 StringUtil.compare("...", null) = 1
-
-