快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

和记娱乐怡情怎么样_机器人论坛



上篇文章我写的是关于若何用JavaMail来实现对邮件的查找,在这篇文章中我们继承探究若何用JavaMail来和记娱乐怡情怎么样实现邮件查找,这篇文章的重点是若何经由过程扩展JavaMail来实现自定义的邮件查找器

下面我将经由过程两个例子来阐明假如扩展JavaMail的javax.mail.search中的类:

例子一:

经由过程扩展SearchTerm来实现自己的根据附件来查找邮件的JAttachTerm,下面是本法度榜样的

源代码:

//|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

/*

* Created on 2005-1-30

*

* TODO To change the template for this generated file go to

* Window - Preferences - Java - Code Style - Code Templates

*/

package webmail.mail.search;

import javax.mail.Message;

import javax.mail.internet.MimeMessage;

import javax.mail.search.StringTerm;

import webmail.mail.MimeMess和记娱乐怡情怎么样ageParser;

/**

*

Title: JSubjectTerm.java

*

Description:

*

Copyright: Copyright (c) 2004-2008

*

Company: coffee-mail of BeiJing

*

* @author wang weiping

* @version 1.0 2005-1-30

*/

public class JSubjectTerm extends StringTerm{

public JSubjectTerm(String pattern){

super(pattern);

}

/* (non-Javadoc)

* 核心: 主要的便是扩展SearchTerm的match(Message message) 和记娱乐怡情怎么样措施

* @see javax.mail.search.SearchTerm#match(javax.mail.Message)

*/

public boolean match(Message message){

String subject = "";

//以下应用自定义的类MimeMessageParser类来实现对M和记娱乐怡情怎么样imeMessage的解析

//来得到特定邮件的主题

MimeMessag和记娱乐怡情怎么样eParser mmp = MimeMessageParser.getMessageParser((MimeMessage)message);

try{

//调用MimeMessageParser类的getSubject()措施来得到邮件的主题

subject = mmp.getSubject();

}catch(Exception ex){

//ignore exception

return false;

}

if(subject == null) return false;

return super.match(subject);

}

//留意必然要覆写StringTerm的equals(Object object)措施,详细来由请参看Effective Java

public boolean equals(Object obj) {

if (! (obj instanceof JSubjectTerm)) {

return false;

}

return super.equals(obj);

}

}

您可能还会对下面的文章感兴趣: