public class ParameterValidation extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ParameterValidation.LoggingValidationErrorHandler |
static class |
ParameterValidation.ValidationErrorHandler
Implements a behavior to be executed in case a value fails to be validated.
|
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
CSS_DISTANCE |
static Pattern |
VALID_ASCII_CLASS_NAME |
static Pattern |
XSS_CHECK |
| Constructor and Description |
|---|
ParameterValidation() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
existsAndIsNotEmpty(Collection collection) |
static boolean |
existsAndIsNotEmpty(Map map) |
static <T> boolean |
existsAndIsNotEmpty(T[] array) |
static boolean |
isNullOrEmpty(String valueToCheck)
Determines whether the given String is
null or empty (after all extra whitespaces have been trimmed,
if any). |
static boolean |
isOldAndNewDifferent(Object oldValue,
Object newValue) |
static String |
sanitizeFromPattern(String value,
Pattern regex,
String defaultValue)
Checks if a given value matches the given format (as a regular expression).
|
static String |
sanitizeFromPatternWithHandler(String value,
Pattern regex,
ParameterValidation.ValidationErrorHandler handler)
Checks if a given value matches the given format (as a regular expression) and delegates what to do to the
specified ValidationErrorHandler.
|
static String |
sanitizeFromValues(String value,
String[] possibleValues,
String defaultValue)
Checks if a given value matches one of the possible values.
|
static String |
sanitizeFromValuesWithHandler(String value,
String[] possibleValues,
ParameterValidation.ValidationErrorHandler handler)
Checks if a given value matches one of the possible values and delegates what to do to the specified
ValidationErrorHandler.
|
static void |
throwIllegalArgExceptionIfNull(Object objectToTest,
String name) |
static void |
throwIllegalArgExceptionIfNullOrEmpty(Object[] array,
String name) |
static void |
throwIllegalArgExceptionIfNullOrEmpty(String valueToCheck,
String valueName,
String contextName) |
static void |
throwIllegalArgExceptionIfRangeInvalid(char[] chars,
int offset,
int length) |
public static final Pattern CSS_DISTANCE
public static final Pattern XSS_CHECK
public static final Pattern VALID_ASCII_CLASS_NAME
public static void throwIllegalArgExceptionIfNullOrEmpty(String valueToCheck, String valueName, String contextName)
public static void throwIllegalArgExceptionIfRangeInvalid(char[] chars,
int offset,
int length)
public static boolean isNullOrEmpty(String valueToCheck)
null or empty (after all extra whitespaces have been trimmed,
if any).valueToCheck - the String to testtrue if the the given String is null or empty (after being trimmed),
false otherwise.public static void throwIllegalArgExceptionIfNull(Object objectToTest, String name)
public static void throwIllegalArgExceptionIfNullOrEmpty(Object[] array, String name)
public static boolean existsAndIsNotEmpty(Collection collection)
public static boolean existsAndIsNotEmpty(Map map)
public static <T> boolean existsAndIsNotEmpty(T[] array)
public static String sanitizeFromPattern(String value, Pattern regex, String defaultValue)
value - value to sanitize if needed, null is considered as not matchingregex - format the value needs to conform todefaultValue - default value to use if the specified value does not conform to the specified formatpublic static String sanitizeFromPatternWithHandler(String value, Pattern regex, ParameterValidation.ValidationErrorHandler handler)
value - value to sanitize if needed, null is considered as not matchingregex - format the value needs to conform tohandler - ValidationErrorHandler implementing the behavior to apply in case the specified value failed to
validatepublic static String sanitizeFromValues(String value, String[] possibleValues, String defaultValue)
value - value to sanitize if needed, null is considered as not matchingpossibleValues - possible valuesdefaultValue - default value to use if the specified value does not conform to the specified formatpublic static String sanitizeFromValuesWithHandler(String value, String[] possibleValues, ParameterValidation.ValidationErrorHandler handler)
value - value to sanitize if needed, null is considered as not matchingpossibleValues - possible valueshandler - ValidationErrorHandler implementing the behavior to apply in case the specified value failed
to validateCopyright © 2025 JBoss by Red Hat. All Rights Reserved.