velosurf.validation
Class EmailCheck

java.lang.Object
  extended by velosurf.validation.FieldConstraint
      extended by velosurf.validation.EmailCheck

public class EmailCheck
extends FieldConstraint

An 'email' constraint. Syntax is:

    <column type="email"/>
  

Or:

     <column>
       <email [dns-check="true | false"] [smtp-check="true | false" ] [message="error-message"]>
     </column>
   

Author:
Claude Brisson

Nested Class Summary
(package private)  class EmailCheck.FastTimeoutConnect
          A socket with short timeout.
 
Field Summary
private  boolean dnsCheck
          whether to check dns.
private  boolean smtpCheck
          whether to check smtp server.
private static java.util.regex.Pattern validEmail
          valid email pattern.
 
Constructor Summary
EmailCheck()
          Default constructor.
EmailCheck(boolean dnsCheck, boolean smtpCheck)
          Constructor.
 
Method Summary
private  boolean checkSMTP(java.lang.String user, java.lang.String hostname)
          Check SMTP server.
 java.lang.String toString()
          return a string representation for this constraint.
 boolean validate(java.lang.Object data)
          Validate data against this constraint.
 
Methods inherited from class velosurf.validation.FieldConstraint
getMessage, setMessage, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dnsCheck

private boolean dnsCheck
whether to check dns.


smtpCheck

private boolean smtpCheck
whether to check smtp server.


validEmail

private static java.util.regex.Pattern validEmail
valid email pattern.

Constructor Detail

EmailCheck

public EmailCheck()
Default constructor.


EmailCheck

public EmailCheck(boolean dnsCheck,
                  boolean smtpCheck)
Constructor.

Parameters:
dnsCheck - whether to validate this email using a DNS query
smtpCheck - whether to validate this email using an STMP query
Method Detail

validate

public boolean validate(java.lang.Object data)
Validate data against this constraint.

Overrides:
validate in class FieldConstraint
Parameters:
data - data to validate
Returns:
whether data is valid

checkSMTP

private boolean checkSMTP(java.lang.String user,
                          java.lang.String hostname)
Check SMTP server.

Parameters:
user - username
hostname - hostname
Returns:
true if valid

toString

public java.lang.String toString()
return a string representation for this constraint.

Overrides:
toString in class java.lang.Object
Returns:
string


~ooOoo~