Class StringUtils
java.lang.Object
com.onenetwork.platform.tools.util.StringUtils
public abstract class StringUtils
extends java.lang.Object
Basic utilities for manipulating Strings.
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.Pattern
ALPHA_NUMERIC_PATTERN
Alpha NumericPattern
constantstatic java.lang.String
EMPTY_STRING
Empty string constant -
Constructor Summary
Constructors Modifier Constructor Description protected
StringUtils()
-
Method Summary
Modifier and Type Method Description static boolean
isAlphaNumeric(char ch)
CheckCharacter
is alphanumericstatic boolean
isAlphaNumeric(java.lang.String str)
static boolean
isBlank(java.lang.Object o)
Utility method to check for blanks Strings.static boolean
isNull(java.lang.Object o)
Utility method to check for null objects.static boolean
isNullOrBlank(java.lang.Object o)
Checks an object's for null or if a String, empty stringstatic java.lang.String
requireNonNullOrBlank(java.lang.String val, java.util.function.Supplier<java.lang.String> supp)
static java.lang.String
sanitizeWebSafeCallbackString(java.lang.String str)
This method is the same as validateWebSafeCallbackString except it returns a string This method is the preferred one for code checked by Checkmarx since it only considers a method to be a sanitizer of a variable if it affects its contentstatic void
validateWebSafeCallbackString(java.lang.String str)
This method is used to validate strings which will may be emitted into a web page as a callback parameter- it allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and .static void
validateWebSafeJsonp(java.lang.String str)
This method is used to validate strings which will may be emitted into a web page as a jsonp (callback) parameter It allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and .
-
Field Details
-
ALPHA_NUMERIC_PATTERN
public static final java.util.regex.Pattern ALPHA_NUMERIC_PATTERNAlpha NumericPattern
constant -
EMPTY_STRING
public static final java.lang.String EMPTY_STRINGEmpty string constant- See Also:
- Constant Field Values
-
-
Constructor Details
-
StringUtils
protected StringUtils()
-
-
Method Details
-
isBlank
public static boolean isBlank(java.lang.Object o)Utility method to check for blanks Strings. Probably exists somewhere else in some fashion.- Parameters:
o
- an object to check to see if is a blank string- Returns:
- true, if object is blank
-
isNull
public static boolean isNull(java.lang.Object o)Utility method to check for null objects. Probably exists somewhere else in some fashion.- Parameters:
o
- the object to check- Returns:
- true, if object is null
-
isNullOrBlank
public static boolean isNullOrBlank(java.lang.Object o)Checks an object's for null or if a String, empty string- Parameters:
o
- object being investigated- Returns:
- true, if the object is null or is an empty String.
-
isAlphaNumeric
public static boolean isAlphaNumeric(char ch)CheckCharacter
is alphanumeric- Parameters:
ch
-- Returns:
true
iffchar
isNumber
ofCharacter
elsefalse
-
isAlphaNumeric
public static boolean isAlphaNumeric(java.lang.String str) -
requireNonNullOrBlank
public static java.lang.String requireNonNullOrBlank(java.lang.String val, java.util.function.Supplier<java.lang.String> supp) -
sanitizeWebSafeCallbackString
public static java.lang.String sanitizeWebSafeCallbackString(java.lang.String str)This method is the same as validateWebSafeCallbackString except it returns a string This method is the preferred one for code checked by Checkmarx since it only considers a method to be a sanitizer of a variable if it affects its content- Returns:
- String
-
validateWebSafeCallbackString
public static void validateWebSafeCallbackString(java.lang.String str)This method is used to validate strings which will may be emitted into a web page as a callback parameter- it allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and . This helps ensure the string has not html elements like < or > which could allow a user to inject scripts/etc into a page if their input is reflected back as markup in the response. -
validateWebSafeJsonp
public static void validateWebSafeJsonp(java.lang.String str)This method is used to validate strings which will may be emitted into a web page as a jsonp (callback) parameter It allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and . This helps ensure the string has not html elements like < or > which could allow a user to inject scripts/etc into a page if their input is reflected back as markup in the response.
-