org.apache.bval.extras.constraints.net
Class DomainValidator

java.lang.Object
  extended by org.apache.bval.extras.constraints.net.DomainValidator
All Implemented Interfaces:
ConstraintValidator<Domain,String>

public class DomainValidator
extends Object
implements ConstraintValidator<Domain,String>

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):

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


Constructor Summary
DomainValidator()
           
 
Method Summary
 void initialize(Domain domain)
          
 boolean isValid(String domain, ConstraintValidatorContext context)
          
(package private) static boolean isValidCountryCodeTld(String ccTld)
          Returns true if the specified String matches any IANA-defined country code top-level domain.
(package private) static boolean isValidGenericTld(String gTld)
          Returns true if the specified String matches any IANA-defined generic top-level domain.
(package private) static boolean isValidInfrastructureTld(String iTld)
          Returns true if the specified String matches any IANA-defined infrastructure top-level domain.
(package private) static boolean isValidLocalTld(String iTld)
          Returns true if the specified String matches any widely used "local" domains (localhost or localdomain).
(package private)  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
 

Constructor Detail

DomainValidator

public DomainValidator()
Method Detail

isValid

public boolean isValid(String domain,
                       ConstraintValidatorContext context)

Specified by:
isValid in interface ConstraintValidator<Domain,String>

isValidTld

boolean isValidTld(String tld)
Returns true if the specified String matches any IANA-defined top-level domain. Leading dots are ignored if present. The search is case-sensitive.

Parameters:
tld - the parameter to check for TLD status
Returns:
true if the parameter is a TLD

isValidInfrastructureTld

static boolean isValidInfrastructureTld(String iTld)
Returns true if the specified String matches any IANA-defined infrastructure top-level domain. Leading dots are ignored if present. The search is case-sensitive.

Parameters:
iTld - the parameter to check for infrastructure TLD status
Returns:
true if the parameter is an infrastructure TLD

isValidGenericTld

static boolean isValidGenericTld(String gTld)
Returns true if the specified String matches any IANA-defined generic top-level domain. Leading dots are ignored if present. The search is case-sensitive.

Parameters:
gTld - the parameter to check for generic TLD status
Returns:
true if the parameter is a generic TLD

isValidCountryCodeTld

static boolean isValidCountryCodeTld(String ccTld)
Returns true if the specified String matches any IANA-defined country code top-level domain. Leading dots are ignored if present. The search is case-sensitive.

Parameters:
ccTld - the parameter to check for country code TLD status
Returns:
true if the parameter is a country code TLD

isValidLocalTld

static boolean isValidLocalTld(String iTld)
Returns true if the specified String matches any widely used "local" domains (localhost or localdomain). Leading dots are ignored if present. The search is case-sensitive.

Parameters:
iTld - the parameter to check for local TLD status
Returns:
true if the parameter is an local TLD

initialize

public void initialize(Domain domain)

Specified by:
initialize in interface ConstraintValidator<Domain,String>


Copyright © 2010-2012 Apache Software Foundation. All Rights Reserved.