1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.geronimo.javamail.store.imap;
19
20 import javax.mail.BodyPart;
21 import javax.mail.MessagingException;
22 import javax.mail.MultipartDataSource;
23
24 import javax.mail.internet.MimePart;
25 import javax.mail.internet.MimePartDataSource;
26
27 import org.apache.geronimo.javamail.store.imap.connection.IMAPBodyStructure;
28
29 public class IMAPMultipartDataSource extends MimePartDataSource implements MultipartDataSource {
30
31 protected BodyPart[] parts;
32
33 IMAPMultipartDataSource(IMAPMessage message, MimePart parent, String section, IMAPBodyStructure bodyStructure) {
34 super(parent);
35
36 parts = new BodyPart[bodyStructure.parts.length];
37
38
39
40
41 String sectionBase = section == null ? "" : section + ".";
42
43 for (int i = 0; i < parts.length; i++) {
44
45 parts[i] = new IMAPMimeBodyPart(message, (IMAPBodyStructure)bodyStructure.parts[i], sectionBase + (i + 1));
46 }
47 }
48
49 public int getCount() {
50 return parts.length;
51 }
52
53 public BodyPart getBodyPart(int index) throws MessagingException {
54 return parts[index];
55 }
56 }