FileDocCategorySizeDatePackage
OrTerm.javaAPI DocJavaMail 1.4.34070Tue Nov 17 10:38:12 GMT 2009javax.mail.search

OrTerm

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

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

param
t1 first term
param
t2 second term


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

param
t array of search terms

	terms = new SearchTerm[t.length];
	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 OrTerm))
	    return false;
	OrTerm ot = (OrTerm)obj;
	if (ot.terms.length != terms.length)
	    return false;
	for (int i=0; i < terms.length; i++)
	    if (!terms[i].equals(ot.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 OR operation.

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

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

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