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. package org.apache.commons.httpclient;
  30. /**
  31. * The URI parsing and escape encoding exception.
  32. *
  33. * @author <a href="mailto:jericho at apache.org">Sung-Gu</a>
  34. * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
  35. * @version $Revision: 1.11 $ $Date: 2002/03/14 15:14:01
  36. */
  37. public class URIException extends HttpException {
  38. // ----------------------------------------------------------- constructors
  39. /**
  40. * Default constructor.
  41. */
  42. public URIException() {
  43. }
  44. /**
  45. * The constructor with a reason code argument.
  46. *
  47. * @param reasonCode the reason code
  48. */
  49. public URIException(int reasonCode) {
  50. setReasonCode(reasonCode);
  51. }
  52. /**
  53. * The constructor with a reason string and its code arguments.
  54. *
  55. * @param reasonCode the reason code
  56. * @param reason the reason
  57. */
  58. public URIException(int reasonCode, String reason) {
  59. super(reason); // for backward compatibility of Throwable
  60. this.reason = reason;
  61. setReasonCode(reasonCode);
  62. }
  63. /**
  64. * The constructor with a reason string argument.
  65. *
  66. * @param reason the reason
  67. */
  68. public URIException(String reason) {
  69. super(reason); // for backward compatibility of Throwable
  70. this.reason = reason;
  71. setReasonCode(UNKNOWN);
  72. }
  73. // -------------------------------------------------------------- constants
  74. /**
  75. * No specified reason code.
  76. */
  77. public static final int UNKNOWN = 0;
  78. /**
  79. * The URI parsing error.
  80. */
  81. public static final int PARSING = 1;
  82. /**
  83. * The unsupported character encoding.
  84. */
  85. public static final int UNSUPPORTED_ENCODING = 2;
  86. /**
  87. * The URI escape encoding and decoding error.
  88. */
  89. public static final int ESCAPING = 3;
  90. /**
  91. * The DNS punycode encoding or decoding error.
  92. */
  93. public static final int PUNYCODE = 4;
  94. // ------------------------------------------------------------- properties
  95. /**
  96. * The reason code.
  97. */
  98. protected int reasonCode;
  99. /**
  100. * The reason message.
  101. */
  102. protected String reason;
  103. // ---------------------------------------------------------------- methods
  104. /**
  105. * Get the reason code.
  106. *
  107. * @return the reason code
  108. */
  109. public int getReasonCode() {
  110. return reasonCode;
  111. }
  112. /**
  113. * Set the reason code.
  114. *
  115. * @param reasonCode the reason code
  116. */
  117. public void setReasonCode(int reasonCode) {
  118. this.reasonCode = reasonCode;
  119. }
  120. /**
  121. * Get the reason message.
  122. *
  123. * @return the reason message
  124. */
  125. public String getReason() {
  126. return reason;
  127. }
  128. /**
  129. * Set the reason message.
  130. *
  131. * @param reason the reason message
  132. */
  133. public void setReason(String reason) {
  134. this.reason = reason;
  135. }
  136. }