Skip to content

Package: multipart_report

multipart_report

nameinstructionbranchcomplexitylinemethod
getContent(DataSource)
M: 17 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getTransferData(ActivationDataFlavor, DataSource)
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getTransferDataFlavors()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
multipart_report()
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
writeTo(Object, String, OutputStream)
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

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.dsn;
18:
19: import java.io.*;
20: import jakarta.activation.*;
21: import jakarta.mail.MessagingException;
22:
23:
24: /**
25: * DataContentHandler for multipart/report MIME type.
26: * Applications should not use this class directly, it's used indirectly
27: * through the JavaBeans Activation Framework.
28: *
29: * @since        JavaMail 1.4
30: */
31: public class multipart_report implements DataContentHandler {
32: private ActivationDataFlavor myDF = new ActivationDataFlavor(
33:          MultipartReport.class,
34:          "multipart/report",
35:          "Multipart Report");
36:
37: /**
38: * Creates a default {@code multipart_report}.
39: */
40: public multipart_report() {
41: }
42:
43: /**
44: * Return the ActivationDataFlavors for this <code>DataContentHandler</code>.
45: *
46: * @return The ActivationDataFlavors
47: */
48: public ActivationDataFlavor[] getTransferDataFlavors() { // throws Exception;
49:         return new ActivationDataFlavor[] { myDF };
50: }
51:
52: /**
53: * Return the Transfer Data of type ActivationDataFlavor from InputStream.
54: *
55: * @param df The ActivationDataFlavor
56: * @param ds The DataSource corresponding to the data
57: * @return String object
58: */
59: public Object getTransferData(ActivationDataFlavor df, DataSource ds)
60:                                 throws IOException {
61:         // use myDF.equals to be sure to get ActivationDataFlavor.equals,
62:         // which properly ignores Content-Type parameters in comparison
63:•        if (myDF.equals(df))
64:          return getContent(ds);
65:         else
66:          return null;
67: }
68:
69: /**
70: * Return the content.
71: */
72: public Object getContent(DataSource ds) throws IOException {
73:         try {
74:          return new MultipartReport(ds);
75:         } catch (MessagingException e) {
76:          IOException ioex =
77:                 new IOException("Exception while constructing MultipartReport");
78:          ioex.initCause(e);
79:          throw ioex;
80:         }
81: }
82:
83: /**
84: * Write the object to the output stream, using the specific MIME type.
85: */
86: public void writeTo(Object obj, String mimeType, OutputStream os)
87:                         throws IOException {
88:•        if (obj instanceof MultipartReport) {
89:          try {
90:                 ((MultipartReport)obj).writeTo(os);
91:          } catch (MessagingException e) {
92:                 throw new IOException(e.toString());
93:          }
94:         }
95: }
96: }