Top Description Inners Fields Constructors Methods
com.sun.mail.imap

public Class IMAPMessage

extends MimeMessage
implements ReadableMime
Class Inheritance
All Implemented Interfaces
com.sun.mail.util.ReadableMime
Known Direct Subclasses
com.sun.mail.imap.IMAPNestedMessage
Imports
java.util.Date, java.util.*, java.io.*, javax.mail.*, javax.mail.internet.*, javax.activation.*, com.sun.mail.util.ReadableMime, com.sun.mail.iap.*, com.sun.mail.imap.protocol.*

This class implements an IMAPMessage object.

An IMAPMessage object starts out as a light-weight object. It gets filled-in incrementally when a request is made for some item. Or when a prefetch is done using the FetchProfile.

An IMAPMessage has a messageNumber and a sequenceNumber. The messageNumber is its index into its containing folder's messageCache. The sequenceNumber is its IMAP sequence-number.

Authors
John Mani, Bill Shannon

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
IMAPMessage.FetchProfileCondition

This class implements the test to be done on each message in the folder.

Field Summary

Modifier and TypeField and Description
private volatile boolean
protected BODYSTRUCTURE
private String
protected ENVELOPE
pack-priv static final String
private volatile boolean
protected Map<String, Object>
items

A map of the extension FETCH items.

private Hashtable<String, String>
private volatile long
private Boolean
private Date
protected String
private long
private String
private String
private volatile long
Inherited from javax.mail.internet.MimeMessage:
cachedContentcontentcontentStreamdhflagsheadersmodifiedsaved

Constructor Summary

AccessConstructor and Description
protected
IMAPMessage(IMAPFolder
the folder containing this message
folder
,
int
the message sequence number
msgnum
)

Constructor.

protected
IMAPMessage(Session
the Session
session
)

Constructor, for use by IMAPNestedMessage.

Method Summary

Modifier and TypeMethod and Description
private BODYSTRUCTURE
private ENVELOPE
private Flags
pack-priv long
pack-priv Session
pack-priv void
_setFlags(Flags flags)

accessor routines to make available certain private/protected fields to other classes in this package.

private InternetAddress[]
public void
addFrom(Address[]
the senders of this message
addresses
)

Overrides javax.mail.internet.MimeMessage.addFrom.

Add the specified addresses to the existing "From" field.
public void
addHeader(String
header name
name
,
String
header value
value
)

Overrides javax.mail.internet.MimeMessage.addHeader.

Implements javax.mail.Part.addHeader.

Add this value to the existing values for this header_name.
public void
addHeaderLine(String
the line to add
line
)

Overrides javax.mail.internet.MimeMessage.addHeaderLine.

Implements javax.mail.internet.MimePart.addHeaderLine.

Add a raw RFC 822 header-line.
public void
addRecipients(Message.RecipientType
Recipient type
type
,
Address[]
Addresses
addresses
)

Overrides javax.mail.internet.MimeMessage.addRecipients.

Add the given addresses to the specified recipient type.
private boolean
protected void
protected Object

Returns:

the data associated with the FetchItem
fetchItem
(FetchItem
the FetchItem
fitem
)

Fetch an individual item for the current message.

protected void
forceCheckExpunged()

Do a NOOP to force any untagged EXPUNGE responses and then check if this message is expunged.

public Enumeration<String>
public Enumeration<Header>
public String
public String[]
public String
protected InputStream
getContentStream()

Overrides javax.mail.internet.MimeMessage.getContentStream.

Get all the bytes for this message.
public synchronized String
public synchronized DataHandler
getDataHandler()

Overrides javax.mail.internet.MimeMessage.getDataHandler.

Implements javax.mail.Part.getDataHandler.

Get the DataHandler object for this message.
public String
getDescription()

Overrides javax.mail.internet.MimeMessage.getDescription.

Implements javax.mail.Part.getDescription.

Get the decoded Content-Description.
public String
public String
protected int
public String
getFileName()

Overrides javax.mail.internet.MimeMessage.getFileName.

Implements javax.mail.Part.getFileName.

Get the "filename" Disposition parameter.
public synchronized Flags
getFlags()

Overrides javax.mail.internet.MimeMessage.getFlags.

Get the Flags for this message.
public Address[]
getFrom()

Overrides javax.mail.internet.MimeMessage.getFrom.

Get the "From" attribute.
public String[]
getHeader(String
name of header
name
)

Overrides javax.mail.internet.MimeMessage.getHeader.

Implements javax.mail.Part.getHeader.

Get the named header.
public String
getHeader(String
the name of this header
name
,
String
separator between values
delimiter
)

Overrides javax.mail.internet.MimeMessage.getHeader.

Implements javax.mail.internet.MimePart.getHeader.

Get the named header.
public String

Returns:

the In-Reply-To header
getInReplyTo
()

Get the In-Reply-To header.

public synchronized Object

Returns:

the data associated with the FetchItem
getItem
(FetchItem
the FetchItem
fitem
)

Return the data associated with the FetchItem.

public int
getLineCount()

Overrides javax.mail.internet.MimeMessage.getLineCount.

Implements javax.mail.Part.getLineCount.

Get the total number of lines.
public Enumeration<String>
public Enumeration<Header>
getMatchingHeaders(String[]
the headers to match
names
)

Overrides javax.mail.internet.MimeMessage.getMatchingHeaders.

Implements javax.mail.Part.getMatchingHeaders.

Get matching headers.
protected Object

Returns:

the message cache lock object
getMessageCacheLock
()

Get the messageCacheLock, associated with this Message's Folder.

public String
public InputStream

Returns:

the MIME format stream
getMimeStream
()

Implements com.sun.mail.util.ReadableMime.getMimeStream.

Return the MIME format stream corresponding to this message.
public synchronized long

Returns:

the modification sequence number
getModSeq
()

Return the modification sequence number (MODSEQ) for this message.

public Enumeration<String>
public Enumeration<Header>
getNonMatchingHeaders(String[]
the headers to not match
names
)

Overrides javax.mail.internet.MimeMessage.getNonMatchingHeaders.

Implements javax.mail.Part.getNonMatchingHeaders.

Get non-matching headers.
public synchronized boolean

Returns:

the peek flag
getPeek
()

Get whether or not to use the PEEK variant of FETCH when fetching message content.

protected IMAPProtocol

Returns:

the IMAPProtocol object for the containing folder
getProtocol
()

Get this message's folder's protocol connection.

public Date
getReceivedDate()

Overrides javax.mail.internet.MimeMessage.getReceivedDate.

Get the received date (INTERNALDATE).
public Address[]
getRecipients(Message.RecipientType
Type of recepient
type
)

Overrides javax.mail.internet.MimeMessage.getRecipients.

Get the desired Recipient type.
public Address[]
getReplyTo()

Overrides javax.mail.internet.MimeMessage.getReplyTo.

Get the ReplyTo addresses.
public Address
getSender()

Overrides javax.mail.internet.MimeMessage.getSender.

Get the "Sender" attribute.
public Date
protected int

Returns:

the message sequence number
getSequenceNumber
()

Get this message's IMAP sequence number.

public int
getSize()

Overrides javax.mail.internet.MimeMessage.getSize.

Implements javax.mail.Part.getSize.

Get the message size.
public long

Returns:

the message size as a long integer
getSizeLong
()

Get the message size as a long.

public String
getSubject()

Overrides javax.mail.internet.MimeMessage.getSubject.

Get the decoded subject.
protected long

Returns:

the UID
getUID
()

Return the UID for this message.

protected void
handleExtensionFetchItems(Map<String, Object>
the Map to add fetch items to
extensionItems
)

Apply the data in the extension FETCH items to this message.

protected boolean

Returns:

did we handle this fetch item?
handleFetchItem
(Item
the fetch item
item
,
String[]
the headers we're asking for
hdrs
,
boolean
load all headers?
allHeaders
)

Apply the data in the FETCH item to this message.

protected boolean
public synchronized void
invalidateHeaders()

Invalidate cached header and envelope information for this message.

private boolean
protected boolean
public synchronized boolean
isSet(Flags.Flag
the flag
flag
)

Overrides javax.mail.internet.MimeMessage.isSet.

Test if the given Flags are set in this message.
private synchronized void
private synchronized void
private synchronized void
private synchronized void
public void
removeHeader(String
the name of this header
name
)

Overrides javax.mail.internet.MimeMessage.removeHeader.

Implements javax.mail.Part.removeHeader.

Remove all headers with this name.
public void
setContentID(String
the content ID
cid
)

Overrides javax.mail.internet.MimeMessage.setContentID.

Set the "Content-ID" header field of this Message.
public void
setContentLanguage(String[]
array of language tags
languages
)

Overrides javax.mail.internet.MimeMessage.setContentLanguage.

Implements javax.mail.internet.MimePart.setContentLanguage.

Set the "Content-Language" header of this MimePart.
public void
setContentMD5(String
the MD5 value
md5
)

Overrides javax.mail.internet.MimeMessage.setContentMD5.

Implements javax.mail.internet.MimePart.setContentMD5.

Set the "Content-MD5" header field of this Message.
public void
setDataHandler(DataHandler
The DataHandler for the content.
content
)

Overrides javax.mail.internet.MimeMessage.setDataHandler.

Implements javax.mail.Part.setDataHandler.

This method provides the mechanism to set this part's content.
public void
setDescription(String
Description
description
,
String
Charset for encoding
charset
)

Overrides javax.mail.internet.MimeMessage.setDescription.

Set the "Content-Description" header field for this Message.
public void
setDisposition(String
disposition of this part
disposition
)

Overrides javax.mail.internet.MimeMessage.setDisposition.

Implements javax.mail.Part.setDisposition.

Set the disposition in the "Content-Disposition" header field of this body part.
protected void
setExpunged(boolean
the expunged flag
set
)

Overrides javax.mail.Message.setExpunged.

Sets the expunged flag for this Message.
public void
setFileName(String
Filename to associate with this part
filename
)

Overrides javax.mail.internet.MimeMessage.setFileName.

Implements javax.mail.Part.setFileName.

Set the filename associated with this part, if possible.
public synchronized void
setFlags(Flags
Flags object containing the flags to be set
flag
,
boolean
the value to be set
set
)

Overrides javax.mail.internet.MimeMessage.setFlags.

Set/Unset the given flags in this message.
public void
setFrom(Address
the sender of this message
address
)

Overrides javax.mail.internet.MimeMessage.setFrom.

Set the RFC 822 "From" header field.
public void
setHeader(String
header name
name
,
String
header value
value
)

Overrides javax.mail.internet.MimeMessage.setHeader.

Implements javax.mail.Part.setHeader.

Set the value for this header_name.
private void
private void
setHeadersLoaded(boolean loaded)

protected void
setMessageNumber(int
the message number
msgnum
)

Overrides javax.mail.Message.setMessageNumber.

Wrapper around the protected method Message.setMessageNumber() to make that method accessible to IMAPFolder.
pack-priv void
setModSeq(long modseq)

public synchronized void
setPeek(boolean
the peek flag
peek
)

Set whether or not to use the PEEK variant of FETCH when fetching message content.

public void
setRecipients(Message.RecipientType
Recipient type
type
,
Address[]
Addresses
addresses
)

Overrides javax.mail.internet.MimeMessage.setRecipients.

Set the specified recipient type to the given addresses.
public void
setReplyTo(Address[]
addresses to which replies should be directed
addresses
)

Overrides javax.mail.internet.MimeMessage.setReplyTo.

Set the RFC 822 "Reply-To" header field.
public void
setSender(Address
the sender of this message
address
)

Overrides javax.mail.internet.MimeMessage.setSender.

Set the RFC 822 "Sender" header field.
public void
setSentDate(Date
the sent date of this message
d
)

Overrides javax.mail.internet.MimeMessage.setSentDate.

Set the RFC 822 "Date" header field.
public void
setSubject(String
The subject
subject
,
String
The charset
charset
)

Overrides javax.mail.internet.MimeMessage.setSubject.

Set the "Subject" header field.
protected void
setUID(long uid)

private String
public void
writeTo(OutputStream
the stream to write to
os
)

Overrides javax.mail.internet.MimeMessage.writeTo.

Implements javax.mail.Part.writeTo.

Write out the bytes into the given OutputStream.
Inherited from javax.mail.internet.MimeMessage:
addRecipientscreateInternetHeaderscreateMimeMessagegetAllRecipientsgetContentgetInputStreamgetRawInputStreamisMimeTypeparsereplyreplysaveChangessetContentsetContentsetDescriptionsetFromsetFromsetRecipientssetSubjectsetTextsetTextsetTextupdateHeadersupdateMessageIDwriteTo