View Javadoc

1   /*
2    * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/oac.hc3x/trunk/src/java/org/apache/commons/httpclient/URIException.java $
3    * $Revision$
4    * $Date$
5    *
6    * ====================================================================
7    *
8    *  Licensed to the Apache Software Foundation (ASF) under one or more
9    *  contributor license agreements.  See the NOTICE file distributed with
10   *  this work for additional information regarding copyright ownership.
11   *  The ASF licenses this file to You under the Apache License, Version 2.0
12   *  (the "License"); you may not use this file except in compliance with
13   *  the License.  You may obtain a copy of the License at
14   *
15   *      http://www.apache.org/licenses/LICENSE-2.0
16   *
17   *  Unless required by applicable law or agreed to in writing, software
18   *  distributed under the License is distributed on an "AS IS" BASIS,
19   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   *  See the License for the specific language governing permissions and
21   *  limitations under the License.
22   * ====================================================================
23   *
24   * This software consists of voluntary contributions made by many
25   * individuals on behalf of the Apache Software Foundation.  For more
26   * information on the Apache Software Foundation, please see
27   * <http://www.apache.org/>.
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$ $Date: 2002/03/14 15:14:01 
39   */
40  public class URIException extends HttpException {
41  
42      // ----------------------------------------------------------- constructors
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); // for backward compatibility of Throwable
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); // for backward compatibility of Throwable
81          this.reason = reason;
82          this.reasonCode = UNKNOWN;
83      }
84  
85      // -------------------------------------------------------------- constants
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     // ------------------------------------------------------------- properties
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     // ---------------------------------------------------------------- methods
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