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
31
32 package org.apache.commons.httpclient;
33
34 import java.io.IOException;
35
36 /***
37 * The URI parsing and escape encoding exception.
38 * <p>
39 * Why is it from IOException?
40 * To simplify the programming style for the inherited exception instances.
41 * <p>
42 *
43 * @author <a href="mailto:jericho at apache.org">Sung-Gu</a>
44 * @version $Revision: 1.8.2.1 $ $Date: 2002/03/14 15:14:01
45 */
46 public class URIException extends IOException {
47
48
49
50 /***
51 * Default constructor.
52 */
53 public URIException() {
54 }
55
56
57 /***
58 * The constructor with a reason code argument.
59 *
60 * @param reasonCode the reason code
61 */
62 public URIException(int reasonCode) {
63 setReasonCode(reasonCode);
64 }
65
66
67 /***
68 * The constructor with a reason string and its code arguments.
69 *
70 * @param reasonCode the reason code
71 * @param reason the reason
72 */
73 public URIException(int reasonCode, String reason) {
74 super(reason);
75 this.reason = reason;
76 setReasonCode(reasonCode);
77 }
78
79
80 /***
81 * The constructor with a reason string argument.
82 *
83 * @param reason the reason
84 */
85 public URIException(String reason) {
86 super(reason);
87 this.reason = reason;
88 setReasonCode(UNKNOWN);
89 }
90
91
92
93 /***
94 * No specified reason code.
95 */
96 public static final int UNKNOWN = 0;
97
98
99 /***
100 * The URI parsing error.
101 */
102 public static final int PARSING = 1;
103
104
105 /***
106 * The unsupported character encoding.
107 */
108 public static final int UNSUPPORTED_ENCODING = 2;
109
110
111 /***
112 * The URI escape encoding and decoding error.
113 */
114 public static final int ESCAPING = 3;
115
116
117 /***
118 * The DNS punycode encoding or decoding error.
119 */
120 public static final int PUNYCODE = 4;
121
122
123
124 /***
125 * The reason code.
126 */
127 protected int reasonCode;
128
129
130 /***
131 * The reason message.
132 */
133 protected String reason;
134
135
136
137 /***
138 * Get the reason code.
139 *
140 * @return the reason code
141 */
142 public int getReasonCode() {
143 return reasonCode;
144 }
145
146
147 /***
148 * Set the reason code.
149 *
150 * @param reasonCode the reason code
151 */
152 public void setReasonCode(int reasonCode) {
153 this.reasonCode = reasonCode;
154 }
155
156
157 /***
158 * Get the reason message.
159 *
160 * @return the reason message
161 */
162 public String getReason() {
163 return reason;
164 }
165
166
167 /***
168 * Set the reason message.
169 *
170 * @param reason the reason message
171 */
172 public void setReason(String reason) {
173 this.reason = reason;
174 }
175
176
177 }
178