javax.mail.search
abstract public class: StringTerm [javadoc |
source]
java.lang.Object
javax.mail.search.SearchTerm
javax.mail.search.StringTerm
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BodyTerm, RecipientStringTerm, MessageIDTerm, FromStringTerm, SubjectTerm, HeaderTerm, AddressStringTerm
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
Field Summary |
---|
protected String | pattern | The pattern. |
protected boolean | ignoreCase | Ignore case when comparing? |
Methods from javax.mail.search.SearchTerm: |
---|
match |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.mail.search.StringTerm Detail: |
public boolean equals(Object obj) {
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 boolean getIgnoreCase() {
return ignoreCase;
}
Return true if we should ignore case when matching. |
public String getPattern() {
return pattern;
}
Return the string to match with. |
public int hashCode() {
return ignoreCase ? pattern.hashCode() : ~pattern.hashCode();
}
Compute a hashCode for this object. |
protected boolean match(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;
}
|