Skip to content

Package: message_dispositionnotification

message_dispositionnotification

nameinstructionbranchcomplexitylinemethod
getContent(DataSource)
M: 20 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 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%
message_dispositionnotification()
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 java.util.Properties;
21: import jakarta.activation.*;
22: import jakarta.mail.*;
23: //import jakarta.mail.internet.*;
24:
25:
26: /**
27: * DataContentHandler for message/disposition-notification MIME type.
28: * Applications should not use this class directly, it's used indirectly
29: * through the JavaBeans Activation Framework.
30: *
31: * @since        JavaMail 1.4.2
32: */
33: public class message_dispositionnotification implements DataContentHandler {
34:
35: ActivationDataFlavor ourDataFlavor = new ActivationDataFlavor(
36:         DispositionNotification.class,
37:         "message/disposition-notification",
38:         "Disposition Notification");
39:
40: /**
41: * Creates a default {@code message_dispositionnotification}.
42: */
43: public message_dispositionnotification() {
44: }
45:
46: /**
47: * return the ActivationDataFlavors for this <code>DataContentHandler</code>
48: * @return The ActivationDataFlavors.
49: */
50: public ActivationDataFlavor[] getTransferDataFlavors() {
51:         return new ActivationDataFlavor[] { ourDataFlavor };
52: }
53:
54: /**
55: * return the Transfer Data of type ActivationDataFlavor from InputStream
56: * @param df The ActivationDataFlavor.
57: * @param ds The DataSource corresponding to the data.
58: * @return a Message object
59: */
60: public Object getTransferData(ActivationDataFlavor df, DataSource ds)
61:                                 throws IOException {
62:         // make sure we can handle this ActivationDataFlavor
63:•        if (ourDataFlavor.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:         // create a new DispositionNotification
74:         try {
75:          /*
76:          Session session;
77:          if (ds instanceof MessageAware) {
78:                 jakarta.mail.MessageContext mc =
79:                         ((MessageAware)ds).getMessageContext();
80:                 session = mc.getSession();
81:          } else {
82:                 // Hopefully a rare case. Also hopefully the application
83:                 // has created a default Session that can just be returned
84:                 // here. If not, the one we create here is better than
85:                 // nothing, but overall not a really good answer.
86:                 session = Session.getDefaultInstance(new Properties(), null);
87:          }
88:          return new DispositionNotification(session, ds.getInputStream());
89:          */
90:          return new DispositionNotification(ds.getInputStream());
91:         } catch (MessagingException me) {
92:          throw new IOException(
93:                  "Exception creating DispositionNotification in " +
94:                  "message/disposition-notification DataContentHandler: " +
95:                  me.toString());
96:         }
97: }
98:
99: /**
100: */
101: public void writeTo(Object obj, String mimeType, OutputStream os)
102:                         throws IOException {
103:         // if it's a DispositionNotification, we know how to write that out
104:•        if (obj instanceof DispositionNotification) {
105:          DispositionNotification dn = (DispositionNotification)obj;
106:          dn.writeTo(os);
107:         } else {
108:          throw new IOException("unsupported object");
109:         }
110: }
111: }