View Javadoc

1   /*
2    * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URIException.java,v 1.8.2.1 2004/02/22 18:21:13 olegk Exp $
3    * $Revision: 1.8.2.1 $
4    * $Date: 2004/02/22 18:21:13 $
5    *
6    * ====================================================================
7    *
8    *  Copyright 2002-2004 The Apache Software Foundation
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   * ====================================================================
22   *
23   * This software consists of voluntary contributions made by many
24   * individuals on behalf of the Apache Software Foundation.  For more
25   * information on the Apache Software Foundation, please see
26   * <http://www.apache.org/>.
27   *
28   * [Additional notices, if required by prior licensing conditions]
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      // ----------------------------------------------------------- constructors
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); // for backward compatibility of Throwable
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); // for backward compatibility of Throwable
87          this.reason = reason;
88          setReasonCode(UNKNOWN);
89      }
90  
91      // -------------------------------------------------------------- constants
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     // ------------------------------------------------------------- properties
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     // ---------------------------------------------------------------- methods
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