Skip to content

Package: ConnectionEvent

ConnectionEvent

nameinstructionbranchcomplexitylinemethod
ConnectionEvent(Object, int)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
dispatch(Object)
M: 27 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 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%

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 Connection events.
24: *
25: * @author John Mani
26: */
27:
28: public class ConnectionEvent extends MailEvent {
29:
30: /** A connection was opened. */
31: public static final int OPENED                 = 1;
32: /** A connection was disconnected (not currently used). */
33: public static final int DISCONNECTED         = 2;
34: /** A connection was closed. */
35: public static final int CLOSED                 = 3;
36:
37: /**
38: * The event type.
39: *
40: * @serial
41: */
42: protected int type;
43:
44: private static final long serialVersionUID = -1855480171284792957L;
45:
46: /**
47: * Construct a ConnectionEvent.
48: *
49: * @param        source The source object
50: * @param        type        the event type
51: */
52: public ConnectionEvent(Object source, int type) {
53:         super(source);
54:         this.type = type;
55: }
56:
57: /**
58: * Return the type of this event
59: * @return type
60: */
61: public int getType() {
62:         return type;
63: }
64:
65: /**
66: * Invokes the appropriate ConnectionListener method
67: */
68: @Override
69: public void dispatch(Object listener) {
70:•        if (type == OPENED)
71:          ((ConnectionListener)listener).opened(this);
72:•        else if (type == DISCONNECTED)
73:          ((ConnectionListener)listener).disconnected(this);
74:•        else if (type == CLOSED)
75:          ((ConnectionListener)listener).closed(this);
76: }
77: }