FileDocCategorySizeDatePackage
FetchProfile.javaAPI DocGlassfish v2 API7202Mon May 14 15:28:46 BST 2007javax.mail

FetchProfile

public class FetchProfile extends Object
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);

see
javax.mail.Folder#fetch
author
John Mani
author
Bill Shannon

Fields Summary
private Vector
specials
private Vector
headers
Constructors Summary
public FetchProfile()
Create an empty FetchProfile.

 
	specials = null;
	headers = null;
    
Methods Summary
public voidadd(javax.mail.FetchProfile$Item item)
Add the given special item as one of the attributes to be prefetched.

param
item the special item to be fetched
see
FetchProfile.Item#ENVELOPE
see
FetchProfile.Item#CONTENT_INFO
see
FetchProfile.Item#FLAGS

 
	if (specials == null)
	    specials = new Vector();
	specials.addElement(item);
    
public voidadd(java.lang.String headerName)
Add the specified header-field to the list of attributes to be prefetched.

param
headerName header to be prefetched

 
   	if (headers == null)
	    headers = new Vector();
	headers.addElement(headerName);
    
public booleancontains(javax.mail.FetchProfile$Item item)
Returns true if the fetch profile contains given special item.

 
   	return specials != null && specials.contains(item);
    
public booleancontains(java.lang.String headerName)
Returns true if the fetch profile contains given header name.

 
   	return headers != null && headers.contains(headerName);
    
public java.lang.String[]getHeaderNames()
Get the names of the header-fields set in this profile.

return
headers set in this profile

 
	if (headers == null)
	    return new String[0];

   	String[] s = new String[headers.size()];
	headers.copyInto(s);
	return s;
    
public javax.mail.FetchProfile$Item[]getItems()
Get the items set in this profile.

return
items set in this profile

 
	if (specials == null)
	    return new Item[0];

   	Item[] s = new Item[specials.size()];
	specials.copyInto(s);
	return s;