1 17 18 package org.apache.james.transport.matchers; 19 20 import org.apache.mailet.GenericMatcher; 21 import org.apache.mailet.Mail; 22 23 import java.util.Collection ; 24 import java.util.Collections ; 25 import java.util.StringTokenizer ; 26 27 38 public class SenderHostIs extends GenericMatcher { 39 42 private Collection senderHosts; 43 44 47 public void init() { 48 StringTokenizer st = new StringTokenizer (getCondition(), ", ", false); 50 51 senderHosts = new java.util.HashSet (); 53 while (st.hasMoreTokens()) { 54 senderHosts.add(((String )st.nextToken()).toLowerCase()); 55 } 56 senderHosts = Collections.unmodifiableCollection(senderHosts); 57 } 58 59 67 public Collection match(Mail mail) { 68 try { 69 if (mail.getSender() != null && senderHosts.contains(mail.getSender().getHost().toLowerCase())) { 70 return mail.getRecipients(); 71 } 72 } catch (Exception e) { 73 log(e.getMessage()); 74 } 75 76 return null; } 78 } 79 | Popular Tags |