View Javadoc

1   /*
2    * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/URIException.java,v 1.12 2004/09/30 18:53:20 olegk Exp $
3    * $Revision: 155418 $
4    * $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $
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: 155418 $ $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          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); // for backward compatibility of Throwable
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); // for backward compatibility of Throwable
80          this.reason = reason;
81          this.reasonCode = 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      * 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