1 package com.ozacc.mail.mailet; 2 3 import java.util.ArrayList; 4 import java.util.Iterator; 5 import java.util.List; 6 7 import com.ozacc.mail.fetch.ReceivedMail; 8 9 /*** 10 * MailetインスタンスとMatcherインスタンスのリストを持つMailetの実行単位となるクラス。 11 * 12 * @since 1.2 13 * @author Tomohiro Otsuka 14 * @version $Id: MailetWrapper.java,v 1.1.2.2 2005/01/23 06:47:01 otsuka Exp $ 15 */ 16 public class MailetWrapper { 17 18 private Mailet mailet; 19 20 private List matcherList; 21 22 /*** 23 * コンストラクタ。 24 */ 25 public MailetWrapper() { 26 matcherList = new ArrayList(); 27 } 28 29 /*** 30 * コンストラクタ。 31 * 32 * @param mailet Mailetインスタンス 33 * @param matcherList Matcherインスタンスのリスト 34 */ 35 public MailetWrapper(Mailet mailet, List matcherList) { 36 this(); 37 this.mailet = mailet; 38 this.matcherList = matcherList; 39 } 40 41 /*** 42 * リストされているMatcherの条件をクリアしたMailetを実行します。 43 * 44 * @param mail 受信メール 45 */ 46 public void execute(ReceivedMail mail) { 47 for (Iterator itr = matcherList.iterator(); itr.hasNext();) { 48 Matcher m = (Matcher)itr.next(); 49 if (!m.match(mail)) { 50 return; 51 } 52 } 53 mailet.service(mail); 54 } 55 56 /*** 57 * Mailetインスタンスを返します。 58 * 59 * @return Mailetインスタンス 60 */ 61 public Mailet getMailet() { 62 return mailet; 63 } 64 65 /*** 66 * Mailetインスタンスをセットします。 67 * 68 * @param mailet Mailetインスタンス 69 */ 70 public void setMailet(Mailet mailet) { 71 this.mailet = mailet; 72 } 73 74 /*** 75 * Matcherインスタンスのリストを返します。 76 * 77 * @return Matcherインスタンスのリスト 78 */ 79 public List getMatcherList() { 80 return matcherList; 81 } 82 83 /*** 84 * Matcherインスタンスのリストをセットします。 85 * 86 * @param matcherList Matcherインスタンスのリスト 87 */ 88 public void setMatcherList(List matcherList) { 89 this.matcherList = matcherList; 90 } 91 }