TsBiff 1.3


ts.mail
Class DefaultMailModel

java.lang.Object
  |
  +--ts.mail.DefaultMailModel
All Implemented Interfaces:
MailModel

public class DefaultMailModel
extends java.lang.Object
implements MailModel

This class implements the MailModel interface and represents a generic mail messsage.

Version:
$Id: DefaultMailModel.java,v 1.4 1999/02/21 08:47:12 hauk Exp $
Author:
Jan-Henrik Haukeland <hauk@tildeslash.com>

Fields inherited from interface ts.mail.MailModel
NO_FIELD_VALUE
 
Constructor Summary
DefaultMailModel()
          Create an empty object, with default values
 
Method Summary
 java.util.Enumeration getCCHeaders()
           
 java.lang.String getDateField()
           
 java.lang.String getFromField()
           
 java.lang.String getIdField()
           
 java.lang.String getMailBody()
           
 java.lang.String getOrganizationField()
           
 java.lang.String getReplyToField()
           
 java.lang.String getSubjectField()
           
 java.lang.String getToField()
           
 java.util.Enumeration getXHeaderKeys()
           
 java.lang.String getXHeaderValue(java.lang.String aKey)
           
 boolean hasCCHeaders()
           
 boolean hasXHeaders()
           
 void setCCHeader(java.lang.String aCopy)
          Set a Carbon-copy (cc:) address
 void setDateField(java.lang.String aDate)
          Set the mail date
 void setFromField(java.lang.String aFromField)
          Set the mail's from-field
 void setIdField(java.lang.String aId)
          Set the mail message id
 void setMailBody(java.lang.String aMailBody)
          Set the mail's content.
 void setOrganizationField(java.lang.String aOrganizationField)
          Set the mail's organization field.
 void setReplyToField(java.lang.String aReplyToField)
          Set the mail's Reply-to field.
 void setSubjectField(java.lang.String aSubjectField)
          Set the mail's subject-field.
 void setToField(java.lang.String aToField)
          Set the mail's to-field
 void setXHeader(java.lang.String aXkey, java.lang.String aXvalue)
          Set a X-something header.
 java.lang.String toString()
          Overriding java.object.toString: Print the content nicely formated
 void validate()
          This method validate the mail message fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultMailModel

public DefaultMailModel()
Create an empty object, with default values
Method Detail

setIdField

public void setIdField(java.lang.String aId)
                throws java.lang.IllegalArgumentException
Set the mail message id
Specified by:
setIdField in interface MailModel
Parameters:
aId - - The mail message id
Throws:
java.lang.IllegalArgumentException - Is thrown if the parameter is null

setToField

public void setToField(java.lang.String aToField)
                throws java.lang.IllegalArgumentException
Set the mail's to-field
Specified by:
setToField in interface MailModel
Parameters:
aToField - - The mail's to-field
Throws:
java.lang.IllegalArgumentException - Is thrown if the parameter is null

setFromField

public void setFromField(java.lang.String aFromField)
                  throws java.lang.IllegalArgumentException
Set the mail's from-field
Specified by:
setFromField in interface MailModel
Parameters:
aFromField - - The mail's from-field
Throws:
java.lang.IllegalArgumentException - Is thrown if the parameter is null

setDateField

public void setDateField(java.lang.String aDate)
                  throws java.lang.IllegalArgumentException
Set the mail date
Specified by:
setDateField in interface MailModel
Parameters:
aDate - - The mail's date as a string
Throws:
java.lang.IllegalArgumentException - Is thrown if the parameter is null

setSubjectField

public void setSubjectField(java.lang.String aSubjectField)
Set the mail's subject-field. No exception is thrown since the subject field is allowed to be empty.
Specified by:
setSubjectField in interface MailModel
Parameters:
aSubjectField - - The mail's subject-field

setReplyToField

public void setReplyToField(java.lang.String aReplyToField)
Set the mail's Reply-to field. No exception is thrown since this field is allowed to be empty
Specified by:
setReplyToField in interface MailModel
Parameters:
aReplyToField - - The mail's Reply-to field

setOrganizationField

public void setOrganizationField(java.lang.String aOrganizationField)
Set the mail's organization field. No exception is thrown since this field is allowed to be empty
Specified by:
setOrganizationField in interface MailModel
Parameters:
aOrganizationField - The mail's organization field

setMailBody

public void setMailBody(java.lang.String aMailBody)
Set the mail's content. No exception is thrown since the mail body is allowed to be empty.
Specified by:
setMailBody in interface MailModel
Parameters:
aMailBody - - The mail's content

setCCHeader

public void setCCHeader(java.lang.String aCopy)
                 throws java.lang.IllegalArgumentException
Set a Carbon-copy (cc:) address
Specified by:
setCCHeader in interface MailModel
Parameters:
aAddress - The cc: mail address
Throws:
java.lang.IllegalArgumentException - Is thrown if the parameter is null

setXHeader

public void setXHeader(java.lang.String aXkey,
                       java.lang.String aXvalue)
                throws java.lang.IllegalArgumentException
Set a X-something header. The method does no syntax checking on the submitted header, because this class should not know the format of any of it's fields.
Specified by:
setXHeader in interface MailModel
Parameters:
aXkey - The X-header name
aXvalue - The X-Header's value
Throws:
java.lang.IllegalArgumentException - Is thrown if the parameters is null or if the key does not start with "X-"

getIdField

public java.lang.String getIdField()
Specified by:
getIdField in interface MailModel
Returns:
The mail message id

getToField

public java.lang.String getToField()
Specified by:
getToField in interface MailModel
Returns:
Return the to field

getFromField

public java.lang.String getFromField()
Specified by:
getFromField in interface MailModel
Returns:
Return the from field

getDateField

public java.lang.String getDateField()
Specified by:
getDateField in interface MailModel
Returns:
The date field

getSubjectField

public java.lang.String getSubjectField()
Specified by:
getSubjectField in interface MailModel
Returns:
Return the subject field

getReplyToField

public java.lang.String getReplyToField()
Specified by:
getReplyToField in interface MailModel
Returns:
Return the reply-to field

getOrganizationField

public java.lang.String getOrganizationField()
Specified by:
getOrganizationField in interface MailModel
Returns:
Return the organization field

getCCHeaders

public java.util.Enumeration getCCHeaders()
Specified by:
getCCHeaders in interface MailModel
Returns:
An enumeration of the Carbon-copy headers

getXHeaderKeys

public java.util.Enumeration getXHeaderKeys()
Specified by:
getXHeaderKeys in interface MailModel
Returns:
An enumeration of the X-header keys

getXHeaderValue

public java.lang.String getXHeaderValue(java.lang.String aKey)
Specified by:
getXHeaderValue in interface MailModel
Returns:
The value for the given X-header key

getMailBody

public java.lang.String getMailBody()
Specified by:
getMailBody in interface MailModel
Returns:
Return the mail body

hasCCHeaders

public boolean hasCCHeaders()
Specified by:
hasCCHeaders in interface MailModel
Returns:
true if the mail has any cc headers

hasXHeaders

public boolean hasXHeaders()
Specified by:
hasXHeaders in interface MailModel
Returns:
true if the mail has any X- headers

validate

public void validate()
              throws java.lang.IllegalStateException
This method validate the mail message fields. An exception is thrown if any of the required fields is empty. A warning is printed if the subject-field or mail body are empty.
Specified by:
validate in interface MailModel
Throws:
java.lang.IllegalStateException - Is thrown if invalid

toString

public java.lang.String toString()
Overriding java.object.toString: Print the content nicely formated
Overrides:
toString in class java.lang.Object
Returns:
A string representation of the Mail object

TsBiff 1.3