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

RecipientTerm

public final class RecipientTerm extends AddressTerm
This class implements comparisons for the Recipient Address headers.
author
Bill Shannon
author
John Mani

Fields Summary
protected Message$RecipientType
type
The recipient type.
private static final long
serialVersionUID
Constructors Summary
public RecipientTerm(Message$RecipientType type, Address address)
Constructor.

param
type the recipient type
param
address the address to match for


       	    	         
         
	super(address);
	this.type = type;
    
Methods Summary
public booleanequals(java.lang.Object obj)
Equality comparison.

	if (!(obj instanceof RecipientTerm))
	    return false;
	RecipientTerm rt = (RecipientTerm)obj;
	return rt.type.equals(this.type) && super.equals(obj);
    
public javax.mail.Message$RecipientTypegetRecipientType()
Return the type of recipient to match with.

	return type;
    
public inthashCode()
Compute a hashCode for this object.

	return type.hashCode() + super.hashCode();
    
public booleanmatch(javax.mail.Message msg)
The match method.

param
msg The address match is applied to this Message's recepient address
return
true if the match succeeds, otherwise false

	Address[] recipients;

	try {
 	    recipients = msg.getRecipients(type);
	} catch (Exception e) {
	    return false;
	}

	if (recipients == null)
	    return false;

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