Liferay 6.2-ce-ga5

com.liferay.portal.kernel.util
Class Validator

java.lang.Object
  extended by com.liferay.portal.kernel.util.Validator

public class Validator
extends Object

Provides utility methods related to data validation and format checking.


Constructor Summary
Validator()
           
 
Method Summary
static boolean equals(boolean boolean1, boolean boolean2)
          Returns true if the booleans are equal.
static boolean equals(byte byte1, byte byte2)
          Returns true if the bytes are equal.
static boolean equals(char char1, char char2)
          Returns true if the characters are equal.
static boolean equals(double double1, double double2)
          Returns true if the doubles are equal.
static boolean equals(float float1, float float2)
          Returns true if the floats are equal.
static boolean equals(int int1, int int2)
          Returns true if the integers are equal.
static boolean equals(long long1, long long2)
          Returns true if the long integers are equal.
static boolean equals(Object obj1, Object obj2)
          Returns true if the objects are either equal, the same instance, or both null.
static boolean equals(short short1, short short2)
          Returns true if the short integers are equal.
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 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 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 isParentDirAllowed)
           
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(Object[] array)
          Deprecated. As of 6.2.0, replaced by ArrayUtil.isNotEmpty( Object[])
static boolean isNotNull(String s)
          Returns true if the string is not null, meaning it is not a null reference, nothing but spaces, or the string "null".
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(Object[] array)
          Deprecated. As of 6.2.0, replaced by ArrayUtil.isEmpty(Object[])
static boolean isNull(String s)
          Returns true if the string is null, meaning it is a null reference, nothing but spaces, or the string "null".
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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validator

public Validator()
Method Detail

equals

public static boolean equals(boolean boolean1,
                             boolean boolean2)
Returns true if the booleans are equal.

Parameters:
boolean1 - the first boolean
boolean2 - the second boolean
Returns:
true if the booleans are equal; false otherwise

equals

public static boolean equals(byte byte1,
                             byte byte2)
Returns true if the bytes are equal.

Parameters:
byte1 - the first byte
byte2 - the second byte
Returns:
true if the bytes are equal; false otherwise

equals

public static boolean equals(char char1,
                             char char2)
Returns true if the characters are equal.

Parameters:
char1 - the first character
char2 - the second character
Returns:
true if the characters are equal; false otherwise

equals

public static boolean equals(double double1,
                             double double2)
Returns true if the doubles are equal.

Parameters:
double1 - the first double
double2 - the second double
Returns:
true if the doubles are equal; false otherwise

equals

public static boolean equals(float float1,
                             float float2)
Returns true if the floats are equal.

Parameters:
float1 - the first float
float2 - the second float
Returns:
true if the floats are equal; false otherwise

equals

public static boolean equals(int int1,
                             int int2)
Returns true if the integers are equal.

Parameters:
int1 - the first integer
int2 - the second integer
Returns:
true if the integers are equal; false otherwise

equals

public static boolean equals(long long1,
                             long long2)
Returns true if the long integers are equal.

Parameters:
long1 - the first long integer
long2 - the second long integer
Returns:
true if the long integers are equal; false otherwise

equals

public static boolean equals(Object obj1,
                             Object obj2)
Returns true if the objects are either equal, the same instance, or both null.

Parameters:
obj1 - the first object
obj2 - the second object
Returns:
true if the objects are either equal, the same instance, or both null; false otherwise

equals

public static boolean equals(short short1,
                             short short2)
Returns true if the short integers are equal.

Parameters:
short1 - the first short integer
short2 - the second short integer
Returns:
true if the short integers are equal; false otherwise

equalsSorted

public static boolean equalsSorted(boolean[] booleanArray1,
                                   boolean[] booleanArray2)
Returns true if the boolean arrays are equal.

Parameters:
booleanArray1 - the first boolean array
booleanArray2 - the second boolean array
Returns:
true if the booleans arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(byte[] byteArray1,
                                   byte[] byteArray2)
Returns true if the byte arrays are equal.

Parameters:
byteArray1 - the first byte array
byteArray2 - the second byte array
Returns:
true if the byte arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(char[] charArray1,
                                   char[] charArray2)
Returns true if the char arrays are equal.

Parameters:
charArray1 - the first char array
charArray2 - the second char array
Returns:
true if the char arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(double[] doubleArray1,
                                   double[] doubleArray2)
Returns true if the double arrays are equal.

Parameters:
doubleArray1 - the first double array
doubleArray2 - the second double array
Returns:
true if the double arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(float[] floatArray1,
                                   float[] floatArray2)
Returns true if the float arrays are equal.

Parameters:
floatArray1 - the first float array
floatArray2 - the second char array
Returns:
true if the float arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(int[] intArray1,
                                   int[] intArray2)
Returns true if the int arrays are equal.

Parameters:
intArray1 - the first int array
intArray2 - the second int array
Returns:
true if the int arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(long[] longArray1,
                                   long[] longArray2)
Returns true if the long arrays are equal.

Parameters:
longArray1 - the first long array
longArray2 - the second long array
Returns:
true if the long arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(Object[] objArray1,
                                   Object[] objArray2)
Returns true if the object arrays are equal.

Parameters:
objArray1 - the first object array
objArray2 - the second object array
Returns:
true if the object arrays are equal; false otherwise

equalsSorted

public static boolean equalsSorted(short[] shortArray1,
                                   short[] shortArray2)
Returns true if the short arrays are equal.

Parameters:
shortArray1 - the first short array
shortArray2 - the second short array
Returns:
true if the short arrays are equal; false otherwise

isAddress

public static boolean isAddress(String address)
Returns 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.

Parameters:
address - the string to check
Returns:
true if the string is an email address; false otherwise

isAlphanumericName

public static boolean isAlphanumericName(String name)
Returns true if the string is an alphanumeric name, meaning it contains nothing but English letters, numbers, and spaces.

Parameters:
name - the string to check
Returns:
true if the string is an Alphanumeric name; false otherwise

isAscii

public static boolean isAscii(char c)
Returns true if the character is in the ASCII character set. This includes characters with integer values between 32 and 126 (inclusive).

Parameters:
c - the character to check
Returns:
true if the character is in the ASCII character set; false otherwise

isBlank

public static boolean isBlank(String s)

isChar

public static boolean isChar(char c)
Returns true if the character is an upper or lower case English letter.

Parameters:
c - the character to check
Returns:
true if the character is an upper or lower case English letter; false otherwise

isChar

public static boolean isChar(String s)
Returns true if string consists only of upper and lower case English letters.

Parameters:
s - the string to check
Returns:
true if the string consists only of upper and lower case English letters

isDate

public static boolean isDate(int month,
                             int day,
                             int year)
Returns true if the date is valid in the Gregorian calendar.

Parameters:
month - the month to check
day - the day to check
year - the year to check
Returns:
true if the date is valid in the Gregorian calendar; false otherwise

isDigit

public static boolean isDigit(char c)
Returns true if the character is a digit between 0 and 9 (inclusive).

Parameters:
c - the character to check
Returns:
true if the character is a digit between 0 and 9 (inclusive); false otherwise

isDigit

public static boolean isDigit(String s)
Returns true if the string consists of only digits between 0 and 9 (inclusive).

Parameters:
s - the string to check
Returns:
true if the string consists of only digits between 0 and 9 (inclusive); false otherwise

isDomain

public static boolean isDomain(String domainName)
Returns 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).

Parameters:
domainName - the string to check
Returns:
true if the string is a valid domain name; false otherwise

isEmailAddress

public static boolean isEmailAddress(String emailAddress)
Returns true if the string is a valid email address.

Parameters:
emailAddress - the string to check
Returns:
true if the string is a valid email address; false otherwise

isEmailAddressSpecialChar

public static boolean isEmailAddressSpecialChar(char c)
Returns true if the character is a special character in an email address.

Parameters:
c - the character to check
Returns:
true if the character is a special character in an email address; false otherwise

isFileExtension

public static boolean isFileExtension(String fileExtension)
Returns true if the file extension is valid.

Parameters:
fileExtension - string to check
Returns:
true if the extension is valid; false otherwise

isFileName

public static boolean isFileName(String name)

isFilePath

public static boolean isFilePath(String path,
                                 boolean isParentDirAllowed)

isGregorianDate

public static boolean isGregorianDate(int month,
                                      int day,
                                      int year)
Returns true if the date is valid in the Gregorian calendar.

Parameters:
month - the month (0-based, meaning 0 for January)
day - the day of the month
year - the year
Returns:
true if the date is valid; false otherwise

isHex

public static boolean isHex(String s)
Returns 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.

Parameters:
s - the string to check
Returns:
true if the string is a hexidecimal number; false otherwise
See Also:
isNull(String)

isHostName

public static boolean isHostName(String name)
Returns true if the string is a valid host name.

Parameters:
name - the string to check
Returns:
true if the string is a valid host name; false otherwise

isHTML

public static boolean isHTML(String s)
Returns true if the string is an HTML document. The only requirement is that it contain the opening and closing html tags.

Parameters:
s - the string to check
Returns:
true if the string is an HTML document; false otherwise

isIPAddress

public static boolean isIPAddress(String ipAddress)
Returns true if the string is a valid IPv4 or IPv6 IP address.

Parameters:
ipAddress - the string to check
Returns:
true if the string is a valid IPv4 or IPv6 IP address; false otherwise

isIPv4Address

public static boolean isIPv4Address(String ipAddress)
Returns true if the string is a valid IPv4 IP address.

Parameters:
ipAddress - the string to check
Returns:
true if the string is a valid IPv4 IP address; false otherwise

isIPv6Address

public static boolean isIPv6Address(String ipAddress)
Returns true if the string is a valid IPv6 IP address.

Parameters:
ipAddress - the string to check
Returns:
true if the string is a valid IPv6 IP address; false otherwise

isJulianDate

public static boolean isJulianDate(int month,
                                   int day,
                                   int year)
Returns true if the date is valid in the Julian calendar.

Parameters:
month - the month (0-based, meaning 0 for January)
day - the day of the month
year - the year
Returns:
true if the date is valid in the Julian calendar; false otherwise

isLUHN

public 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.

Parameters:
number - the string to check
Returns:
true if the string contains a valid number according to the Luhn algorithm; false otherwise

isName

public static boolean isName(String name)
Returns true if the string is a name, meaning it contains nothing but English letters and spaces.

Parameters:
name - the string to check
Returns:
true if the string is a name; false otherwise

isNotNull

public static boolean isNotNull(Long l)
Returns true if the long number object is not null, meaning it is neither a null reference or zero.

Parameters:
l - the long number object to check
Returns:
true if the long number object is not null; false otherwise

isNotNull

public 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.

Parameters:
obj - the object to check
Returns:
true if the object is not null; false otherwise

isNotNull

public static boolean isNotNull(Object[] array)
Deprecated. As of 6.2.0, replaced by ArrayUtil.isNotEmpty( Object[])


isNotNull

public static boolean isNotNull(String s)
Returns true if the string is not null, meaning it is not a null reference, nothing but spaces, or the string "null".

Parameters:
s - the string to check
Returns:
true if the string is not null; false otherwise

isNull

public static boolean isNull(Long l)
Returns true if the long number object is null, meaning it is either a null reference or zero.

Parameters:
l - the long number object to check
Returns:
true if the long number object is null; false otherwise

isNull

public 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.

Parameters:
obj - the object to check
Returns:
true if the object is null; false otherwise

isNull

public static boolean isNull(Object[] array)
Deprecated. As of 6.2.0, replaced by ArrayUtil.isEmpty(Object[])


isNull

public static boolean isNull(String s)
Returns true if the string is null, meaning it is a null reference, nothing but spaces, or the string "null".

Parameters:
s - the string to check
Returns:
true if the string is null; false otherwise

isNumber

public static boolean isNumber(String number)
Returns true if the string is a decimal integer number, meaning it contains nothing but decimal digits.

Parameters:
number - the string to check
Returns:
true if the string is a decimal integer number; false otherwise

isPassword

public 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.

Parameters:
password - the string to check
Returns:
true if the string is a valid password; false otherwise

isPhoneNumber

public static boolean isPhoneNumber(String phoneNumber)
Returns 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.

Parameters:
phoneNumber - the string to check
Returns:
true if the string is a valid phone number; false otherwise

isUri

public static boolean isUri(String uri)

isUrl

public static boolean isUrl(String url)
Returns true if the string is a valid URL based on the rules in URL.

Parameters:
url - the string to check
Returns:
true if the string is a valid URL; false otherwise

isVariableName

public static boolean isVariableName(String variableName)
Returns true if the string is a valid variable name in Java.

Parameters:
variableName - the string to check
Returns:
true if the string is a valid variable name in Java; false otherwise

isVariableTerm

public static boolean isVariableTerm(String s)
Returns true if the string is a valid variable term, meaning it begins with "[$" and ends with "$]".

Parameters:
s - the string to check
Returns:
true if the string is a valid variable term; false otherwise

isWhitespace

public 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).

Parameters:
c - the character to check
Returns:
true if the character is whitespace; false otherwise

isXml

public static boolean isXml(String s)
Returns true if the string is an XML document. The only requirement is that it contain either the xml start tag "".

Parameters:
s - the string to check
Returns:
true if the string is an XML document; false otherwise

Liferay 6.2-ce-ga5