FileDocCategorySizeDatePackage
AndTerm.javaAPI DocGlassfish v2 API4140Mon May 14 15:28:50 BST 2007javax.mail.search

AndTerm

public final class AndTerm extends SearchTerm
This class implements the logical AND operator on individual SearchTerms.
author
Bill Shannon
author
John Mani

Fields Summary
protected SearchTerm[]
terms
The array of terms on which the AND operator should be applied.
private static final long
serialVersionUID
Constructors Summary
public AndTerm(SearchTerm t1, SearchTerm t2)
Constructor that takes two terms.

param
t1 first term
param
t2 second term


                       
         
	terms = new SearchTerm[2];
	terms[0] = t1;
	terms[1] = t2;
    
public AndTerm(SearchTerm[] t)
Constructor that takes an array of SearchTerms.

param
t array of terms

	terms = new SearchTerm[t.length]; // clone the array
	for (int i = 0; i < t.length; i++)
	    terms[i] = t[i];
    
Methods Summary
public booleanequals(java.lang.Object obj)
Equality comparison.

	if (!(obj instanceof AndTerm))
	    return false;
	AndTerm at = (AndTerm)obj;
	if (at.terms.length != terms.length)
	    return false;
	for (int i=0; i < terms.length; i++)
	    if (!terms[i].equals(at.terms[i]))
		return false;
	return true;
    
public javax.mail.search.SearchTerm[]getTerms()
Return the search terms.

	return (SearchTerm[])terms.clone();
    
public inthashCode()
Compute a hashCode for this object.

	int hash = 0;
	for (int i=0; i < terms.length; i++)
	    hash += terms[i].hashCode();
	return hash;
    
public booleanmatch(javax.mail.Message msg)
The AND operation.

The terms specified in the constructor are applied to the given object and the AND operator is applied to their results.

param
msg The specified SearchTerms are applied to this Message and the AND operator is applied to their results.
return
true if the AND succeds, otherwise false

	for (int i=0; i < terms.length; i++)
	    if (!terms[i].match(msg))
		return false;
	return true;