Skip to content

Package: SendResult

SendResult

nameinstructionbranchcomplexitylinemethod
SendResult()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
SendResult(Session)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
SendResult(Session, Throwable)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
SendResult(Throwable)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getException()
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%
getSession()
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%
isOK()
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) 2018, 2023 Oracle and/or its affiliates and others.
3: * All rights reserved.
4: *
5: * This program and the accompanying materials are made available under the
6: * terms of the Eclipse Public License v. 2.0, which is available at
7: * http://www.eclipse.org/legal/epl-2.0.
8: *
9: * This Source Code may also be made available under the following Secondary
10: * Licenses when the conditions for such availability set forth in the
11: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
12: * version 2 with the GNU Classpath Exception, which is available at
13: * https://www.gnu.org/software/classpath/license.html.
14: *
15: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16: */
17:
18: package jakarta.websocket;
19:
20: /**
21: * The result of asynchronously sending a web socket message. A SendResult is either ok indicating there was no problem,
22: * or is not OK in which case there was a problem and it carries an exception to indicate what the problem was.
23: *
24: * @author dannycoward
25: */
26: final public class SendResult {
27:
28: private final Session session;
29: private final Throwable exception;
30: private final boolean isOK;
31:
32: /**
33: * Construct a SendResult carrying an exception.
34: *
35: * @param session the WebSocket session in which the message was sent
36: * @param exception the exception causing a send failure.
37: */
38: public SendResult(Session session, Throwable exception) {
39: this.session = session;
40: this.exception = exception;
41: this.isOK = false;
42: }
43:
44: /**
45: * Construct a SendResult signifying a successful send carrying no exception.
46: *
47: * @param session the WebSocket session in which the message was sent
48: */
49: public SendResult(Session session) {
50: this.session = session;
51: this.exception = null;
52: this.isOK = true;
53: }
54:
55: /**
56: * Construct a SendResult carrying an exception.
57: *
58: * @param exception the exception causing a send failure.
59: *
60: * @deprecated Deprecated in WebSocket 2.2 and will be removed in a future version. Use
61: * {@link #SendResult(Session, Throwable)} as a replacement.
62: */
63: @Deprecated
64: public SendResult(Throwable exception) {
65: this.session = null;
66: this.exception = exception;
67: this.isOK = false;
68: }
69:
70: /**
71: * Construct a SendResult signifying a successful send carrying no exception.
72: *
73: * @deprecated Deprecated in WebSocket 2.2 and will be removed in a future version. Use
74: * {@link #SendResult(Session, Throwable)} as a replacement.
75: */
76: @Deprecated
77: public SendResult() {
78: this.session = null;
79: this.exception = null;
80: this.isOK = true;
81: }
82:
83: /**
84: * The problem sending the message.
85: *
86: * @return the problem or {@code null} if the send was successful.
87: */
88: public Throwable getException() {
89: return exception;
90: }
91:
92: /**
93: * Determines if this result is ok or not.
94: *
95: * @return whether the send was successful or not.
96: */
97: public boolean isOK() {
98: return this.isOK;
99: }
100:
101: /**
102: * The WebSocket session in which the session was sent.
103: *
104: * @return the WebSocket session in which the session was sent or {@code null} if not known.
105: */
106: public Session getSession() {
107: return session;
108: }
109: }