org.apache.james.mime4j.message
Class AbstractMessage

java.lang.Object
  extended by org.apache.james.mime4j.message.AbstractEntity
      extended by org.apache.james.mime4j.message.AbstractMessage
All Implemented Interfaces:
Body, Disposable, Entity, Message
Direct Known Subclasses:
MessageImpl

public abstract class AbstractMessage
extends AbstractEntity
implements Message

Abstract MIME message.


Constructor Summary
AbstractMessage()
           
 
Method Summary
 void createMessageId(java.lang.String hostname)
          Creates and sets a new Message-ID header field for this message.
 AddressList getBcc()
          Returns the value of the Bcc header field of this message as AddressList object or null if it is not present.
 AddressList getCc()
          Returns the value of the Cc header field of this message as AddressList object or null if it is not present.
 java.util.Date getDate()
          Returns the value of the Date header field of this message as Date object or null if it is not present.
 MailboxList getFrom()
          Returns the value of the From header field of this message as MailboxList object or null if it is not present.
 java.lang.String getMessageId()
          Returns the value of the Message-ID header field of this message or null if it is not present.
 AddressList getReplyTo()
          Returns the value of the Reply-To header field of this message as AddressList object or null if it is not present.
 Mailbox getSender()
          Returns the value of the Sender header field of this message as Mailbox object or null if it is not present.
 java.lang.String getSubject()
          Returns the (decoded) value of the Subject header field of this message or null if it is not present.
 AddressList getTo()
          Returns the value of the To header field of this message as AddressList object or null if it is not present.
protected abstract  AddressListField newAddressList(java.lang.String fieldName, java.util.Collection<? extends Address> addresses)
           
protected abstract  DateTimeField newDate(java.util.Date date, java.util.TimeZone zone)
           
protected abstract  MailboxField newMailbox(java.lang.String fieldName, Mailbox mailbox)
           
protected abstract  MailboxListField newMailboxList(java.lang.String fieldName, java.util.Collection<Mailbox> mailboxes)
           
protected abstract  ParsedField newMessageId(java.lang.String hostname)
           
protected abstract  UnstructuredField newSubject(java.lang.String subject)
           
 void setBcc(Address... bcc)
          Sets the Bcc header field of this message to the specified addresses.
 void setBcc(Address bcc)
          Sets the Bcc header field of this message to the specified address.
 void setBcc(java.util.Collection<? extends Address> bcc)
          Sets the Bcc header field of this message to the specified addresses.
 void setCc(Address... cc)
          Sets the Cc header field of this message to the specified addresses.
 void setCc(Address cc)
          Sets the Cc header field of this message to the specified address.
 void setCc(java.util.Collection<? extends Address> cc)
          Sets the Cc header field of this message to the specified addresses.
 void setDate(java.util.Date date)
          Sets the Date header field for this message.
 void setDate(java.util.Date date, java.util.TimeZone zone)
          Sets the Date header field for this message.
 void setFrom(java.util.Collection<Mailbox> from)
          Sets the From header field of this message to the specified mailbox addresses.
 void setFrom(Mailbox... from)
          Sets the From header field of this message to the specified mailbox addresses.
 void setFrom(Mailbox from)
          Sets the From header field of this message to the specified mailbox address.
 void setReplyTo(Address... replyTo)
          Sets the Reply-To header field of this message to the specified addresses.
 void setReplyTo(Address replyTo)
          Sets the Reply-To header field of this message to the specified address.
 void setReplyTo(java.util.Collection<? extends Address> replyTo)
          Sets the Reply-To header field of this message to the specified addresses.
 void setSender(Mailbox sender)
          Sets the Sender header field of this message to the specified mailbox address.
 void setSubject(java.lang.String subject)
          Sets the Subject header field for this message.
 void setTo(Address... to)
          Sets the To header field of this message to the specified addresses.
 void setTo(Address to)
          Sets the To header field of this message to the specified address.
 void setTo(java.util.Collection<? extends Address> to)
          Sets the To header field of this message to the specified addresses.
 
Methods inherited from class org.apache.james.mime4j.message.AbstractEntity
calcCharset, calcMimeType, calcTransferEncoding, dispose, getBody, getCharset, getContentTransferEncoding, getDispositionType, getFilename, getHeader, getMimeType, getParent, isMimeType, isMultipart, newContentDisposition, newContentDisposition, newContentTransferEncoding, newContentType, newUniqueBoundary, removeBody, setBody, setBody, setBody, setContentDisposition, setContentDisposition, setContentDisposition, setContentDisposition, setContentTransferEncoding, setFilename, setHeader, setMessage, setMultipart, setMultipart, setParent, setText, setText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.james.mime4j.dom.Entity
getBody, getCharset, getContentTransferEncoding, getDispositionType, getFilename, getHeader, getMimeType, getParent, isMultipart, removeBody, setBody, setHeader, setParent
 
Methods inherited from interface org.apache.james.mime4j.dom.Body
getParent, setParent
 
Methods inherited from interface org.apache.james.mime4j.dom.Disposable
dispose
 

Constructor Detail

AbstractMessage

public AbstractMessage()
Method Detail

getMessageId

public java.lang.String getMessageId()
Returns the value of the Message-ID header field of this message or null if it is not present.

Specified by:
getMessageId in interface Message
Returns:
the identifier of this message.

createMessageId

public void createMessageId(java.lang.String hostname)
Creates and sets a new Message-ID header field for this message. A Header is created if this message does not already have one.

Specified by:
createMessageId in interface Message
Parameters:
hostname - host name to be included in the identifier or null if no host name should be included.

newMessageId

protected abstract ParsedField newMessageId(java.lang.String hostname)

getSubject

public java.lang.String getSubject()
Returns the (decoded) value of the Subject header field of this message or null if it is not present.

Specified by:
getSubject in interface Message
Returns:
the subject of this message.

setSubject

public void setSubject(java.lang.String subject)
Sets the Subject header field for this message. The specified string may contain non-ASCII characters, in which case it gets encoded as an 'encoded-word' automatically. A Header is created if this message does not already have one.

Specified by:
setSubject in interface Message
Parameters:
subject - subject to set or null to remove the subject header field.

getDate

public java.util.Date getDate()
Returns the value of the Date header field of this message as Date object or null if it is not present.

Specified by:
getDate in interface Message
Returns:
the date of this message.

setDate

public void setDate(java.util.Date date)
Sets the Date header field for this message. This method uses the default TimeZone of this host to encode the specified Date object into a string.

Specified by:
setDate in interface Message
Parameters:
date - date to set or null to remove the date header field.

setDate

public void setDate(java.util.Date date,
                    java.util.TimeZone zone)
Sets the Date header field for this message. The specified TimeZone is used to encode the specified Date object into a string.

Specified by:
setDate in interface Message
Parameters:
date - date to set or null to remove the date header field.
zone - a time zone.

getSender

public Mailbox getSender()
Returns the value of the Sender header field of this message as Mailbox object or null if it is not present.

Specified by:
getSender in interface Message
Returns:
the sender of this message.

setSender

public void setSender(Mailbox sender)
Sets the Sender header field of this message to the specified mailbox address.

Specified by:
setSender in interface Message
Parameters:
sender - address to set or null to remove the header field.

getFrom

public MailboxList getFrom()
Returns the value of the From header field of this message as MailboxList object or null if it is not present.

Specified by:
getFrom in interface Message
Returns:
value of the from field of this message.

setFrom

public void setFrom(Mailbox from)
Sets the From header field of this message to the specified mailbox address.

Specified by:
setFrom in interface Message
Parameters:
from - address to set or null to remove the header field.

setFrom

public void setFrom(Mailbox... from)
Sets the From header field of this message to the specified mailbox addresses.

Specified by:
setFrom in interface Message
Parameters:
from - addresses to set or null or no arguments to remove the header field.

setFrom

public void setFrom(java.util.Collection<Mailbox> from)
Sets the From header field of this message to the specified mailbox addresses.

Specified by:
setFrom in interface Message
Parameters:
from - addresses to set or null or an empty collection to remove the header field.

getTo

public AddressList getTo()
Returns the value of the To header field of this message as AddressList object or null if it is not present.

Specified by:
getTo in interface Message
Returns:
value of the to field of this message.

setTo

public void setTo(Address to)
Sets the To header field of this message to the specified address.

Specified by:
setTo in interface Message
Parameters:
to - address to set or null to remove the header field.

setTo

public void setTo(Address... to)
Sets the To header field of this message to the specified addresses.

Specified by:
setTo in interface Message
Parameters:
to - addresses to set or null or no arguments to remove the header field.

setTo

public void setTo(java.util.Collection<? extends Address> to)
Sets the To header field of this message to the specified addresses.

Specified by:
setTo in interface Message
Parameters:
to - addresses to set or null or an empty collection to remove the header field.

getCc

public AddressList getCc()
Returns the value of the Cc header field of this message as AddressList object or null if it is not present.

Specified by:
getCc in interface Message
Returns:
value of the cc field of this message.

setCc

public void setCc(Address cc)
Sets the Cc header field of this message to the specified address.

Specified by:
setCc in interface Message
Parameters:
cc - address to set or null to remove the header field.

setCc

public void setCc(Address... cc)
Sets the Cc header field of this message to the specified addresses.

Specified by:
setCc in interface Message
Parameters:
cc - addresses to set or null or no arguments to remove the header field.

setCc

public void setCc(java.util.Collection<? extends Address> cc)
Sets the Cc header field of this message to the specified addresses.

Specified by:
setCc in interface Message
Parameters:
cc - addresses to set or null or an empty collection to remove the header field.

getBcc

public AddressList getBcc()
Returns the value of the Bcc header field of this message as AddressList object or null if it is not present.

Specified by:
getBcc in interface Message
Returns:
value of the bcc field of this message.

setBcc

public void setBcc(Address bcc)
Sets the Bcc header field of this message to the specified address.

Specified by:
setBcc in interface Message
Parameters:
bcc - address to set or null to remove the header field.

setBcc

public void setBcc(Address... bcc)
Sets the Bcc header field of this message to the specified addresses.

Specified by:
setBcc in interface Message
Parameters:
bcc - addresses to set or null or no arguments to remove the header field.

setBcc

public void setBcc(java.util.Collection<? extends Address> bcc)
Sets the Bcc header field of this message to the specified addresses.

Specified by:
setBcc in interface Message
Parameters:
bcc - addresses to set or null or an empty collection to remove the header field.

getReplyTo

public AddressList getReplyTo()
Returns the value of the Reply-To header field of this message as AddressList object or null if it is not present.

Specified by:
getReplyTo in interface Message
Returns:
value of the reply to field of this message.

setReplyTo

public void setReplyTo(Address replyTo)
Sets the Reply-To header field of this message to the specified address.

Specified by:
setReplyTo in interface Message
Parameters:
replyTo - address to set or null to remove the header field.

setReplyTo

public void setReplyTo(Address... replyTo)
Sets the Reply-To header field of this message to the specified addresses.

Specified by:
setReplyTo in interface Message
Parameters:
replyTo - addresses to set or null or no arguments to remove the header field.

setReplyTo

public void setReplyTo(java.util.Collection<? extends Address> replyTo)
Sets the Reply-To header field of this message to the specified addresses.

Specified by:
setReplyTo in interface Message
Parameters:
replyTo - addresses to set or null or an empty collection to remove the header field.

newAddressList

protected abstract AddressListField newAddressList(java.lang.String fieldName,
                                                   java.util.Collection<? extends Address> addresses)

newSubject

protected abstract UnstructuredField newSubject(java.lang.String subject)

newDate

protected abstract DateTimeField newDate(java.util.Date date,
                                         java.util.TimeZone zone)

newMailbox

protected abstract MailboxField newMailbox(java.lang.String fieldName,
                                           Mailbox mailbox)

newMailboxList

protected abstract MailboxListField newMailboxList(java.lang.String fieldName,
                                                   java.util.Collection<Mailbox> mailboxes)


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.