Skip to content

Package: AddressException

AddressException

nameinstructionbranchcomplexitylinemethod
AddressException()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
AddressException(String)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
AddressException(String, String)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
AddressException(String, String, int)
M: 16 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getPos()
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%
getRef()
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%
toString()
M: 39 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 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 jakarta.mail.internet;
18:
19: /**
20: * The exception thrown when a wrongly formatted address is encountered.
21: *
22: * @author Bill Shannon
23: * @author Max Spivak
24: */
25:
26: public class AddressException extends ParseException {
27: /**
28: * The string being parsed.
29: *
30: * @serial
31: */
32: protected String ref = null;
33:
34: /**
35: * The index in the string where the error occurred, or -1 if not known.
36: *
37: * @serial
38: */
39: protected int pos = -1;
40:
41: private static final long serialVersionUID = 9134583443539323120L;
42:
43: /**
44: * Constructs an AddressException with no detail message.
45: */
46: public AddressException() {
47: super();
48: }
49:
50: /**
51: * Constructs an AddressException with the specified detail message.
52: *
53: * @param s the detail message
54: */
55: public AddressException(String s) {
56: super(s);
57: }
58:
59: /**
60: * Constructs an AddressException with the specified detail message
61: * and reference info.
62: *
63: * @param s the detail message
64: * @param ref the string being parsed
65: */
66: public AddressException(String s, String ref) {
67: super(s);
68: this.ref = ref;
69: }
70:
71: /**
72: * Constructs an AddressException with the specified detail message
73: * and reference info.
74: *
75: * @param s the detail message
76: * @param ref the string being parsed
77: * @param pos the position of the error
78: */
79: public AddressException(String s, String ref, int pos) {
80: super(s);
81: this.ref = ref;
82: this.pos = pos;
83: }
84:
85: /**
86: * Get the string that was being parsed when the error was detected
87: * (null if not relevant).
88: *
89: * @return the string that was being parsed
90: */
91: public String getRef() {
92: return ref;
93: }
94:
95: /**
96: * Get the position with the reference string where the error was
97: * detected (-1 if not relevant).
98: *
99: * @return the position within the string of the error
100: */
101: public int getPos() {
102: return pos;
103: }
104:
105: @Override
106: public String toString() {
107: String s = super.toString();
108:• if (ref == null)
109: return s;
110: s += " in string ``" + ref + "''";
111:• if (pos < 0)
112: return s;
113: return s + " at position " + pos;
114: }
115: }