Skip to content

Package: message_deliverystatus

message_deliverystatus

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_deliverystatus()
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/delivery-status 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
32: */
33: public class message_deliverystatus implements DataContentHandler {
34:
35: ActivationDataFlavor ourDataFlavor = new ActivationDataFlavor(
36:         DeliveryStatus.class,
37:         "message/delivery-status",
38:         "Delivery Status");
39:
40: /**
41: * Creates a default {@code message_deliverystatus}.
42: */
43: public message_deliverystatus() {
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 DeliveryStatus
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 DeliveryStatus(session, ds.getInputStream());
89:          */
90:          return new DeliveryStatus(ds.getInputStream());
91:         } catch (MessagingException me) {
92:          throw new IOException("Exception creating DeliveryStatus in " +
93:                  "message/delivery-status DataContentHandler: " +
94:                  me.toString());
95:         }
96: }
97:
98: /**
99: */
100: public void writeTo(Object obj, String mimeType, OutputStream os)
101:                         throws IOException {
102:         // if the object is a DeliveryStatus, we know how to write that out
103:•        if (obj instanceof DeliveryStatus) {
104:          DeliveryStatus ds = (DeliveryStatus)obj;
105:          ds.writeTo(os);
106:
107:         } else {
108:          throw new IOException("unsupported object");
109:         }
110: }
111: }