001: /*
002: * $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 $
003: * $Revision: 480424 $
004: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005: *
006: * ====================================================================
007: *
008: * Licensed to the Apache Software Foundation (ASF) under one or more
009: * contributor license agreements. See the NOTICE file distributed with
010: * this work for additional information regarding copyright ownership.
011: * The ASF licenses this file to You under the Apache License, Version 2.0
012: * (the "License"); you may not use this file except in compliance with
013: * the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing, software
018: * distributed under the License is distributed on an "AS IS" BASIS,
019: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020: * See the License for the specific language governing permissions and
021: * limitations under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: */
030:
031: package org.apache.commons.httpclient;
032:
033: /**
034: * The URI parsing and escape encoding exception.
035: *
036: * @author <a href="mailto:jericho at apache.org">Sung-Gu</a>
037: * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
038: * @version $Revision: 480424 $ $Date: 2002/03/14 15:14:01
039: */
040: public class URIException extends HttpException {
041:
042: // ----------------------------------------------------------- constructors
043:
044: /**
045: * Default constructor.
046: */
047: public URIException() {
048: }
049:
050: /**
051: * The constructor with a reason code argument.
052: *
053: * @param reasonCode the reason code
054: */
055: public URIException(int reasonCode) {
056: this .reasonCode = reasonCode;
057: }
058:
059: /**
060: * The constructor with a reason string and its code arguments.
061: *
062: * @param reasonCode the reason code
063: * @param reason the reason
064: */
065: public URIException(int reasonCode, String reason) {
066: super (reason); // for backward compatibility of Throwable
067: this .reason = reason;
068: this .reasonCode = reasonCode;
069: }
070:
071: /**
072: * The constructor with a reason string argument.
073: *
074: * @param reason the reason
075: */
076: public URIException(String reason) {
077: super (reason); // for backward compatibility of Throwable
078: this .reason = reason;
079: this .reasonCode = UNKNOWN;
080: }
081:
082: // -------------------------------------------------------------- constants
083:
084: /**
085: * No specified reason code.
086: */
087: public static final int UNKNOWN = 0;
088:
089: /**
090: * The URI parsing error.
091: */
092: public static final int PARSING = 1;
093:
094: /**
095: * The unsupported character encoding.
096: */
097: public static final int UNSUPPORTED_ENCODING = 2;
098:
099: /**
100: * The URI escape encoding and decoding error.
101: */
102: public static final int ESCAPING = 3;
103:
104: /**
105: * The DNS punycode encoding or decoding error.
106: */
107: public static final int PUNYCODE = 4;
108:
109: // ------------------------------------------------------------- properties
110:
111: /**
112: * The reason code.
113: */
114: protected int reasonCode;
115:
116: /**
117: * The reason message.
118: */
119: protected String reason;
120:
121: // ---------------------------------------------------------------- methods
122:
123: /**
124: * Get the reason code.
125: *
126: * @return the reason code
127: */
128: public int getReasonCode() {
129: return reasonCode;
130: }
131:
132: /**
133: * Set the reason code.
134: *
135: * @param reasonCode the reason code
136: *
137: * @deprecated Callers should set the reason code as a parameter to the
138: * constructor.
139: */
140: public void setReasonCode(int reasonCode) {
141: this .reasonCode = reasonCode;
142: }
143:
144: /**
145: * Get the reason message.
146: *
147: * @return the reason message
148: *
149: * @deprecated You should instead call {@link #getMessage()}.
150: */
151: public String getReason() {
152: return reason;
153: }
154:
155: /**
156: * Set the reason message.
157: *
158: * @param reason the reason message
159: *
160: * @deprecated Callers should instead set this via a parameter to the constructor.
161: */
162: public void setReason(String reason) {
163: this.reason = reason;
164: }
165:
166: }
|