MCPcopy Create free account
hub / github.com/M66B/FairEmail / matchPart

Method matchPart

app/src/main/java/javax/mail/search/BodyTerm.java:59–92  ·  view source on GitHub ↗

Search all the parts of the message for any text part that matches the pattern.

(Part p)

Source from the content-addressed store, hash-verified

57 * that matches the pattern.
58 */
59 private boolean matchPart(Part p) {
60 try {
61 /*
62 * Using isMimeType to determine the content type avoids
63 * fetching the actual content data until we need it.
64 */
65 if (p.isMimeType("text/*")) {
66 String s = (String)p.getContent();
67 if (s == null)
68 return false;
69 /*
70 * We invoke our superclass' (i.e., StringTerm) match method.
71 * Note however that StringTerm.match() is not optimized
72 * for substring searches in large string buffers. We really
73 * need to have a StringTerm subclass, say BigStringTerm,
74 * with its own match() method that uses a better algorithm ..
75 * and then subclass BodyTerm from BigStringTerm.
76 */
77 return super.match(s);
78 } else if (p.isMimeType("multipart/*")) {
79 Multipart mp = (Multipart)p.getContent();
80 int count = mp.getCount();
81 for (int i = 0; i < count; i++)
82 if (matchPart(mp.getBodyPart(i)))
83 return true;
84 } else if (p.isMimeType("message/rfc822")) {
85 return matchPart((Part)p.getContent());
86 }
87 } catch (MessagingException ex) {
88 } catch (IOException ex) {
89 } catch (RuntimeException ex) {
90 }
91 return false;
92 }
93
94 /**
95 * Equality comparison.

Callers 1

matchMethod · 0.95

Calls 5

getCountMethod · 0.95
getBodyPartMethod · 0.95
isMimeTypeMethod · 0.65
getContentMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected