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

FromStringTerm

public final class FromStringTerm extends AddressStringTerm
This class implements string comparisons for the From Address header.

Note that this class differs from the FromTerm 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 static final long
serialVersionUID
Constructors Summary
public FromStringTerm(String pattern)
Constructor.

param
pattern the address pattern to be compared.


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

	if (!(obj instanceof FromStringTerm))
	    return false;
	return super.equals(obj);
    
public booleanmatch(javax.mail.Message msg)
Check whether the address string specified in the constructor is a substring of the From address of this Message.

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

	Address[] from;

	try {
	    from = msg.getFrom();
	} catch (Exception e) {
	    return false;
	}

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