|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.randomcoder.validation.DataValidationUtils
public final class DataValidationUtils
Convenience methods to validate common data types.
Copyright (c) 2006, Craig Condit. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
| Method Summary | |
|---|---|
static String |
canonicalizeDomainName(String domain)
Returns the canonical representation of a domain name. |
static String |
canonicalizeTagName(String name)
Derives a canonical representation of a tag name. |
static boolean |
isValidDomainName(String domain)
Determines whether a domain name is valid or not. |
static boolean |
isValidDomainWildcard(String domain)
Determines if the given string matches a domain name wildcard. |
static boolean |
isValidEmailAddress(String email)
Validates email addresses according to RFC2822. |
static boolean |
isValidEmailAddress(String email,
boolean strict,
boolean local,
boolean wildcard)
Validates email addresses according to RFC2822. |
static boolean |
isValidIpAddress(String ipAddress)
Determines if a specified IP address is valid. |
static boolean |
isValidLocalEmailAccount(String email)
Validates local email account names. |
static boolean |
isValidUrl(String url)
Determines if a specified URL is valid. |
static boolean |
isValidUrl(String url,
String... allowedProtocols)
Determines if a specified URL is valid. |
static String[] |
splitEmailAddress(String email)
Splits an email address into its local and domain parts. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String canonicalizeDomainName(String domain)
domain - domain nam
public static boolean isValidDomainName(String domain)
NOTE: This method does not handle internationalized domain names.
domain - domain name
public static boolean isValidDomainWildcard(String domain)
domain - domain name
public static boolean isValidLocalEmailAccount(String email)
email - email account
public static boolean isValidIpAddress(String ipAddress)
NOTE: This is IPv4 only.
ipAddress - ip address to test
public static boolean isValidUrl(String url)
This validates a URL, and restricts the protocols to http and https.
url - URL to validate
public static boolean isValidUrl(String url,
String... allowedProtocols)
url - URL to validateallowedProtocols - array of valid protocols
public static String[] splitEmailAddress(String email)
email - email address
public static boolean isValidEmailAddress(String email)
This is equivalent to calling isValidEmailAddress(String, boolean, boolean, boolean)
with strict, local, and wildcard set to false.
email - email address
public static boolean isValidEmailAddress(String email,
boolean strict,
boolean local,
boolean wildcard)
email - email addressstrict - if name must be usable in DNS zone filelocal - if local addresses are to be allowedwildcard - if wildcards are to be allowed
public static String canonicalizeTagName(String name)
name - tag name
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||