1 21 22 27 28 package javax.mail.search; 29 30 import javax.mail.Message ; 31 32 38 public final class OrTerm extends SearchTerm { 39 40 46 protected SearchTerm [] terms; 47 48 private static final long serialVersionUID = 5380534067523646936L; 49 50 56 public OrTerm(SearchTerm t1, SearchTerm t2) { 57 terms = new SearchTerm [2]; 58 terms[0] = t1; 59 terms[1] = t2; 60 } 61 62 67 public OrTerm(SearchTerm [] t) { 68 terms = new SearchTerm [t.length]; 69 for (int i = 0; i < t.length; i++) 70 terms[i] = t[i]; 71 } 72 73 76 public SearchTerm [] getTerms() { 77 return (SearchTerm [])terms.clone(); 78 } 79 80 90 91 public boolean match(Message msg) { 92 for (int i=0; i < terms.length; i++) 93 if (terms[i].match(msg)) 94 return true; 95 return false; 96 } 97 98 101 public boolean equals(Object obj) { 102 if (!(obj instanceof OrTerm )) 103 return false; 104 OrTerm ot = (OrTerm )obj; 105 if (ot.terms.length != terms.length) 106 return false; 107 for (int i=0; i < terms.length; i++) 108 if (!terms[i].equals(ot.terms[i])) 109 return false; 110 return true; 111 } 112 113 116 public int hashCode() { 117 int hash = 0; 118 for (int i=0; i < terms.length; i++) 119 hash += terms[i].hashCode(); 120 return hash; 121 } 122 } 123 | Popular Tags |