1 21 22 27 28 package javax.mail.search; 29 30 import javax.mail.Message ; 31 import javax.mail.Address ; 32 33 39 public final class RecipientTerm extends AddressTerm { 40 41 46 protected Message.RecipientType type; 47 48 private static final long serialVersionUID = 6548700653122680468L; 49 50 56 public RecipientTerm(Message.RecipientType type, Address address) { 57 super(address); 58 this.type = type; 59 } 60 61 64 public Message.RecipientType getRecipientType() { 65 return type; 66 } 67 68 75 public boolean match(Message msg) { 76 Address [] recipients; 77 78 try { 79 recipients = msg.getRecipients(type); 80 } catch (Exception e) { 81 return false; 82 } 83 84 if (recipients == null) 85 return false; 86 87 for (int i=0; i < recipients.length; i++) 88 if (super.match(recipients[i])) 89 return true; 90 return false; 91 } 92 93 96 public boolean equals(Object obj) { 97 if (!(obj instanceof RecipientTerm )) 98 return false; 99 RecipientTerm rt = (RecipientTerm )obj; 100 return rt.type.equals(this.type) && super.equals(obj); 101 } 102 103 106 public int hashCode() { 107 return type.hashCode() + super.hashCode(); 108 } 109 } 110 | Popular Tags |