|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.mail.Part
com.funambol.mail.Message
public class Message
This class models a MIME-style email message.
Message
extends the Part
abstract class, and
contains a set of attributes and a 'content'. Messages within a folder also
have a set of flags that describe its state within the folder. This state is
in turn described by the calss MessageFlags.
Message
defines some new attributes in addition to those
defined in Part
. These attributes specify meta-data for the
message -i.e., addressing and descriptive information about the message.
Clients create new MIME-style messages building an empty Message
object and then filling it with appropriate attributes and content.
Message
objects can be obtained from a Folder
too.
TODO: A Message object obtained from a folder is just a lightweight reference to the actual message. The Message is 'lazily' filled up (on demand) when each item is requested from the message. Note that certain folder implementations may return Message objects that are pre-filled with certain user-specified items.
Field Summary | |
---|---|
static java.lang.String |
BCC
BCC header name |
static java.lang.String |
CC
CC header name |
protected java.lang.Object |
content
The content of this Message as an Object (it can be a Multipart or a String) When it is a String, it is stored in the native encoding of the application, regardless of how it has been transferred. |
protected MessageFlags |
flags
A combination of status flags for this Message within a
folder, e.g. |
static java.lang.String |
FROM
FROM header name |
protected boolean |
incomplete
True is the message has been read by the store but without content |
protected java.lang.String |
msgid
The unique ID of this message. |
protected Folder |
parent
A Folder can contain many Messages, and each Message has a reference to its Folder |
protected java.util.Date |
received
The received date of this message |
static java.lang.String |
REPLYTO
REPLY-TO header name |
protected java.util.Date |
sent
The sent date of this message |
static java.lang.String |
SUBJECT
SUBJECT header name |
static java.lang.String |
TO
TO header name |
Fields inherited from class com.funambol.mail.Part |
---|
CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, contentType, ENC_7BIT, ENC_8BIT, ENC_B64, ENC_QP, headers, MULTIPART, MULTIPART_ALTERNATIVE, MULTIPART_MIXED, TEXT_PLAIN |
Constructor Summary | |
---|---|
Message()
The default constructor |
Method Summary | |
---|---|
void |
addRecipient(Address address)
Add the specified recipient to the correct header, based on the Address type (see com.funambol.mail.Address for the defined types). |
void |
addRecipients(Address[] list)
Add the specified recipients to the correct header, based on the Address type. |
void |
deserialize(java.io.DataInputStream din)
|
Address[] |
getBcc()
Get the Bcc: recipients |
Address[] |
getCc()
Get the Cc: recipients |
java.lang.Object |
getContent()
Get the content of this message: can be a String or a Multipart. |
MessageFlags |
getFlags()
Returns the flag mask for this message. |
Address |
getFrom()
Get the sender address |
java.lang.String |
getMessageId()
Returns the String representing the ID of this Message. |
Folder |
getParent()
Returns this message's parent Folder |
java.util.Date |
getReceivedDate()
Returns the received date of this message. |
Address[] |
getReplyTo()
Get the Reply-To: address (to from if not specified) |
java.util.Date |
getSentDate()
Returns the sent date of this message. |
java.lang.String |
getSubject()
Convenience method to return the content of the RFC 2822 "Subject:" header field |
java.lang.String |
getTextContent()
Convenience method to get the body for text messages TODO: retrieve the text of the first BodyPart for MultiPart? |
Address[] |
getTo()
Get the destination recipients |
void |
removeAllRecipients(int type)
This method removes all the recipients of the specified type from this message. |
void |
serialize(java.io.DataOutputStream dout)
|
void |
setBcc(Address[] bcclist)
Set the content of the RFC 2822 "Bcc:" (blind carbon copy) header with the provided addresses, passed as an Address array |
void |
setCc(Address[] cclist)
Set the content of the RFC 2822 "Cc:" (carbon copy) header with the provided addresses, passed as an Address array |
void |
setContent(java.lang.Object content)
Sets the content of this Message. |
void |
setContent(java.lang.Object content,
java.lang.String type)
Sets the content of this Message. |
void |
setFlags(MessageFlags flags)
Sets the flag mask for this message. |
void |
setFrom(Address from)
This method sets the content of the RFC 2822 "From:" header with the given Address |
void |
setMessageId(java.lang.String messageId)
Sets the String representing the unique ID of this Message |
void |
setParent(Folder parent)
Sets a reference to the Folder this Message
is contained in |
void |
setReceivedDate(java.util.Date received)
Set the received date |
void |
setReplyTo(Address[] replytolist)
Set the content of the RFC 2822 "Bcc:" (blind carbon copy) header with the provided addresses, passed as an Address array |
void |
setSentDate(java.util.Date sent)
Set the sent date |
void |
setSubject(java.lang.String subject)
Set the content of the RFC 2822 "Subject:" header. |
void |
setTo(Address[] tolist)
Set the content of the RFC 2822 "To:" header with the provided addresses, passed as an Address array |
Methods inherited from class com.funambol.mail.Part |
---|
addHeader, getAllHeaders, getContentType, getHeader, isMultipart, isText, isTextHtml, isTextPlain, removeHeader, setContentType, setHeader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TO
public static final java.lang.String FROM
public static final java.lang.String CC
public static final java.lang.String BCC
public static final java.lang.String REPLYTO
public static final java.lang.String SUBJECT
protected java.lang.String msgid
protected MessageFlags flags
Message
within a
folder, e.g. 'read', 'forwarded', 'draft' etc.
protected Folder parent
protected java.util.Date sent
protected java.util.Date received
protected java.lang.Object content
protected boolean incomplete
Constructor Detail |
---|
public Message()
Initialize the message with default values suitable for sending it (content-type: text/plain, sent and received date equal to current time). The caller must override these values with the desired content.
Method Detail |
---|
public void addRecipients(Address[] list) throws MailException
list
- list of Adresses to add to the recipient header.
MailException
public void addRecipient(Address address) throws MailException
address
- the address to add to the recipient header.
MailException
public Address getFrom() throws MailException
MailException
public Address[] getTo() throws MailException
MailException
public Address[] getCc() throws MailException
MailException
public Address[] getBcc() throws MailException
MailException
public Address[] getReplyTo() throws MailException
MailException
public MessageFlags getFlags()
public java.lang.String getMessageId()
public java.lang.String getSubject()
public java.util.Date getSentDate()
public void setFlags(MessageFlags flags)
flags
- the flag mask for this message.public java.util.Date getReceivedDate()
public void removeAllRecipients(int type)
type
- one of the defined types inpublic void setFrom(Address from)
Address
public void setTo(Address[] tolist)
tolist
- list of Adresses to put in the To: listpublic void setCc(Address[] cclist)
cclist
- list of Adresses to put in the Cc: listpublic void setBcc(Address[] bcclist)
bcclist
- list of Adresses to put in the bcclistpublic void setReplyTo(Address[] replytolist)
replytolist
- list of Adresses to put in the bcclistpublic void setSubject(java.lang.String subject)
subject
- The text to put in the Subjectpublic Folder getParent()
public void setParent(Folder parent)
Folder
this Message
is contained in
parent
- The folder this Message
is a child ofpublic void setSentDate(java.util.Date sent)
sent
- the sent datepublic void setReceivedDate(java.util.Date received)
received
- the received datepublic java.lang.Object getContent()
getContent
in class Part
public java.lang.String getTextContent()
public void setContent(java.lang.Object content) throws MailException
setContent
in class Part
MailException
public void setContent(java.lang.Object content, java.lang.String type) throws MailException
setContent
in class Part
content
- The content objecttype
- The MIME type of the content
MailException
public void setMessageId(java.lang.String messageId)
public void serialize(java.io.DataOutputStream dout) throws java.io.IOException
serialize
in interface com.funambol.storage.Serializable
java.io.IOException
public void deserialize(java.io.DataInputStream din) throws java.io.IOException
deserialize
in interface com.funambol.storage.Serializable
java.io.IOException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |