1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.apache.commons.httpclient;
31
32 /***
33 * The URI parsing and escape encoding exception.
34 *
35 * @author <a href="mailto:jericho at apache.org">Sung-Gu</a>
36 * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
37 * @version $Revision: 155418 $ $Date: 2002/03/14 15:14:01
38 */
39 public class URIException extends HttpException {
40
41
42
43 /***
44 * Default constructor.
45 */
46 public URIException() {
47 }
48
49
50 /***
51 * The constructor with a reason code argument.
52 *
53 * @param reasonCode the reason code
54 */
55 public URIException(int reasonCode) {
56 this.reasonCode = reasonCode;
57 }
58
59
60 /***
61 * The constructor with a reason string and its code arguments.
62 *
63 * @param reasonCode the reason code
64 * @param reason the reason
65 */
66 public URIException(int reasonCode, String reason) {
67 super(reason);
68 this.reason = reason;
69 this.reasonCode = reasonCode;
70 }
71
72
73 /***
74 * The constructor with a reason string argument.
75 *
76 * @param reason the reason
77 */
78 public URIException(String reason) {
79 super(reason);
80 this.reason = reason;
81 this.reasonCode = UNKNOWN;
82 }
83
84
85
86 /***
87 * No specified reason code.
88 */
89 public static final int UNKNOWN = 0;
90
91
92 /***
93 * The URI parsing error.
94 */
95 public static final int PARSING = 1;
96
97
98 /***
99 * The unsupported character encoding.
100 */
101 public static final int UNSUPPORTED_ENCODING = 2;
102
103
104 /***
105 * The URI escape encoding and decoding error.
106 */
107 public static final int ESCAPING = 3;
108
109
110 /***
111 * The DNS punycode encoding or decoding error.
112 */
113 public static final int PUNYCODE = 4;
114
115
116
117 /***
118 * The reason code.
119 */
120 protected int reasonCode;
121
122
123 /***
124 * The reason message.
125 */
126 protected String reason;
127
128
129
130 /***
131 * Get the reason code.
132 *
133 * @return the reason code
134 */
135 public int getReasonCode() {
136 return reasonCode;
137 }
138
139 /***
140 * Set the reason code.
141 *
142 * @param reasonCode the reason code
143 *
144 * @deprecated Callers should set the reason code as a parameter to the
145 * constructor.
146 */
147 public void setReasonCode(int reasonCode) {
148 this.reasonCode = reasonCode;
149 }
150
151
152 /***
153 * Get the reason message.
154 *
155 * @return the reason message
156 *
157 * @deprecated You should instead call {@link #getMessage()}.
158 */
159 public String getReason() {
160 return reason;
161 }
162
163
164 /***
165 * Set the reason message.
166 *
167 * @param reason the reason message
168 *
169 * @deprecated Callers should instead set this via a parameter to the constructor.
170 */
171 public void setReason(String reason) {
172 this.reason = reason;
173 }
174
175
176 }
177