FetchProfile (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail Class FetchProfile

java.lang.Object
  extended by javax.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);

 

作者:
John Mani, Bill Shannon
另请参见:
Folder.fetch(javax.mail.Message[], javax.mail.FetchProfile)

嵌套类摘要
static class FetchProfile.Item
          This inner class is the base class of all items that can be requested in a FetchProfile.
 
构造器摘要
FetchProfile()
          Create an empty FetchProfile.
 
方法摘要
 void add(FetchProfile.Item item)
          Add the given special item as one of the attributes to be prefetched.
 void add(String headerName)
          Add the specified header-field to the list of attributes to be prefetched.
 boolean contains(FetchProfile.Item item)
          Returns true if the fetch profile contains given special item.
 boolean contains(String headerName)
          Returns true if the fetch profile contains given header name.
 String[] getHeaderNames()
          Get the names of the header-fields set in this profile.
 FetchProfile.Item[] getItems()
          Get the items set in this profile.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造器详细信息

FetchProfile

public FetchProfile()
Create an empty FetchProfile.

方法详细信息

add

public void add(FetchProfile.Item item)
Add the given special item as one of the attributes to be prefetched.

参数:
item - the special item to be fetched
另请参见:
FetchProfile.Item.ENVELOPE, FetchProfile.Item.CONTENT_INFO, FetchProfile.Item.FLAGS

add

public void add(String headerName)
Add the specified header-field to the list of attributes to be prefetched.

参数:
headerName - header to be prefetched

contains

public boolean contains(FetchProfile.Item item)
Returns true if the fetch profile contains given special item.


contains

public boolean contains(String headerName)
Returns true if the fetch profile contains given header name.


getItems

public FetchProfile.Item[] getItems()
Get the items set in this profile.

返回:
items set in this profile

getHeaderNames

public String[] getHeaderNames()
Get the names of the header-fields set in this profile.

返回:
headers set in this profile

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.