1 17 18 package org.apache.james.transport.matchers; 19 20 import org.apache.mailet.GenericMatcher; 21 import org.apache.mailet.Mail; 22 import org.apache.mailet.MailAddress; 23 24 import java.util.Collection ; 25 import java.util.StringTokenizer ; 26 27 30 public class SenderIs extends GenericMatcher { 31 32 private Collection senders; 33 34 public void init() throws javax.mail.MessagingException { 35 StringTokenizer st = new StringTokenizer (getCondition(), ", \t", false); 36 senders = new java.util.HashSet (); 37 while (st.hasMoreTokens()) { 38 senders.add(new MailAddress(st.nextToken())); 39 } 40 } 41 42 public Collection match(Mail mail) { 43 if (senders.contains(mail.getSender())) { 44 return mail.getRecipients(); 45 } else { 46 return null; 47 } 48 } 49 } 50 | Popular Tags |