Search all the parts of the message for any text part
that matches the pattern.
try {
/*
* Using isMimeType to determine the content type avoids
* fetching the actual content data until we need it.
*/
if (p.isMimeType("text/*")) {
String s = (String)p.getContent();
if (s == null)
return false;
/*
* We invoke our superclass' (i.e., StringTerm) match method.
* Note however that StringTerm.match() is not optimized
* for substring searches in large string buffers. We really
* need to have a StringTerm subclass, say BigStringTerm,
* with its own match() method that uses a better algorithm ..
* and then subclass BodyTerm from BigStringTerm.
*/
return super.match(s);
} else if (p.isMimeType("multipart/*")) {
Multipart mp = (Multipart)p.getContent();
int count = mp.getCount();
for (int i = 0; i < count; i++)
if (matchPart(mp.getBodyPart(i)))
return true;
} else if (p.isMimeType("message/rfc822")) {
return matchPart((Part)p.getContent());
}
} catch (Exception ex) {
}
return false;