Package: IMAPMultipartDataSource
IMAPMultipartDataSource
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
IMAPMultipartDataSource(MimePart, BODYSTRUCTURE[], String, IMAPMessage) |
|
|
|
|
|
||||||||||||||||||||
getBodyPart(int) |
|
|
|
|
|
||||||||||||||||||||
getCount() |
|
|
|
|
|
Coverage
1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.imap;
18:
19:
20: import jakarta.mail.*;
21: import jakarta.mail.internet.*;
22:
23: import org.eclipse.angus.mail.imap.protocol.*;
24: import org.eclipse.angus.mail.imap.protocol.BODYSTRUCTURE;
25:
26: import java.util.ArrayList;
27: import java.util.List;
28:
29: /**
30: * This class
31: *
32: * @author John Mani
33: */
34:
35: public class IMAPMultipartDataSource extends MimePartDataSource
36:                                  implements MultipartDataSource {
37: private List<IMAPBodyPart> parts;
38:
39: protected IMAPMultipartDataSource(MimePart part, BODYSTRUCTURE[] bs,
40:                                  String sectionId, IMAPMessage msg) {
41:         super(part);
42:
43:         parts = new ArrayList<>(bs.length);
44:•        for (int i = 0; i < bs.length; i++)
45:          parts.add(
46:                 new IMAPBodyPart(bs[i],
47:•                                 sectionId == null ?
48:                                  Integer.toString(i+1) :
49:                                  sectionId + "." + Integer.toString(i+1),
50:                                  msg)
51:          );
52: }
53:
54: @Override
55: public int getCount() {
56:         return parts.size();
57: }
58:
59: @Override
60: public BodyPart getBodyPart(int index) throws MessagingException {
61:         return parts.get(index);
62: }
63: }