Skip to content

Package: TransportEvent

TransportEvent

nameinstructionbranchcomplexitylinemethod
TransportEvent(Transport, int, Address[], Address[], Address[], Message)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
dispatch(Object)
M: 23 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getInvalidAddresses()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMessage()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getValidSentAddresses()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getValidUnsentAddresses()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2021 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 jakarta.mail.event;
18:
19: import java.util.*;
20: import jakarta.mail.*;
21:
22: /**
23: * This class models Transport events.
24: *
25: * @author John Mani
26: * @author Max Spivak
27: *
28: * @see jakarta.mail.Transport
29: * @see jakarta.mail.event.TransportListener
30: */
31:
32: public class TransportEvent extends MailEvent {
33:
34: /**
35: * Message has been        successfully delivered to all recipients by the
36: * transport firing this event. validSent[] contains all the addresses
37: * this transport sent to successfully. validUnsent[] and invalid[]
38: * should be null,
39: */
40: public static final int MESSAGE_DELIVERED         = 1;
41:
42: /**
43: * Message was not sent for some reason. validSent[] should be null.
44: * validUnsent[] may have addresses that are valid (but the message
45: * wasn't sent to them). invalid[] should likely contain invalid addresses.
46: */
47: public static final int MESSAGE_NOT_DELIVERED = 2;
48:
49: /**
50: * Message was successfully sent to some recipients but not to all.
51: * validSent[] holds addresses of recipients to whom the message was sent.
52: * validUnsent[] holds valid addresses to which the message was not sent.
53: * invalid[] holds invalid addresses, if any.
54: */
55: public static final int MESSAGE_PARTIALLY_DELIVERED = 3;
56:
57:
58: /**
59: * The event type.
60: *
61: * @serial
62: */
63: protected int type;
64:
65: /** The valid address to which the message was sent. */
66: transient protected Address[] validSent;
67: /** The valid address to which the message was not sent. */
68: transient protected Address[] validUnsent;
69: /** The invalid addresses. */
70: transient protected Address[] invalid;
71: /** The Message to which this event applies. */
72: transient protected Message msg;
73:
74: private static final long serialVersionUID = -4729852364684273073L;
75:
76: /**
77: * Constructor.
78: *
79: * @param        transport The Transport object
80: * @param        type        the event type (MESSAGE_DELIVERED, etc.)
81: * @param        validSent the valid addresses to which the message was sent
82: * @param        validUnsent the valid addresses to which the message was
83: *                                not sent
84: * @param        invalid        the invalid addresses
85: * @param        msg        the message being sent
86: */
87: public TransportEvent(Transport transport, int type, Address[] validSent,
88:                          Address[] validUnsent, Address[] invalid,
89:                          Message msg) {
90:         super(transport);
91:         this.type = type;
92:         this.validSent = validSent;
93:         this.validUnsent = validUnsent;
94:         this.invalid = invalid;
95:         this.msg = msg;
96: }
97:
98: /**
99: * Return the type of this event.
100: * @return type
101: */
102: public int getType() {
103:         return type;
104: }
105:
106: /**
107: * Return the addresses to which this message was sent succesfully.
108: * @return Addresses to which the message was sent successfully or null
109: */
110: public Address[] getValidSentAddresses() {
111:         return validSent;
112: }
113:
114: /**
115: * Return the addresses that are valid but to which this message
116: * was not sent.
117: * @return Addresses that are valid but to which the message was
118: * not sent successfully or null
119: */
120: public Address[] getValidUnsentAddresses() {
121:         return validUnsent;
122: }
123:
124: /**
125: * Return the addresses to which this message could not be sent.
126: * @return Addresses to which the message sending failed or null
127: */
128: public Address[] getInvalidAddresses() {
129:         return invalid;
130: }
131:
132: /**
133: * Get the Message object associated with this Transport Event.
134: *
135: * @return the Message object
136: * @since                JavaMail 1.2
137: */
138: public Message getMessage() {
139: return msg;
140: }
141:
142: /**
143: * Invokes the appropriate TransportListener method.
144: */
145: @Override
146: public void dispatch(Object listener) {
147:•        if (type == MESSAGE_DELIVERED)        
148:          ((TransportListener)listener).messageDelivered(this);
149:•        else if (type == MESSAGE_NOT_DELIVERED)
150:          ((TransportListener)listener).messageNotDelivered(this);
151:         else // MESSAGE_PARTIALLY_DELIVERED
152:          ((TransportListener)listener).messagePartiallyDelivered(this);
153: }
154: }