Clover coverage report - Maven Clover report
Coverage timestamp: Sun Aug 20 2006 04:01:04 PDT
file stats: LOC: 90   Methods: 6
NCLOC: 36   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AndTerm.java 0% 0% 0% 0%
coverage
 1    /**
 2    *
 3    * Copyright 2003-2004 The Apache Software Foundation
 4    *
 5    * Licensed under the Apache License, Version 2.0 (the "License");
 6    * you may not use this file except in compliance with the License.
 7    * You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    */
 17   
 18    package javax.mail.search;
 19   
 20    import java.util.Arrays;
 21    import javax.mail.Message;
 22   
 23    /**
 24    * Term that implements a logical AND across terms.
 25    *
 26    * @version $Rev: 126550 $ $Date: 2005-01-26 14:27:45 -0800 (Wed, 26 Jan 2005) $
 27    */
 28    public final class AndTerm extends SearchTerm {
 29    /**
 30    * Terms to which the AND operator should be applied.
 31    */
 32    protected SearchTerm[] terms;
 33   
 34    /**
 35    * Constructor for performing a binary AND.
 36    *
 37    * @param a the first term
 38    * @param b the second ter,
 39    */
 40  0 public AndTerm(SearchTerm a, SearchTerm b) {
 41  0 terms = new SearchTerm[]{a, b};
 42    }
 43   
 44    /**
 45    * Constructor for performing and AND across an arbitraty number of terms.
 46    * @param terms the terms to AND together
 47    */
 48  0 public AndTerm(SearchTerm[] terms) {
 49  0 this.terms = terms;
 50    }
 51   
 52    /**
 53    * Return the terms.
 54    * @return the terms
 55    */
 56  0 public SearchTerm[] getTerms() {
 57  0 return terms;
 58    }
 59   
 60    /**
 61    * Match by applying the terms, in order, to the Message and performing an AND operation
 62    * to the result. Comparision will stop immediately if one of the terms returns false.
 63    *
 64    * @param message the Message to apply the terms to
 65    * @return true if all terms match
 66    */
 67  0 public boolean match(Message message) {
 68  0 for (int i = 0; i < terms.length; i++) {
 69  0 SearchTerm term = terms[i];
 70  0 if (!term.match(message)) {
 71  0 return false;
 72    }
 73    }
 74  0 return true;
 75    }
 76   
 77  0 public boolean equals(Object other) {
 78  0 if (other == this) return true;
 79  0 if (other instanceof AndTerm == false) return false;
 80  0 return Arrays.equals(terms, ((AndTerm) other).terms);
 81    }
 82   
 83  0 public int hashCode() {
 84  0 int hash = 0;
 85  0 for (int i = 0; i < terms.length; i++) {
 86  0 hash = hash * 37 + terms[i].hashCode();
 87    }
 88  0 return hash;
 89    }
 90    }