1 21 22 27 28 package javax.mail.search; 29 30 import javax.mail.Message ; 31 32 39 public final class AndTerm extends SearchTerm { 40 41 47 protected SearchTerm [] terms; 48 49 private static final long serialVersionUID = -3583274505380989582L; 50 51 57 public AndTerm(SearchTerm t1, SearchTerm t2) { 58 terms = new SearchTerm [2]; 59 terms[0] = t1; 60 terms[1] = t2; 61 } 62 63 68 public AndTerm(SearchTerm [] t) { 69 terms = new SearchTerm [t.length]; for (int i = 0; i < t.length; i++) 71 terms[i] = t[i]; 72 } 73 74 77 public SearchTerm [] getTerms() { 78 return (SearchTerm [])terms.clone(); 79 } 80 81 91 public boolean match(Message msg) { 92 for (int i=0; i < terms.length; i++) 93 if (!terms[i].match(msg)) 94 return false; 95 return true; 96 } 97 98 101 public boolean equals(Object obj) { 102 if (!(obj instanceof AndTerm )) 103 return false; 104 AndTerm at = (AndTerm )obj; 105 if (at.terms.length != terms.length) 106 return false; 107 for (int i=0; i < terms.length; i++) 108 if (!terms[i].equals(at.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 |