protected boolean isValidDomain ( String domain ) { // see if domain is an IP address in brackets Matcher ipDomainMatcher = IP_DOMAIN_PATTERN . matcher ( domain ) ; if ( ipDomainMatcher . matches ( ) ) { InetAddressValidator inetAddressValidator = InetAddressValidator . getInstance ( ) ; return inetAddressValidator . isValid ( ipDomainMatcher . group ( 1 ) ) ; } // Domain is symbolic name DomainValidator domainValidator = DomainValidator . getInstance ( allowLocal ) ; return domainValidator . isValid ( domain ) || domainValidator . isValidTld ( domain ) ; }
Returns true if the domain component of an email address is valid .