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

RecipientStringTerm

public final class RecipientStringTerm extends AddressStringTerm
This class implements string comparisons for the Recipient Address headers.

Note that this class differs from the RecipientTerm class in that this class does comparisons on address strings rather than Address objects. The string comparisons are case-insensitive.

since
JavaMail 1.1

Fields Summary
private Message$RecipientType
type
The recipient type.
private static final long
serialVersionUID
Constructors Summary
public RecipientStringTerm(Message$RecipientType type, String pattern)
Constructor.

param
type the recipient type
param
pattern the address pattern to be compared.


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

	if (!(obj instanceof RecipientStringTerm))
	    return false;
	RecipientStringTerm rst = (RecipientStringTerm)obj;
	return rst.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)
Check whether the address specified in the constructor is a substring of the recipient address of this Message.

param
msg The comparison is applied to this Message's recipient 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;