Package net.simplace.core.service
Class EmailValidator
java.lang.Object
net.simplace.core.service.EmailValidator
Perform email validations.
This class is a Singleton; you can retrieve the instance via the getInstance() method.
Based on a script by Sandeep V. Tamhankar http://javascript.internet.com
This implementation is not guaranteed to catch all possible errors in an email address. For example, an address like nobody@noplace.d- will pass validator, even though there is no TLD "d-"
.- Since:
- Validator 1.1
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor for subclasses to use. -
Method Summary
Modifier and TypeMethodDescriptionstatic EmailValidatorReturns the Singleton instance of this validator.booleanChecks if a field has a valid e-mail address.protected booleanisValidDomain(String domain) Returns true if the domain component of an email address is valid.protected booleanisValidIpAddress(org.apache.oro.text.perl.Perl5Util ipAddressMatcher) Validates an IP address.protected booleanisValidSymbolicDomain(String aDomain) Validates a symbolic domain name.protected booleanisValidUser(String user) Returns true if the user component of an email address is valid.protected StringstripComments(String emailStr) Recursively remove comments, and replace with a single space.
-
Constructor Details
-
EmailValidator
protected EmailValidator()Protected constructor for subclasses to use.
-
-
Method Details
-
getInstance
Returns the Singleton instance of this validator.- Returns:
- the Singleton instance of this validator
-
isValid
Checks if a field has a valid e-mail address.
- Parameters:
aEmail- The value validation is being performed on. Anullvalue is considered invalid.- Returns:
- true if a field has a valid e-mail address
-
isValidDomain
Returns true if the domain component of an email address is valid.- Parameters:
domain- being validated.- Returns:
- true if the domain component of an email address is valid
-
isValidUser
Returns true if the user component of an email address is valid.- Parameters:
user- being validated- Returns:
- true if the user component of an email address is valid
-
isValidIpAddress
protected boolean isValidIpAddress(org.apache.oro.text.perl.Perl5Util ipAddressMatcher) Validates an IP address. Returns true if valid.- Parameters:
ipAddressMatcher- Pattren matcher- Returns:
- true if an IP address is valid
-
isValidSymbolicDomain
Validates a symbolic domain name. Returns true if it's valid.- Parameters:
aDomain- symbolic domain name- Returns:
- true if a symbolic domain name is valid
-
stripComments
Recursively remove comments, and replace with a single space. The simpler regexps in the Email Addressing FAQ are imperfect - they will miss escaped chars in atoms, for example. Derived From Mail::RFC822::Address- Parameters:
emailStr-- Returns:
- resulting String
-