Java Reference
In-Depth Information
Subject: CPreProcessorStream
Sent: Sun Dec 13 07:14:00 PST 2009
Received: Sun Dec 13 07:08:00 PST 2009
Answered
Read
Folders
Messages received from the network (as opposed to sent to the network) generally be‐
long to some
Folder
. The
getFolder()
method returns a reference to the
Folder
object
that contains this
Message
:
public
Folder
getFolder
()
It returns
null
if the message isn't contained in a folder.
Within a folder, messages are organized from first (message 1) to last. The
getMessage
Number()
method returns the relative position of this
Message
in its
Folder
:
public int getMessageNumber()
Messages that aren't in any folder have number 0.
One of the things you can do with a folder is expunge messages from it. This physically
deletes the message if it's already been marked as deleted. (A merely deleted message
can be “undeleted”, whereas an expunged message cannot be.) If a message is expunged,
there may still be a
Message
object pointing to the message, but almost all methods on
the message will throw a
MessagingException
. Thus, it may be important to check
whether a message has been expunged before working with it. The
isExpunged()
method does that:
public
boolean
isExpunged
()
Searching
The final method left in the
Message
class is
match()
. The
match()
method determines
whether a
Message
satisfies particular search criteria. We'll discuss this more in a bit
when we talk about searching folders:
public
boolean
match
(
SearchTerm
term
)
throws
MessagingException
The Part Interface
Both
Message
and
BodyPart
implement the
Part
interface. Every
Message
is a
Part
.
However, some parts may contain other parts. The
Part
interface declares three kinds
of methods:
• Methods for getting and setting the attributes of the part