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

StringTerm

public abstract class StringTerm extends SearchTerm
This class implements the match method for Strings. The current implementation provides only for substring matching. We could add comparisons (like strcmp ...).
author
Bill Shannon
author
John Mani

Fields Summary
protected String
pattern
The pattern.
protected boolean
ignoreCase
Ignore case when comparing?
private static final long
serialVersionUID
Constructors Summary
protected StringTerm(String pattern)


       
	this.pattern = pattern;
	ignoreCase = true;
    
protected StringTerm(String pattern, boolean ignoreCase)

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

	if (!(obj instanceof StringTerm))
	    return false;
	StringTerm st = (StringTerm)obj;
	if (ignoreCase)
	    return st.pattern.equalsIgnoreCase(this.pattern) &&
		    st.ignoreCase == this.ignoreCase;
	else
	    return st.pattern.equals(this.pattern) &&
		    st.ignoreCase == this.ignoreCase;
    
public booleangetIgnoreCase()
Return true if we should ignore case when matching.

	return ignoreCase;
    
public java.lang.StringgetPattern()
Return the string to match with.

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

	return ignoreCase ? pattern.hashCode() : ~pattern.hashCode();
    
protected booleanmatch(java.lang.String s)

	int len = s.length() - pattern.length();
	for (int i=0; i <= len; i++) {
	    if (s.regionMatches(ignoreCase, i, 
				pattern, 0, pattern.length()))
		return true;
	}
	return false;