|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jgoodies.validation.util.ValidationUtils
public final class ValidationUtils
Consists exclusively of static methods for validating input values by testing and comparing single and multiple values.
The Jakarta Commons Lang
library contains more classes and methods useful for validation.
The Utils string and character tests in this ValidationUtils class are
compatible with the Jakarta Commons Lang StringUtils methods.
Calendar| Method Summary | |
|---|---|
static boolean |
equals(java.lang.Object o1,
java.lang.Object o2)
Checks and answers if the two objects are both null or equal. |
static java.util.Calendar |
getRelativeCalendar(java.util.Calendar from,
int offsetDays)
Computes the day that has the given offset in days from the specified from date and returns it as an instance of Calendar. |
static java.util.Calendar |
getRelativeCalendar(int offsetDays)
Computes the day that has the given offset in days to today and returns it as an instance of Calendar. |
static java.util.Date |
getRelativeDate(int offsetDays)
Computes the day that has the given offset in days to today and returns it as an instance of Date. |
static boolean |
hasBoundedLength(java.lang.String str,
int min,
int max)
Checks and answers if the length of the given string is in the bounds as specified by the interval [min, max]. |
static boolean |
hasMaximumLength(java.lang.String str,
int max)
Checks and answers if the given string is shorter than the specified maximum length. |
static boolean |
hasMinimumLength(java.lang.String str,
int min)
Checks and answers if the given string has at least the specified minimum length. |
static boolean |
isAlpha(java.lang.String str)
Checks and answers if the given string contains only unicode letters. |
static boolean |
isAlphanumeric(java.lang.String str)
Checks and answers if the given string contains only unicode letters or digits. |
static boolean |
isAlphanumericSpace(java.lang.String str)
Checks and answers if the given string contains only unicode letters or digits or space (' '). |
static boolean |
isAlphaSpace(java.lang.String str)
Checks and answers if the given string contains only unicode letters and space (' '). |
static boolean |
isBlank(java.lang.String str)
Checks and answers if the given string is whitespace, empty ("") or null. |
static boolean |
isEmpty(java.lang.String str)
Checks and answers if the given string is empty ("") or null. |
static boolean |
isFutureDay(java.util.Date date)
Determines and answers if the day of the given Date
is in the future. |
static boolean |
isNotBlank(java.lang.String str)
Checks and answers if the given string is not empty (""), not null and not whitespace only. |
static boolean |
isNotEmpty(java.lang.String str)
Checks and answers if the given string is not empty ("") and not null. |
static boolean |
isNumeric(java.lang.String str)
Checks and answers if the given string contains only unicode digits. |
static boolean |
isNumericSpace(java.lang.String str)
Checks and answers if the given string contains only unicode digits or space (' '). |
static boolean |
isPastDay(java.util.Date date)
Determines and answers if the day of the given Date
is in the past. |
static boolean |
isToday(java.util.Date date)
Determines and answers if the given Date is today. |
static boolean |
isTomorrow(java.util.Date date)
Determines and answers if the given Date is tomorrow. |
static boolean |
isYesterday(java.util.Date date)
Determines and answers if the given Date is yesterday. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean equals(java.lang.Object o1,
java.lang.Object o2)
null or equal.
ValidationUtils.equals(null, null) == true
ValidationUtils.equals("Hi", "Hi") == true
ValidationUtils.equals("Hi", null) == false
ValidationUtils.equals(null, "Hi") == false
ValidationUtils.equals("Hi", "Ho") == false
o1 - the first object to compareo2 - the second object to compare
true if and only if
both objects are null or equalpublic static boolean isBlank(java.lang.String str)
null.
ValidationUtils.isBlank(null) == true
ValidationUtils.isBlank("") == true
ValidationUtils.isBlank(" ") == true
ValidationUtils.isBlank(" abc") == false
ValidationUtils.isBlank("abc ") == false
ValidationUtils.isBlank(" abc ") == false
str - the string to check, may be null
true if the string is whitespace, empty
or nullisEmpty(String)public static boolean isNotBlank(java.lang.String str)
null and not whitespace only.
ValidationUtils.isNotBlank(null) == false
ValidationUtils.isNotBlank("") == false
ValidationUtils.isNotBlank(" ") == false
ValidationUtils.isNotBlank(" abc") == true
ValidationUtils.isNotBlank("abc ") == true
ValidationUtils.isNotBlank(" abc ") == true
str - the string to check, may be null
true if the string is not empty
and not null and not whitespace onlyisEmpty(String)public static boolean isEmpty(java.lang.String str)
null.
ValidationUtils.isEmpty(null) == true
ValidationUtils.isEmpty("") == true
ValidationUtils.isEmpty(" ") == false
ValidationUtils.isEmpty("Hi ") == false
str - the string to check, may be null
true if the string is empty or nullisBlank(String)public static boolean isNotEmpty(java.lang.String str)
null.
ValidationUtils.isNotEmpty(null) == false
ValidationUtils.isNotEmpty("") == false
ValidationUtils.isNotEmpty(" ") == true
ValidationUtils.isNotEmpty("Hi") == true
ValidationUtils.isNotEmpty("Hi ") == true
str - the string to check, may be null
true if the string is not empty and not nullisBlank(String)
public static boolean hasMinimumLength(java.lang.String str,
int min)
null or contain only blanks have length 0.
ValidationUtils.hasMinimumLength(null, 2) == false
ValidationUtils.hasMinimumLength("", 2) == false
ValidationUtils.hasMinimumLength(" ", 2) == false
ValidationUtils.hasMinimumLength(" ", 2) == false
ValidationUtils.hasMinimumLength("Hi ", 2) == true
ValidationUtils.hasMinimumLength("Ewa", 2) == true
str - the string to checkmin - the minimum length
true if the length is greater or equal to the minimum,
false otherwise
public static boolean hasMaximumLength(java.lang.String str,
int max)
null or contain only blanks have length 0.
ValidationUtils.hasMaximumLength(null, 2) == true
ValidationUtils.hasMaximumLength("", 2) == true
ValidationUtils.hasMaximumLength(" ", 2) == true
ValidationUtils.hasMaximumLength(" ", 2) == true
ValidationUtils.hasMaximumLength("Hi ", 2) == true
ValidationUtils.hasMaximumLength("Ewa", 2) == false
str - the string to checkmax - the maximum length
true if the length is less than or equal to the minimum,
false otherwise
public static boolean hasBoundedLength(java.lang.String str,
int min,
int max)
null or contain only blanks have length 0.
ValidationUtils.hasBoundedLength(null, 1, 2) == false
ValidationUtils.hasBoundedLength("", 1, 2) == false
ValidationUtils.hasBoundedLength(" ", 1, 2) == false
ValidationUtils.hasBoundedLength(" ", 1, 2) == false
ValidationUtils.hasBoundedLength("Hi ", 1, 2) == true
ValidationUtils.hasBoundedLength("Ewa", 1, 2) == false
str - the string to checkmin - the minimum lengthmax - the maximum length
true if the length is in the interval,
false otherwise
java.lang.IllegalArgumentException - if min > maxpublic static boolean isAlpha(java.lang.String str)
null returns false,
an empty string ("") returns true.
ValidationUtils.isAlpha(null) == false
ValidationUtils.isAlpha("") == true
ValidationUtils.isAlpha(" ") == false
ValidationUtils.isAlpha("abc") == true
ValidationUtils.isAlpha("ab c") == false
ValidationUtils.isAlpha("ab2c") == false
ValidationUtils.isAlpha("ab-c") == false
str - the string to check, may be null
true if the string contains only unicode letters,
and is non-nullpublic static boolean isAlphaSpace(java.lang.String str)
null returns false,
an empty string ("") returns true.
ValidationUtils.isAlphaSpace(null) == false
ValidationUtils.isAlphaSpace("") == true
ValidationUtils.isAlphaSpace(" ") == true
ValidationUtils.isAlphaSpace("abc") == true
ValidationUtils.isAlphaSpace("ab c") == true
ValidationUtils.isAlphaSpace("ab2c") == false
ValidationUtils.isAlphaSpace("ab-c") == false
str - the string to check, may be null
true if the string contains only unicode letters
and space, and is non-nullpublic static boolean isAlphanumeric(java.lang.String str)
null returns false,
an empty string ("") returns true.
ValidationUtils.isAlphanumeric(null) == false
ValidationUtils.isAlphanumeric("") == true
ValidationUtils.isAlphanumeric(" ") == false
ValidationUtils.isAlphanumeric("abc") == true
ValidationUtils.isAlphanumeric("ab c") == false
ValidationUtils.isAlphanumeric("ab2c") == true
ValidationUtils.isAlphanumeric("ab-c") == false
ValidationUtils.isAlphanumeric("123") == true
ValidationUtils.isAlphanumeric("12 3") == false
ValidationUtils.isAlphanumeric("12-3") == false
str - the string to check, may be null
true if the string contains only unicode letters
or digits, and is non-nullpublic static boolean isAlphanumericSpace(java.lang.String str)
null returns false,
an empty string ("") returns true.
ValidationUtils.isAlphanumericSpace(null) == false
ValidationUtils.isAlphanumericSpace("") == true
ValidationUtils.isAlphanumericSpace(" ") == true
ValidationUtils.isAlphanumericSpace("abc") == true
ValidationUtils.isAlphanumericSpace("ab c") == true
ValidationUtils.isAlphanumericSpace("ab2c") == true
ValidationUtils.isAlphanumericSpace("ab-c") == false
ValidationUtils.isAlphanumericSpace("123") == true
ValidationUtils.isAlphanumericSpace("12 3") == true
ValidationUtils.isAlphanumericSpace("12-3") == false
str - the string to check, may be null
true if the string contains only unicode letters,
digits or space (' '), and is non-nullpublic static boolean isNumeric(java.lang.String str)
false.
null returns false,
an empty string ("") returns true.
ValidationUtils.isNumeric(null) == false
ValidationUtils.isNumeric("") == true
ValidationUtils.isNumeric(" ") == false
ValidationUtils.isNumeric("abc") == false
ValidationUtils.isNumeric("ab c") == false
ValidationUtils.isNumeric("ab2c") == false
ValidationUtils.isNumeric("ab-c") == false
ValidationUtils.isNumeric("123") == true
ValidationUtils.isNumeric("12 3") == false
ValidationUtils.isNumeric("12-3") == false
ValidationUtils.isNumeric("12.3") == false
str - the string to check, may be null
true if the string contains only unicode digits,
and is non-nullpublic static boolean isNumericSpace(java.lang.String str)
false.
null returns false,
an empty string ("") returns true.
ValidationUtils.isNumericSpace(null) == false
ValidationUtils.isNumericSpace("") == true
ValidationUtils.isNumericSpace(" ") == true
ValidationUtils.isNumericSpace("abc") == false
ValidationUtils.isNumericSpace("ab c") == false
ValidationUtils.isNumericSpace("ab2c") == false
ValidationUtils.isNumericSpace("ab-c") == false
ValidationUtils.isNumericSpace("123") == true
ValidationUtils.isNumericSpace("12 3") == true
ValidationUtils.isNumericSpace("12-3") == false
ValidationUtils.isNumericSpace("12.3") == false
str - the string to check, may be null
true if the string contains only unicode digits
or space, and is non-nullpublic static boolean isPastDay(java.util.Date date)
Date
is in the past.
date - the date to check
true if in the past, false otherwisepublic static boolean isYesterday(java.util.Date date)
Date is yesterday.
date - the date to check
true if yesterday, false otherwisepublic static boolean isToday(java.util.Date date)
Date is today.
date - the date to check
true if today, false otherwisepublic static boolean isTomorrow(java.util.Date date)
Date is tomorrow.
date - the date to check
true if tomorrow, false otherwisepublic static boolean isFutureDay(java.util.Date date)
Date
is in the future.
date - the date to check
true if in the future, false otherwisepublic static java.util.Date getRelativeDate(int offsetDays)
Date.
offsetDays - the offset in day relative to today
Date that is the begin of the day
with the specified offsetpublic static java.util.Calendar getRelativeCalendar(int offsetDays)
Calendar.
offsetDays - the offset in day relative to today
Calendar instance that is the begin of the day
with the specified offset
public static java.util.Calendar getRelativeCalendar(java.util.Calendar from,
int offsetDays)
Calendar.
from - the base date as Calendar instanceoffsetDays - the offset in day relative to today
Calendar instance that is the begin of the day
with the specified offset from the given day
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||