org.tentackle.util
Class EmailAddress

java.lang.Object
  extended by org.tentackle.util.EmailAddress

public class EmailAddress
extends Object

EmailAddress address.

Verifies an email address (syntax check via regex) and optionally validates the DNS MX records.

Author:
harald

Constructor Summary
EmailAddress()
          Creates an empty mail address
 
Method Summary
 void clear()
          Clears the mail address
 String getAddress()
          Gets the mail address as a string.
 String getError()
          Gets the error message.
 boolean isValid()
          Returns whether mail address is valid
 boolean setAddress(String address)
          Sets the mail address and verifies it.
 boolean setAddress(String address, boolean withDomainCheck)
          Sets the mail address and verifies it.
 void setError(String error)
          Sets the error message.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EmailAddress

public EmailAddress()
Creates an empty mail address

Method Detail

clear

public void clear()
Clears the mail address


setAddress

public boolean setAddress(String address,
                          boolean withDomainCheck)
Sets the mail address and verifies it.

Parameters:
address - the mail address
withDomainCheck - true if check domainname for DNS MX-records
Returns:
true if mail address is ok, false if not valid

setAddress

public boolean setAddress(String address)
Sets the mail address and verifies it. No MX lookup.

Parameters:
address - the mail address
Returns:
true if mail address is ok, false if not valid

getAddress

public String getAddress()
Gets the mail address as a string.

Returns:
the mail address as a string

toString

public String toString()
Description copied from class: java.lang.Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.

isValid

public boolean isValid()
Returns whether mail address is valid

Returns:
true if valid, else invalid or empty

getError

public String getError()
Gets the error message.

Returns:
the error message, null if none

setError

public void setError(String error)
Sets the error message.

Parameters:
error - the error message, null if none


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de