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, 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.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: * @param s                the detail message
53: */
54: public AddressException(String s) {
55:         super(s);
56: }
57:
58: /**
59: * Constructs an AddressException with the specified detail message
60: * and reference info.
61: *
62: * @param        s        the detail message
63: * @param        ref        the string being parsed
64: */
65: public AddressException(String s, String ref) {
66:         super(s);
67:         this.ref = ref;
68: }
69:
70: /**
71: * Constructs an AddressException with the specified detail message
72: * and reference info.
73: *
74: * @param        s        the detail message
75: * @param        ref        the string being parsed
76: * @param        pos        the position of the error
77: */
78: public AddressException(String s, String ref, int pos) {
79:         super(s);
80:         this.ref = ref;
81:         this.pos = pos;
82: }
83:
84: /**
85: * Get the string that was being parsed when the error was detected
86: * (null if not relevant).
87: *
88: * @return        the string that was being parsed
89: */
90: public String getRef() {
91:         return ref;
92: }
93:
94: /**
95: * Get the position with the reference string where the error was
96: * detected (-1 if not relevant).
97: *
98: * @return        the position within the string of the error
99: */
100: public int getPos() {
101:         return pos;
102: }
103:
104: @Override
105: public String toString() {
106:         String s = super.toString();
107:•        if (ref == null)
108:          return s;
109:         s += " in string ``" + ref + "''";
110:•        if (pos < 0)
111:          return s;
112:         return s + " at position " + pos;
113: }
114: }