FetchProfile (Java EE 5)

Java EE API


javax.mail Class FetchProfile

java.lang.Object
  extended by javax.mail.FetchProfile

public class FetchProfile
extends Object

Inner classes: FetchProfile.Item

客户端使用 FetchProfile 列出希望从服务器预获取的某一范围消息的 Message 属性。

从 Folder 获得的消息是轻量级对象,这些对象开始通常作为对实际消息的空引用。当对该特定 Message 调用适当的 get*() 方法时,才“按需”填充这样的 Message 对象。某些基于服务器的消息访问协议 (Ex:IMAP) 允许在单个请求中批量获取某一范围消息的消息属性。想要使用某一范围 Message 的消息属性的客户端(例如,要显示头列表中顶级头的客户端)可能需要使用这类服务器提供的优化。FetchProfile 允许客户端向服务器指示此需求。

注意,实现并不一定会支持 FetchProfile,因为可能存在后端服务不允许简单有效地获取这类配置文件的情况。

说明 FetchProfile 用法的示例代码如下所示:

Message[] msgs = folder.getMessages();

FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add("X-mailer");
folder.fetch(msgs, fp);

 

英文文档:

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

 

Author:
John Mani, Bill Shannon
See Also:
Folder.fetch(javax.mail.Message[], javax.mail.FetchProfile)

Nested Class Summary
static class
 
Constructor Summary
 
Method Summary
 void
 void
 boolean
 boolean
 String[]
 FetchProfile.Item[]
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public FetchProfile()
创建一个空 FetchProfile。
英文文档:

FetchProfile

public FetchProfile()
Create an empty FetchProfile.

Method Detail

public void add(FetchProfile.Item item)
将给定特殊项作为要预获取的属性之一添加。
item 要获取的特殊项
See also ENVELOPE, CONTENT_INFO, FLAGS
英文文档:

add

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

Parameters:
item - the special item to be fetched
See Also:
FetchProfile.Item.ENVELOPE, FetchProfile.Item.CONTENT_INFO, FetchProfile.Item.FLAGS

public void add(String headerName)
将指定头字段添加到要预获取的属性的列表中。
headerName 要预获取的头
英文文档:

add

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

Parameters:
headerName - header to be prefetched

public boolean contains(FetchProfile.Item item)
如果 fetch 配置文件包含给定特殊项,则返回 true。
英文文档:

contains

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


public boolean contains(String headerName)
如果 fetch 配置文件包含给定头名称,则返回 true。
英文文档:

contains

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


public FetchProfile.Item[] getItems()
获取此配置文件中设置的项。
return 此配置文件中设置的项
英文文档:

getItems

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

Returns:
items set in this profile

public String[] getHeaderNames()
获取此配置文件中设置的头字段的名称。
return 此配置文件中设置的头
英文文档:

getHeaderNames

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

Returns:
headers set in this profile


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!