|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.validator.routines.DomainValidator
public class DomainValidator
Domain name validation routines.
This validator provides methods for validating Internet domain names and top-level domains.
Domain names are evaluated according to the standards RFC1034, section 3, and RFC1123, section 2.1. No accomodation is provided for the specialized needs of other applications; if the domain name has been URL-encoded, for example, validation will fail even though the equivalent plaintext version of the same name would have passed.
Validation is also provided for top-level domains (TLDs) as defined and maintained by the Internet Assigned Numbers Authority (IANA):
isValidInfrastructureTld(java.lang.String)
- validates infrastructure TLDs
(.arpa
, etc.)isValidGenericTld(java.lang.String)
- validates generic TLDs
(.com, .org
, etc.)isValidCountryCodeTld(java.lang.String)
- validates country code TLDs
(.us, .uk, .cn
, etc.)
(NOTE: This class does not provide IP address lookup for domain names or
methods to ensure that a given domain name matches a specific IP; see
InetAddress
for that functionality.)
Method Summary | |
---|---|
static DomainValidator |
getInstance()
Returns the singleton instance of this validator. |
static DomainValidator |
getInstance(boolean allowLocal)
Returns the singleton instance of this validator, with local validation as required. |
boolean |
isValid(String domain)
Returns true if the specified String parses
as a valid domain name with a recognized top-level domain. |
boolean |
isValidCountryCodeTld(String ccTld)
Returns true if the specified String matches any
IANA-defined country code top-level domain. |
boolean |
isValidGenericTld(String gTld)
Returns true if the specified String matches any
IANA-defined generic top-level domain. |
boolean |
isValidInfrastructureTld(String iTld)
Returns true if the specified String matches any
IANA-defined infrastructure top-level domain. |
boolean |
isValidLocalTld(String iTld)
Returns true if the specified String matches any
widely used "local" domains (localhost or localdomain). |
boolean |
isValidTld(String tld)
Returns true if the specified String matches any
IANA-defined top-level domain. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DomainValidator getInstance()
public static DomainValidator getInstance(boolean allowLocal)
allowLocal
- Should local addresses be considered valid?
public boolean isValid(String domain)
String
parses
as a valid domain name with a recognized top-level domain.
The parsing is case-sensitive.
domain
- the parameter to check for domain name syntax
public boolean isValidTld(String tld)
String
matches any
IANA-defined top-level domain. Leading dots are ignored if present.
The search is case-sensitive.
tld
- the parameter to check for TLD status
public boolean isValidInfrastructureTld(String iTld)
String
matches any
IANA-defined infrastructure top-level domain. Leading dots are
ignored if present. The search is case-sensitive.
iTld
- the parameter to check for infrastructure TLD status
public boolean isValidGenericTld(String gTld)
String
matches any
IANA-defined generic top-level domain. Leading dots are ignored
if present. The search is case-sensitive.
gTld
- the parameter to check for generic TLD status
public boolean isValidCountryCodeTld(String ccTld)
String
matches any
IANA-defined country code top-level domain. Leading dots are
ignored if present. The search is case-sensitive.
ccTld
- the parameter to check for country code TLD status
public boolean isValidLocalTld(String iTld)
String
matches any
widely used "local" domains (localhost or localdomain). Leading dots are
ignored if present. The search is case-sensitive.
iTld
- the parameter to check for local TLD status
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |