gnu.mail.providers.imap

Class IMAPMessage

Implemented Interfaces:
MimePart, Part

public final class IMAPMessage
extends gnu.mail.providers.ReadOnlyMessage

The message class implementing the IMAP4 mail protocol.

Nested Class Summary

Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage

MimeMessage.RecipientType

Nested classes/interfaces inherited from class javax.mail.Message

Message.RecipientType

Field Summary

protected boolean
headersComplete
If set, the current set of headers is complete.
protected String
internalDate
If set, this contains the string value of the received date.
protected static DateFormat
internalDateFormat
The date format used to parse IMAP INTERNALDATE values.
protected long
uid
The UID associated with this message.

Fields inherited from class javax.mail.internet.MimeMessage

content, contentStream, dh, flags, headers, modified, saved

Fields inherited from class javax.mail.Message

expunged, folder, msgnum, session

Fields inherited from interface javax.mail.Part

ATTACHMENT, INLINE

Method Summary

Enumeration
getAllHeaderLines()
Get all header lines as an Enumeration of Strings.
Enumeration
getAllHeaders()
Return all the headers from this Message as an enumeration of Header objects.
Object
getContent()
Return the content as a Java object.
protected InputStream
getContentStream()
Returns the raw content stream.
DataHandler
getDataHandler()
Returns a data handler for this message's content.
Flags
getFlags()
Return a Flags object containing the flags for this message.
String[]
getHeader(String name)
Returns the specified header field.
String
getHeader(String name, String delimiter)
Returns the specified header field.
Enumeration
getMatchingHeaderLines(String[] names)
Get matching header lines as an Enumeration of Strings.
Enumeration
getMatchingHeaders(String[] names)
Return matching headers from this Message as an Enumeration of Header objects.
Enumeration
getNonMatchingHeaderLines(String[] names)
Get non-matching header lines as an Enumeration of Strings.
Enumeration
getNonMatchingHeaders(String[] names)
Return non-matching headers from this Message as an Enumeration of Header objects.
Date
getReceivedDate()
Returns the date on which this message was received.
boolean
isSet(Flags.Flag flag)
Check whether the flag specified in the flag argument is set in this message.
void
setFlags(Flags flag, boolean set)
Set the specified flags.
void
writeTo(OutputStream msgStream)
Output the message as an RFC 822 format stream.
void
writeTo(OutputStream msgStream, String[] ignoreList)
Output the message as an RFC 822 format stream, without specified headers.

Methods inherited from class gnu.mail.providers.ReadOnlyMessage

addHeader, addHeaderLine, removeHeader, saveChanges, setContent, setContent, setFlags, setHeader

Methods inherited from class javax.mail.internet.MimeMessage

addFrom, addHeader, addHeaderLine, addRecipients, addRecipients, createInternetHeaders, getAllHeaderLines, getAllHeaders, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFlags, getFrom, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getMessageID, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getReceivedDate, getRecipients, getReplyTo, getSender, getSentDate, getSize, getSubject, isMimeType, isSet, parse, removeHeader, reply, saveChanges, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFlags, setFrom, setFrom, setHeader, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, updateHeaders, writeTo, writeTo

Methods inherited from class javax.mail.Message

addFrom, addRecipient, addRecipients, getAllRecipients, getFlags, getFolder, getFrom, getMessageNumber, getReceivedDate, getRecipients, getReplyTo, getSentDate, getSubject, isExpunged, isSet, match, reply, saveChanges, setExpunged, setFlag, setFlags, setFrom, setFrom, setMessageNumber, setRecipient, setRecipients, setReplyTo, setSentDate, setSubject

Field Details

headersComplete

protected boolean headersComplete
If set, the current set of headers is complete. If false, and a header is requested but returns null, all headers will be requested from the server.


internalDate

protected String internalDate
If set, this contains the string value of the received date.


internalDateFormat

protected static final DateFormat internalDateFormat
The date format used to parse IMAP INTERNALDATE values.


uid

protected long uid
The UID associated with this message.

Method Details

getAllHeaderLines

public Enumeration getAllHeaderLines()
            throws MessagingException
Get all header lines as an Enumeration of Strings. A Header line is a raw RFC 822 header-line, containing both the "name" and "value" field.
Specified by:
getAllHeaderLines in interface MimePart
Overrides:
getAllHeaderLines in interface MimeMessage


getAllHeaders

public Enumeration getAllHeaders()
            throws MessagingException
Return all the headers from this Message as an enumeration of Header objects.

Note that certain headers may be encoded as per RFC 2047 if they contain non US-ASCII characters and these should be decoded.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getAllHeaders in interface Part
Overrides:
getAllHeaders in interface MimeMessage

Returns:
array of header objects


getContent

public Object getContent()
            throws MessagingException,
                   IOException
Return the content as a Java object. The type of this object is dependent on the content itself. For example, the native format of a "text/plain" content is usually a String object. The native format for a "multipart" message is always a Multipart subclass. For content types that are unknown to the DataHandler system, an input stream is returned as the content.

This implementation obtains the content from the DataHandler, that is, it invokes getDataHandler().getContent().

Specified by:
getContent in interface Part
Overrides:
getContent in interface MimeMessage


getContentStream

protected InputStream getContentStream()
            throws MessagingException
Returns the raw content stream.
Overrides:
getContentStream in interface MimeMessage


getDataHandler

public DataHandler getDataHandler()
            throws MessagingException
Returns a data handler for this message's content.
Specified by:
getDataHandler in interface Part
Overrides:
getDataHandler in interface MimeMessage


getFlags

public Flags getFlags()
            throws MessagingException
Return a Flags object containing the flags for this message.

Note that a clone of the internal Flags object is returned, so modifying the returned Flags object will not affect the flags of this message.

Overrides:
getFlags in interface MimeMessage

Returns:
Flags object containing the flags for this message


getHeader

public String[] getHeader(String name)
            throws MessagingException
Returns the specified header field.
Specified by:
getHeader in interface Part
Overrides:
getHeader in interface MimeMessage


getHeader

public String getHeader(String name,
                        String delimiter)
            throws MessagingException
Returns the specified header field.
Specified by:
getHeader in interface MimePart
Overrides:
getHeader in interface MimeMessage


getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)
            throws MessagingException
Get matching header lines as an Enumeration of Strings. A Header line is a raw RFC 822 header-line, containing both the "name" and "value" field.
Specified by:
getMatchingHeaderLines in interface MimePart
Overrides:
getMatchingHeaderLines in interface MimeMessage


getMatchingHeaders

public Enumeration getMatchingHeaders(String[] names)
            throws MessagingException
Return matching headers from this Message as an Enumeration of Header objects.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getMatchingHeaders in interface Part
Overrides:
getMatchingHeaders in interface MimeMessage


getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)
            throws MessagingException
Get non-matching header lines as an Enumeration of Strings. A Header line is a raw RFC 822 header-line, containing both the "name" and "value" field.
Specified by:
getNonMatchingHeaderLines in interface MimePart
Overrides:
getNonMatchingHeaderLines in interface MimeMessage


getNonMatchingHeaders

public Enumeration getNonMatchingHeaders(String[] names)
            throws MessagingException
Return non-matching headers from this Message as an Enumeration of Header objects.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getNonMatchingHeaders in interface Part
Overrides:
getNonMatchingHeaders in interface MimeMessage


getReceivedDate

public Date getReceivedDate()
            throws MessagingException
Returns the date on which this message was received.
Overrides:
getReceivedDate in interface MimeMessage


isSet

public boolean isSet(Flags.Flag flag)
            throws MessagingException
Check whether the flag specified in the flag argument is set in this message.

This implementation checks this message's internal flags object.

Overrides:
isSet in interface MimeMessage

Parameters:
flag - - the flag

Returns:
value of the specified flag for this message


setFlags

public void setFlags(Flags flag,
                     boolean set)
            throws MessagingException
Set the specified flags.
Overrides:
setFlags in interface gnu.mail.providers.ReadOnlyMessage


writeTo

public void writeTo(OutputStream msgStream)
            throws IOException,
                   MessagingException
Output the message as an RFC 822 format stream.

Note that, depending on how the message was constructed, it may use a variety of line termination conventions. Generally the output should be sent through an appropriate FilterOutputStream that converts the line terminators to the desired form, either CRLF for MIME compatibility and for use in Internet protocols, or the local platform's line terminator for storage in a local text file.

This implementation calls the writeTo(OutputStream, String[]) method with a null ignore list.

Specified by:
writeTo in interface Part
Overrides:
writeTo in interface MimeMessage


writeTo

public void writeTo(OutputStream msgStream,
                    String[] ignoreList)
            throws IOException,
                   MessagingException
Output the message as an RFC 822 format stream, without specified headers. If the saved flag is not set, the saveChanges method is called. If the modified flag is not set and the content array is not null, the content array is written directly, after writing the appropriate message headers.
Overrides:
writeTo in interface MimeMessage