View Javadoc

1   /*
2    * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URIException.java,v 1.11 2004/04/18 23:51:35 jsdever Exp $
3    * $Revision: 1.11 $
4    * $Date: 2004/04/18 23:51:35 $
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   */
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: 1.11 $ $Date: 2002/03/14 15:14:01 
38   */
39  public class URIException extends HttpException {
40  
41      // ----------------------------------------------------------- constructors
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          setReasonCode(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); // for backward compatibility of Throwable
68          this.reason = reason;
69          setReasonCode(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); // for backward compatibility of Throwable
80          this.reason = reason;
81          setReasonCode(UNKNOWN);
82      }
83  
84      // -------------------------------------------------------------- constants
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     // ------------------------------------------------------------- properties
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     // ---------------------------------------------------------------- methods
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     /***
141      * Set the reason code.
142      *
143      * @param reasonCode the reason code
144      */
145     public void setReasonCode(int reasonCode) {
146         this.reasonCode = reasonCode;
147     }
148 
149 
150     /***
151      * Get the reason message.
152      *
153      * @return the reason message
154      */
155     public String getReason() {
156         return reason;
157     }
158 
159 
160     /***
161      * Set the reason message.
162      *
163      * @param reason the reason message
164      */
165     public void setReason(String reason) {
166         this.reason = reason;
167     }
168 
169 
170 }
171