Package com.optum.sourcehawk.core.utils
Class StringUtils
- java.lang.Object
-
- com.optum.sourcehawk.core.utils.StringUtils
-
public final class StringUtils extends Object
String Utilities- Author:
- Brian Wyka
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdefaultString(String str, String defaultStr)Returns either the passed in String, or if the String isnull, the value ofdefaultStr.static booleanequals(CharSequence charSequenceOne, CharSequence charSequenceTwo)Determine if two character sequences are equal to each otherstatic booleanisBlankOrEmpty(String string)Determine if a string is blank or emptystatic booleanisNotBlankOrEmpty(String string)Determine if a string is not blank or emptystatic booleanisUrl(String url)Determine whether or not the string provided is a URLstatic StringremoveNewLines(String string)Remove new lines and carriage returnsstatic booleanstartsWith(CharSequence subject, CharSequence prefix)Determine if a string starts with the provided prefix
-
-
-
Method Detail
-
isBlankOrEmpty
public static boolean isBlankOrEmpty(String string)
Determine if a string is blank or empty- Parameters:
string- the string to check- Returns:
- true if null, empty, or blank
-
isNotBlankOrEmpty
public static boolean isNotBlankOrEmpty(String string)
Determine if a string is not blank or empty- Parameters:
string- the string to check- Returns:
- true if NOT null, empty, or blank
-
startsWith
public static boolean startsWith(CharSequence subject, CharSequence prefix)
Determine if a string starts with the provided prefix- Parameters:
subject- the subject to check for prefixprefix- the sequence to check for at beginning- Returns:
- true if starts with prefix, false otherwise
-
equals
public static boolean equals(CharSequence charSequenceOne, CharSequence charSequenceTwo)
Determine if two character sequences are equal to each other- Parameters:
charSequenceOne- character sequence onecharSequenceTwo- character sequence two- Returns:
- true if equal, false otherwise
-
removeNewLines
public static String removeNewLines(String string)
Remove new lines and carriage returns- Parameters:
string- the string to remove from- Returns:
- the modified string with new lines and carriage returns removed
-
isUrl
public static boolean isUrl(String url)
Determine whether or not the string provided is a URL- Parameters:
url- the string to check- Returns:
- true if a URL, false otherwise
-
defaultString
public static String defaultString(String str, String defaultStr)
Returns either the passed in String, or if the String is
null, the value ofdefaultStr.StringUtils.defaultString(null, "NULL") = "NULL" StringUtils.defaultString("", "NULL") = "" StringUtils.defaultString("bat", "NULL") = "bat"- Parameters:
str- the String to check, may be nulldefaultStr- the default String to return if the input isnull, may be null- Returns:
- the passed in String, or the default if it was
null - See Also:
String.valueOf(Object)
-
-