KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > mail > internet > AddressException


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)AddressException.java 1.8 05/08/29
24  *
25  * Copyright 1996-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package javax.mail.internet;
29
30 /**
31  * The exception thrown when a wrongly formatted address is encountered.
32  *
33  * @author Bill Shannon
34  * @author Max Spivak
35  */

36
37 public class AddressException extends ParseException JavaDoc {
38     /**
39      * The string being parsed.
40      *
41      * @serial
42      */

43     protected String JavaDoc ref = null;
44
45     /**
46      * The index in the string where the error occurred, or -1 if not known.
47      *
48      * @serial
49      */

50     protected int pos = -1;
51
52     private static final long serialVersionUID = 9134583443539323120L;
53
54     /**
55      * Constructs an AddressException with no detail message.
56      */

57     public AddressException() {
58     super();
59     }
60
61     /**
62      * Constructs an AddressException with the specified detail message.
63      * @param s the detail message
64      */

65     public AddressException(String JavaDoc s) {
66     super(s);
67     }
68
69     /**
70      * Constructs an AddressException with the specified detail message
71      * and reference info.
72      *
73      * @param s the detail message
74      */

75
76     public AddressException(String JavaDoc s, String JavaDoc ref) {
77     super(s);
78     this.ref = ref;
79     }
80     /**
81      * Constructs an AddressException with the specified detail message
82      * and reference info.
83      *
84      * @param s the detail message
85      */

86     public AddressException(String JavaDoc s, String JavaDoc ref, int pos) {
87     super(s);
88     this.ref = ref;
89     this.pos = pos;
90     }
91
92     /**
93      * Get the string that was being parsed when the error was detected
94      * (null if not relevant).
95      */

96     public String JavaDoc getRef() {
97     return ref;
98     }
99
100     /**
101      * Get the position with the reference string where the error was
102      * detected (-1 if not relevant).
103      */

104     public int getPos() {
105     return pos;
106     }
107
108     public String JavaDoc toString() {
109     String JavaDoc s = super.toString();
110     if (ref == null)
111         return s;
112     s += " in string ``" + ref + "''";
113     if (pos < 0)
114         return s;
115     return s + " at position " + pos;
116     }
117 }
118
Popular Tags