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