com.arsdigita.kernel
Class EmailAddress

java.lang.Object
  extended bycom.arsdigita.kernel.EmailAddress

public class EmailAddress
extends Object

Represents an email address. While this class does not extend DomainObject and is not a domain object class, it does provide email verification methods, which in turn may manipulate domain objects and persist the changes.

The verification-related data about an email address is persistent data, but the persistence details do not concern developers using this class. Furthermore, developers can instantiate this class for any email address, regardless of whether there is persistent data about the verification status of the email. Persistent data about verification status is only created when necessary. For example, a call to setIsBouncing() will result in persistent storage of the bouncing status for this email address.

The primary reason for not making this class extend DomainObject is so that developers can use it for any random email address without that email address necessarily being a persistent object stored somewhere in the database.

Version:
$Id: //core-platform/dev/src/com/arsdigita/kernel/EmailAddress.java#11 $
Author:
Oumi Mehrotra

Field Summary
static String versionId
           
 
Constructor Summary
EmailAddress(DataObject emailData)
          Creates a new EmailAddress instance backed by a data object of type com.arsdigita.kernel.EmailAddress.
EmailAddress(String emailAddress)
          Creates a new EmailAddress instance that encapsulates emailAddress.
 
Method Summary
 boolean equals(Object o)
          Checks whether the object specified by o is equal to this.
 String getEmailAddress()
          Gets the string email address encapsualted by this object.
protected  DomainObject getEmailDomainObject()
          Gets or creates a new DomainObject for this email address, encapsulating a data object of type com.arsdigita.kernel.EmailAddress.
 int hashCode()
           
 boolean isBouncing()
          Checks whether this email is set as bouncing.
 boolean isVerified()
          Sets whether this email has been verified.
 void setIsBouncing(boolean isBouncing)
          Sets whether email is bouncing.
 void setIsVerified(boolean isVerified)
          Sets whether this email is verified.
 String toString()
          Gets the string email address encapsualted by this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

EmailAddress

public EmailAddress(String emailAddress)
Creates a new EmailAddress instance that encapsulates emailAddress. Note that the services offered by this class (to check verification/bouncing status) are insensitive to the case of email address.

Parameters:
emailAddress - the email address to encapsulate

EmailAddress

public EmailAddress(DataObject emailData)
Creates a new EmailAddress instance backed by a data object of type com.arsdigita.kernel.EmailAddress. Should only be used by classes that involve an association between one of their data object types and the EmailAddress data object type.

Parameters:
emailData - the data object to encapsulate in the new domain object
Method Detail

isBouncing

public boolean isBouncing()
Checks whether this email is set as bouncing.

Returns:
true if this email is set as bouncing; false otherwise.

isVerified

public boolean isVerified()
Sets whether this email has been verified.

Returns:
true if this email has been verified; false otherwise.

setIsBouncing

public void setIsBouncing(boolean isBouncing)
Sets whether email is bouncing. Note that the setting does not persist until transaction commit.

Parameters:
isBouncing - true if this email is set as bouncing, false otherwise

setIsVerified

public void setIsVerified(boolean isVerified)
Sets whether this email is verified. Note that the setting does not persist until transaction commit.

Parameters:
isVerified - true if this email is verified, false otherwise

getEmailAddress

public String getEmailAddress()
Gets the string email address encapsualted by this object.

Returns:
the email address encapsualted by this object.

toString

public String toString()
Gets the string email address encapsualted by this object.

Returns:
the email address encapsualted by this object.

equals

public boolean equals(Object o)
Checks whether the object specified by o is equal to this. Returns true if the o is not null, is an instance of EmailAddress, and encapsulates the same email address (that is, if o.getEmailAddress().toLower() == this.getEmailAddress().toLower()).


hashCode

public int hashCode()

getEmailDomainObject

protected DomainObject getEmailDomainObject()
Gets or creates a new DomainObject for this email address, encapsulating a data object of type com.arsdigita.kernel.EmailAddress. First tries to retrieve a DomainObject for this email address. If none exists, a new one is created. However, the new DomainObject will *not* persist until one of the setXXX methods in this class is called or the returned DomainObject's save() method is called.

This method is primarily useful for other domain objects whose encapsulated data objects have associations to com.arsdigita.kernel.EmailAddress. Such domain object classes can use getEmailDomainObject().addToAssociation(). For example, the method Party.addEmailAddress(EmailAddress emailAddress) internally calls emailAddress.getDomainObject().addToAssociation( (DataAssociation) get ("emailAddress") )

Returns:
the DomainObject object for this email address.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC