public class Validator
extends Object
Constructor and Description |
---|
Validator() |
Modifier and Type | Method and Description |
---|---|
static boolean |
equals(boolean boolean1,
boolean boolean2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(byte byte1,
byte byte2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(char char1,
char char2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(double double1,
double double2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(float float1,
float float2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(int int1,
int int2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(long long1,
long long2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(Object obj1,
Object obj2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equals(short short1,
short short2)
Deprecated.
As of Judson (7.1.x)
|
static boolean |
equalsSorted(boolean[] booleanArray1,
boolean[] booleanArray2)
Returns
true if the boolean arrays are equal. |
static boolean |
equalsSorted(byte[] byteArray1,
byte[] byteArray2)
Returns
true if the byte arrays are equal. |
static boolean |
equalsSorted(char[] charArray1,
char[] charArray2)
Returns
true if the char arrays are equal. |
static boolean |
equalsSorted(double[] doubleArray1,
double[] doubleArray2)
Returns
true if the double arrays are equal. |
static boolean |
equalsSorted(float[] floatArray1,
float[] floatArray2)
Returns
true if the float arrays are equal. |
static boolean |
equalsSorted(int[] intArray1,
int[] intArray2)
Returns
true if the int arrays are equal. |
static boolean |
equalsSorted(long[] longArray1,
long[] longArray2)
Returns
true if the long arrays are equal. |
static boolean |
equalsSorted(Object[] objArray1,
Object[] objArray2)
Returns
true if the object arrays are equal. |
static boolean |
equalsSorted(short[] shortArray1,
short[] shortArray2)
Returns
true if the short arrays are equal. |
static boolean |
isAddress(String address)
Returns
true if the string is an email address. |
static boolean |
isAlphanumericName(String name)
Returns
true if the string is an alphanumeric name, meaning
it contains nothing but English letters, numbers, and spaces. |
static boolean |
isAscii(char c)
Returns
true if the character is in the ASCII character set. |
static boolean |
isBlank(String s) |
static boolean |
isBoolean(String value) |
static boolean |
isChar(char c)
Returns
true if the character is an upper or lower case
English letter. |
static boolean |
isChar(String s)
Returns
true if string consists only of upper and lower case
English letters. |
static boolean |
isContent(String s)
Returns
true if the string contains content. |
static boolean |
isDate(int month,
int day,
int year)
Returns
true if the date is valid in the Gregorian calendar. |
static boolean |
isDigit(char c)
Returns
true if the character is a digit between 0 and 9
(inclusive). |
static boolean |
isDigit(String s)
Returns
true if the string consists of only digits between 0
and 9 (inclusive). |
static boolean |
isDomain(String domainName)
Returns
true if the string is a valid domain name. |
static boolean |
isEmailAddress(String emailAddress)
Returns
true if the string is a valid email address. |
static boolean |
isEmailAddressSpecialChar(char c)
Returns
true if the character is a special character in an
email address. |
static boolean |
isFileExtension(String fileExtension)
Returns
true if the file extension is valid. |
static boolean |
isFileName(String name) |
static boolean |
isFilePath(String path,
boolean parentDirAllowed) |
static boolean |
isGregorianDate(int month,
int day,
int year)
Returns
true if the date is valid in the Gregorian calendar. |
static boolean |
isHex(String s)
Returns
true if the string is a hexidecimal number. |
static boolean |
isHostName(String name)
Returns
true if the string is a valid host name. |
static boolean |
isHTML(String s)
Returns
true if the string is an HTML document. |
static boolean |
isIPAddress(String ipAddress)
Returns
true if the string is a valid IPv4 or IPv6 IP
address. |
static boolean |
isIPv4Address(String ipAddress)
Returns
true if the string is a valid IPv4 IP address. |
static boolean |
isIPv6Address(String ipAddress)
Returns
true if the string is a valid IPv6 IP address. |
static boolean |
isJulianDate(int month,
int day,
int year)
Returns
true if the date is valid in the Julian calendar. |
static boolean |
isLUHN(String number)
Returns
true if the string contains a valid number according
to the Luhn algorithm, commonly used to validate credit card numbers. |
static boolean |
isName(String name)
Returns
true if the string is a name, meaning it contains
nothing but English letters and spaces. |
static boolean |
isNotNull(Long l)
Returns
true if the long number object is not
null , meaning it is neither a null reference or
zero. |
static boolean |
isNotNull(Object obj)
Returns
true if the object is not null , using
the rules from isNotNull(Long) or isNotNull(String) if
the object is one of these types. |
static boolean |
isNotNull(String s)
Returns
true if the string is not null , meaning
it is not a null reference, an empty string, whitespace, or
the string "null ", with or without leading or trailing
whitespace. |
static boolean |
isNull(Long l)
Returns
true if the long number object is null ,
meaning it is either a null reference or zero. |
static boolean |
isNull(Object obj)
Returns
true if the object is null , using the
rules from isNull(Long) or isNull(String) if the object
is one of these types. |
static boolean |
isNull(String s)
Returns
true if the string is null , meaning it
is a null reference, an empty string, whitespace, or the
string "null ", with or without leading or trailing
whitespace. |
static boolean |
isNumber(String number)
Returns
true if the string is a decimal integer number,
meaning it contains nothing but decimal digits. |
static boolean |
isPassword(String password)
Returns
true if the string is a valid password, meaning it
is at least four characters long and contains only letters and decimal
digits. |
static boolean |
isPhoneNumber(String phoneNumber)
Returns
true if the string is a valid phone number. |
static boolean |
isUri(String uri) |
static boolean |
isUrl(String url)
Returns
true if the string is a valid URL based on the rules
in URL . |
static boolean |
isUrl(String url,
boolean acceptRootRelative)
Returns
true if the string is a valid URL based on the rules
in URL . |
static boolean |
isVariableName(String variableName)
Returns
true if the string is a valid variable name in Java. |
static boolean |
isVariableTerm(String s)
Returns
true if the string is a valid variable term, meaning
it begins with "[$" and ends with "$]". |
static boolean |
isWhitespace(char c)
Returns
true if the character is whitespace, meaning it is
either the null character '0' or whitespace according to
Character.isWhitespace(char) . |
static boolean |
isXml(String s)
Returns
true if the string is an XML document. |
@Deprecated public static boolean equals(boolean boolean1, boolean boolean2)
@Deprecated public static boolean equals(byte byte1, byte byte2)
@Deprecated public static boolean equals(char char1, char char2)
@Deprecated public static boolean equals(double double1, double double2)
@Deprecated public static boolean equals(float float1, float float2)
@Deprecated public static boolean equals(int int1, int int2)
@Deprecated public static boolean equals(long long1, long long2)
@Deprecated public static boolean equals(Object obj1, Object obj2)
@Deprecated public static boolean equals(short short1, short short2)
public static boolean equalsSorted(boolean[] booleanArray1, boolean[] booleanArray2)
true
if the boolean arrays are equal.booleanArray1
- the first boolean arraybooleanArray2
- the second boolean arraytrue
if the booleans arrays are equal; false
otherwisepublic static boolean equalsSorted(byte[] byteArray1, byte[] byteArray2)
true
if the byte arrays are equal.byteArray1
- the first byte arraybyteArray2
- the second byte arraytrue
if the byte arrays are equal; false
otherwisepublic static boolean equalsSorted(char[] charArray1, char[] charArray2)
true
if the char arrays are equal.charArray1
- the first char arraycharArray2
- the second char arraytrue
if the char arrays are equal; false
otherwisepublic static boolean equalsSorted(double[] doubleArray1, double[] doubleArray2)
true
if the double arrays are equal.doubleArray1
- the first double arraydoubleArray2
- the second double arraytrue
if the double arrays are equal; false
otherwisepublic static boolean equalsSorted(float[] floatArray1, float[] floatArray2)
true
if the float arrays are equal.floatArray1
- the first float arrayfloatArray2
- the second char arraytrue
if the float arrays are equal; false
otherwisepublic static boolean equalsSorted(int[] intArray1, int[] intArray2)
true
if the int arrays are equal.intArray1
- the first int arrayintArray2
- the second int arraytrue
if the int arrays are equal; false
otherwisepublic static boolean equalsSorted(long[] longArray1, long[] longArray2)
true
if the long arrays are equal.longArray1
- the first long arraylongArray2
- the second long arraytrue
if the long arrays are equal; false
otherwisepublic static boolean equalsSorted(Object[] objArray1, Object[] objArray2)
true
if the object arrays are equal.objArray1
- the first object arrayobjArray2
- the second object arraytrue
if the object arrays are equal; false
otherwisepublic static boolean equalsSorted(short[] shortArray1, short[] shortArray2)
true
if the short arrays are equal.shortArray1
- the first short arrayshortArray2
- the second short arraytrue
if the short arrays are equal; false
otherwisepublic static boolean isAddress(String address)
true
if the string is an email address. The only
requirements are that the string consist of two parts separated by an @
symbol, and that it contain no whitespace.address
- the string to checktrue
if the string is an email address;
false
otherwisepublic static boolean isAlphanumericName(String name)
true
if the string is an alphanumeric name, meaning
it contains nothing but English letters, numbers, and spaces.name
- the string to checktrue
if the string is an Alphanumeric name;
false
otherwisepublic static boolean isAscii(char c)
true
if the character is in the ASCII character set.
This includes characters with integer values between 32 and 126
(inclusive).c
- the character to checktrue
if the character is in the ASCII character set;
false
otherwisepublic static boolean isBlank(String s)
public static boolean isBoolean(String value)
public static boolean isChar(char c)
true
if the character is an upper or lower case
English letter.c
- the character to checktrue
if the character is an upper or lower case
English letter; false
otherwisepublic static boolean isChar(String s)
true
if string consists only of upper and lower case
English letters.s
- the string to checktrue
if the string consists only of upper and lower
case English letterspublic static boolean isContent(String s)
true
if the string contains content. The only
requirement is that it contain content that is not whitespace.s
- the string to checktrue
if the string contains content;
false
otherwisepublic static boolean isDate(int month, int day, int year)
true
if the date is valid in the Gregorian calendar.month
- the month to checkday
- the day to checkyear
- the year to checktrue
if the date is valid in the Gregorian calendar;
false
otherwisepublic static boolean isDigit(char c)
true
if the character is a digit between 0 and 9
(inclusive).c
- the character to checktrue
if the character is a digit between 0 and 9
(inclusive); false
otherwisepublic static boolean isDigit(String s)
true
if the string consists of only digits between 0
and 9 (inclusive).s
- the string to checktrue
if the string consists of only digits between 0
and 9 (inclusive); false
otherwisepublic static boolean isDomain(String domainName)
true
if the string is a valid domain name. See
RFC-1034 (section 3), RFC-1123 (section 2.1), and RFC-952 (section B.
Lexical grammar).domainName
- the string to checktrue
if the string is a valid domain name;
false
otherwisepublic static boolean isEmailAddress(String emailAddress)
true
if the string is a valid email address.emailAddress
- the string to checktrue
if the string is a valid email address;
false
otherwisepublic static boolean isEmailAddressSpecialChar(char c)
true
if the character is a special character in an
email address.c
- the character to checktrue
if the character is a special character in an
email address; false
otherwisepublic static boolean isFileExtension(String fileExtension)
true
if the file extension is valid.fileExtension
- string to checktrue
if the extension is valid; false
otherwisepublic static boolean isFileName(String name)
public static boolean isFilePath(String path, boolean parentDirAllowed)
public static boolean isGregorianDate(int month, int day, int year)
true
if the date is valid in the Gregorian calendar.month
- the month (0-based, meaning 0 for January)day
- the day of the monthyear
- the yeartrue
if the date is valid; false
otherwisepublic static boolean isHex(String s)
true
if the string is a hexidecimal number. At
present the only requirement is that the string is not null
;
it does not actually check the format of the string.s
- the string to checktrue
if the string is a hexidecimal number;
false
otherwiseisNull(String)
public static boolean isHostName(String name)
true
if the string is a valid host name.name
- the string to checktrue
if the string is a valid host name;
false
otherwisepublic static boolean isHTML(String s)
true
if the string is an HTML document. The only
requirement is that it contain the opening and closing html tags.s
- the string to checktrue
if the string is an HTML document;
false
otherwisepublic static boolean isIPAddress(String ipAddress)
true
if the string is a valid IPv4 or IPv6 IP
address.ipAddress
- the string to checktrue
if the string is a valid IPv4 or IPv6 IP
address; false
otherwisepublic static boolean isIPv4Address(String ipAddress)
true
if the string is a valid IPv4 IP address.ipAddress
- the string to checktrue
if the string is a valid IPv4 IP address;
false
otherwisepublic static boolean isIPv6Address(String ipAddress)
true
if the string is a valid IPv6 IP address.ipAddress
- the string to checktrue
if the string is a valid IPv6 IP address;
false
otherwisepublic static boolean isJulianDate(int month, int day, int year)
true
if the date is valid in the Julian calendar.month
- the month (0-based, meaning 0 for January)day
- the day of the monthyear
- the yeartrue
if the date is valid in the Julian calendar;
false
otherwisepublic static boolean isLUHN(String number)
true
if the string contains a valid number according
to the Luhn algorithm, commonly used to validate credit card numbers.number
- the string to checktrue
if the string contains a valid number according
to the Luhn algorithm; false
otherwisepublic static boolean isName(String name)
true
if the string is a name, meaning it contains
nothing but English letters and spaces.name
- the string to checktrue
if the string is a name; false
otherwisepublic static boolean isNotNull(Long l)
true
if the long number object is not
null
, meaning it is neither a null
reference or
zero.l
- the long number object to checktrue
if the long number object is not
null
; false
otherwisepublic static boolean isNotNull(Object obj)
true
if the object is not null
, using
the rules from isNotNull(Long)
or isNotNull(String)
if
the object is one of these types.obj
- the object to checktrue
if the object is not null
;
false
otherwisepublic static boolean isNotNull(String s)
true
if the string is not null
, meaning
it is not a null
reference, an empty string, whitespace, or
the string "null
", with or without leading or trailing
whitespace.s
- the string to checktrue
if the string is not null
;
false
otherwisepublic static boolean isNull(Long l)
true
if the long number object is null
,
meaning it is either a null
reference or zero.l
- the long number object to checktrue
if the long number object is null
;
false
otherwisepublic static boolean isNull(Object obj)
true
if the object is null
, using the
rules from isNull(Long)
or isNull(String)
if the object
is one of these types.obj
- the object to checktrue
if the object is null
;
false
otherwisepublic static boolean isNull(String s)
true
if the string is null
, meaning it
is a null
reference, an empty string, whitespace, or the
string "null
", with or without leading or trailing
whitespace.s
- the string to checktrue
if the string is null
;
false
otherwisepublic static boolean isNumber(String number)
true
if the string is a decimal integer number,
meaning it contains nothing but decimal digits.number
- the string to checktrue
if the string is a decimal integer number;
false
otherwisepublic static boolean isPassword(String password)
true
if the string is a valid password, meaning it
is at least four characters long and contains only letters and decimal
digits.password
- the string to checktrue
if the string is a valid password;
false
otherwisepublic static boolean isPhoneNumber(String phoneNumber)
true
if the string is a valid phone number. The only
requirement is that there are decimal digits in the string; length and
format are not checked.phoneNumber
- the string to checktrue
if the string is a valid phone number;
false
otherwisepublic static boolean isUri(String uri)
public static boolean isUrl(String url)
true
if the string is a valid URL based on the rules
in URL
.url
- the string to checktrue
if the string is a valid URL;
false
otherwisepublic static boolean isUrl(String url, boolean acceptRootRelative)
true
if the string is a valid URL based on the rules
in URL
. This method can also validate root relative URLs.url
- the string to checkacceptRootRelative
- whether a root relative URL should be acceptedtrue
if the string is a valid URL;
false
otherwisepublic static boolean isVariableName(String variableName)
true
if the string is a valid variable name in Java.variableName
- the string to checktrue
if the string is a valid variable name in Java;
false
otherwisepublic static boolean isVariableTerm(String s)
true
if the string is a valid variable term, meaning
it begins with "[$" and ends with "$]".s
- the string to checktrue
if the string is a valid variable term;
false
otherwisepublic static boolean isWhitespace(char c)
true
if the character is whitespace, meaning it is
either the null
character '0' or whitespace according to
Character.isWhitespace(char)
.c
- the character to checktrue
if the character is whitespace;
false
otherwisepublic static boolean isXml(String s)
true
if the string is an XML document. The only
requirement is that it contain either the xml start tag "".s
- the string to checktrue
if the string is an XML document;
false
otherwise