Messages obtained from a Folder are light-weight objects that
typically start off as empty references to the actual messages.
Such a Message object is filled in "on-demand" when the appropriate
get*() methods are invoked on that particular Message. Certain
server-based message access protocols (Ex: IMAP) allow batch
fetching of message attributes for a range of messages in a single
request. Clients that want to use message attributes for a range of
Messages (Example: to display the top-level headers in a headerlist)
might want to use the optimization provided by such servers. The
FetchProfile allows the client to indicate this desire
to the server.
Note that implementations are not obligated to support FetchProfiles, since there might be cases where the backend service does not allow easy, efficient fetching of such profiles.
Sample code that illustrates the use of a FetchProfile is given below:
Message[] msgs = folder.getMessages();
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add("X-mailer");
folder.fetch(msgs, fp);
javax.mail.Folder#fetch
| Modifier and Type | Class and Description |
|---|---|
| public static class | FetchProfile.Item
This inner class is the base class of all items that can be requested in a FetchProfile. |
| Modifier and Type | Field and Description |
|---|---|
| private Vector | |
| private Vector |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(FetchProfile.
the special item to be fetched itemAdd the given special item as one of the attributes to be prefetched. |
| public void | |
| public boolean | Returns: true if the fetch profile contains the given special itemthe Item to test itemReturns true if the fetch profile contains the given special item. |
| public boolean | |
| public String[] | Returns: headers set in this profileGet the names of the header-fields set in this profile. |
| public FetchProfile. |
| headers | back to summary |
|---|---|
| private Vector<String> headers | |
| specials | back to summary |
|---|---|
| private Vector<FetchProfile. | |
| FetchProfile | back to summary |
|---|---|
| public FetchProfile() Create an empty FetchProfile. | |
| add | back to summary |
|---|---|
| public void add(FetchProfile. Add the given special item as one of the attributes to be prefetched.
| |
| add | back to summary |
|---|---|
| public void add(String headerName) Add the specified header-field to the list of attributes to be prefetched.
| |
| contains | back to summary |
|---|---|
| public boolean contains(FetchProfile. Returns true if the fetch profile contains the given special item.
| |
| contains | back to summary |
|---|---|
| public boolean contains(String headerName) Returns true if the fetch profile contains the given header name.
| |
| getHeaderNames | back to summary |
|---|---|
| public String[] getHeaderNames() Get the names of the header-fields set in this profile.
| |
| getItems | back to summary |
|---|---|
| public FetchProfile. Get the items set in this profile.
| |
ENVELOPE, CONTENT_INFO
and FLAGS. The UIDFolder interface
defines the UID Item as well. Note that this class only has a protected constructor, therby restricting new Item types to either this class or subclasses. This effectively implements a enumeration of allowed Item types.
UIDFolder
| Modifier and Type | Field and Description |
|---|---|
| public static final FetchProfile. | CONTENT_INFO
This item is for fetching information about the content of the message. |
| public static final FetchProfile. | ENVELOPE
This is the Envelope item. |
| public static final FetchProfile. | FLAGS
This is the Flags item. |
| private String | |
| public static final FetchProfile. | SIZE
SIZE is a fetch profile item that can be included in a
|
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public String | toString()
Overrides java. |
| CONTENT_INFO | back to summary |
|---|---|
| public static final FetchProfile. This item is for fetching information about the content of the message. This includes all the attributes that describe the content of the message. Implementations should include the following attributes: ContentType, ContentDisposition, ContentDescription, Size and LineCount. Other items may be included as well. | |
| ENVELOPE | back to summary |
|---|---|
| public static final FetchProfile. This is the Envelope item. The Envelope is an aggregration of the common attributes of a Message. Implementations should include the following attributes: From, To, Cc, Bcc, ReplyTo, Subject and Date. More items may be included as well. For implementations of the IMAP4 protocol (RFC 2060), the Envelope should include the ENVELOPE data item. More items may be included too. | |
| FLAGS | back to summary |
|---|---|
| public static final FetchProfile. This is the Flags item. | |
| name | back to summary |
|---|---|
| private String name | |
| SIZE | back to summary |
|---|---|
| public static final FetchProfile. SIZE is a fetch profile item that can be included in a
| |
| Item | back to summary |
|---|---|
| protected Item(String name) Constructor for an item. The name is used only for debugging.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Include the name in the toString return value for debugging.
| |