Top Description Inners Fields Constructors Methods
javax.mail

public Class FetchProfile

extends Object
Class Inheritance
Imports
java.util.Vector

Clients use a FetchProfile to list the Message attributes that it wishes to prefetch from the server for a range of messages.

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);

Authors
John Mani, Bill Shannon
See Also
javax.mail.Folder#fetch

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FetchProfile.Item

This inner class is the base class of all items that can be requested in a FetchProfile.

Field Summary

Modifier and TypeField and Description
private Vector<String>
private Vector<FetchProfile.Item>

Constructor Summary

AccessConstructor and Description
public
FetchProfile()

Create an empty FetchProfile.

Method Summary

Modifier and TypeMethod and Description
public void
add(FetchProfile.Item
the special item to be fetched
item
)

Add the given special item as one of the attributes to be prefetched.

public void
add(String
header to be prefetched
headerName
)

Add the specified header-field to the list of attributes to be prefetched.

public boolean

Returns:

true if the fetch profile contains the given special item
contains
(FetchProfile.Item
the Item to test
item
)

Returns true if the fetch profile contains the given special item.

public boolean

Returns:

true if the fetch profile contains the given header name
contains
(String
the header to test
headerName
)

Returns true if the fetch profile contains the given header name.

public String[]

Returns:

headers set in this profile
getHeaderNames
()

Get the names of the header-fields set in this profile.

public FetchProfile.Item[]

Returns:

items set in this profile
getItems
()

Get the items set in this profile.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersback to summary
private Vector<String> headers
specialsback to summary
private Vector<FetchProfile.Item> specials

Constructor Detail

FetchProfileback to summary
public FetchProfile()

Create an empty FetchProfile.

Method Detail

addback to summary
public void add(FetchProfile.Item item)

Add the given special item as one of the attributes to be prefetched.

Parameters
item:FetchProfile.Item

the special item to be fetched

See Also
FetchProfile.Item#ENVELOPE, FetchProfile.Item#CONTENT_INFO, FetchProfile.Item#FLAGS
addback to summary
public void add(String headerName)

Add the specified header-field to the list of attributes to be prefetched.

Parameters
headerName:String

header to be prefetched

containsback to summary
public boolean contains(FetchProfile.Item item)

Returns true if the fetch profile contains the given special item.

Parameters
item:FetchProfile.Item

the Item to test

Returns:boolean

true if the fetch profile contains the given special item

containsback to summary
public boolean contains(String headerName)

Returns true if the fetch profile contains the given header name.

Parameters
headerName:String

the header to test

Returns:boolean

true if the fetch profile contains the given header name

getHeaderNamesback to summary
public String[] getHeaderNames()

Get the names of the header-fields set in this profile.

Returns:String[]

headers set in this profile

getItemsback to summary
public FetchProfile.Item[] getItems()

Get the items set in this profile.

Returns:FetchProfile.Item[]

items set in this profile

javax.mail back to summary

public Class FetchProfile.Item

extends Object
Class Inheritance
Known Direct Subclasses
javax.mail.UIDFolder.FetchProfileItem

This inner class is the base class of all items that can be requested in a FetchProfile. The items currently defined here are 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.

See Also
UIDFolder

Field Summary

Modifier and TypeField and Description
public static final FetchProfile.Item
CONTENT_INFO

This item is for fetching information about the content of the message.

public static final FetchProfile.Item
ENVELOPE

This is the Envelope item.

public static final FetchProfile.Item
FLAGS

This is the Flags item.

private String
public static final FetchProfile.Item
SIZE

SIZE is a fetch profile item that can be included in a FetchProfile during a fetch request to a Folder.

Constructor Summary

AccessConstructor and Description
protected
Item(String
the item name
name
)

Constructor for an item.

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Include the name in the toString return value for debugging.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CONTENT_INFOback to summary
public static final FetchProfile.Item CONTENT_INFO

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.

ENVELOPEback to summary
public static final FetchProfile.Item ENVELOPE

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.

FLAGSback to summary
public static final FetchProfile.Item FLAGS

This is the Flags item.

nameback to summary
private String name
SIZEback to summary
public static final FetchProfile.Item SIZE

SIZE is a fetch profile item that can be included in a FetchProfile during a fetch request to a Folder. This item indicates that the sizes of the messages in the specified range should be prefetched.

Since
JavaMail 1.5

Constructor Detail

Itemback to summary
protected Item(String name)

Constructor for an item. The name is used only for debugging.

Parameters
name:String

the item name

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Include the name in the toString return value for debugging.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override