Source Code Cross Referenced for HttpException.java in  » Net » Apache-common-HttpClient » org » apache » commons » httpclient » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Apache common HttpClient » org.apache.commons.httpclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpException.java,v 1.19 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:        import java.io.IOException;
034:        import java.io.PrintStream;
035:        import java.io.PrintWriter;
036:        import java.lang.reflect.Method;
037:
038:        /**
039:         * Signals that an HTTP or HttpClient exception has occurred.
040:         * 
041:         * @author Laura Werner
042:         * 
043:         * @version $Revision: 480424 $ $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
044:         */
045:        public class HttpException extends IOException {
046:
047:            /**
048:             * Creates a new HttpException with a <tt>null</tt> detail message.
049:             */
050:            public HttpException() {
051:                super ();
052:                this .cause = null;
053:            }
054:
055:            /**
056:             * Creates a new HttpException with the specified detail message.
057:             *
058:             * @param message the exception detail message
059:             */
060:            public HttpException(String message) {
061:                super (message);
062:                this .cause = null;
063:            }
064:
065:            /**
066:             * Creates a new HttpException with the specified detail message and cause.
067:             * 
068:             * @param message the exception detail message
069:             * @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
070:             * if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
071:             * 
072:             * @since 3.0
073:             */
074:            public HttpException(String message, Throwable cause) {
075:                super (message);
076:                this .cause = cause;
077:
078:                // If we're running on JDK 1.4 or later, tell Throwable what the cause was
079:                try {
080:                    Class[] paramsClasses = new Class[] { Throwable.class };
081:                    Method initCause = Throwable.class.getMethod("initCause",
082:                            paramsClasses);
083:                    initCause.invoke(this , new Object[] { cause });
084:                } catch (Exception e) {
085:                    // The setCause method must not be available
086:                }
087:            }
088:
089:            /**
090:             * Return the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
091:             *         if the cause is unavailable, unknown, or not a <tt>Throwable</tt>.
092:             * 
093:             * @return the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
094:             *         if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
095:             * 
096:             * @since 3.0
097:             */
098:            public Throwable getCause() {
099:                return cause;
100:            }
101:
102:            /**
103:             * Print this HttpException and its stack trace to the standard error stream.
104:             * 
105:             * @since 3.0
106:             */
107:            public void printStackTrace() {
108:                printStackTrace(System.err);
109:            }
110:
111:            /**
112:             * Print this HttpException and its stack trace to the specified print stream.
113:             * 
114:             * @param s the <tt>PrintStream</tt> to which the exception and its stack trace
115:             * should be written
116:             * 
117:             * @since 3.0
118:             */
119:            public void printStackTrace(PrintStream s) {
120:                try {
121:                    // JDK 1.4 has a nice printStackTrace method that prints the cause's stack
122:                    // trace too and prunes out duplicate stack frames.  Call it if possible,
123:                    // which is determined by checking whether JDK 1.4's getStackTrace method is present 
124:                    Class[] paramsClasses = new Class[] {};
125:                    this .getClass().getMethod("getStackTrace", paramsClasses);
126:                    super .printStackTrace(s);
127:                } catch (Exception ex) {
128:                    // If that didn't work, print it out ourselves
129:                    // First print this exception's stack trace.
130:                    super .printStackTrace(s);
131:                    if (cause != null) {
132:                        // Print out the exception that caused this one.
133:                        // This will recurse if the cause is another HttpException.
134:                        s.print("Caused by: ");
135:                        cause.printStackTrace(s);
136:                    }
137:                }
138:            }
139:
140:            /**
141:             * Print this HttpException and its stack trace to the specified print writer.
142:             * 
143:             * @param s the <tt>PrintWriter</tt> to which the exception and its stack trace
144:             * should be written
145:             * 
146:             * @since 3.0
147:             */
148:            public void printStackTrace(PrintWriter s) {
149:                try {
150:                    // JDK 1.4 has a nice printStackTrace method that prints the cause's stack
151:                    // trace too and prunes out duplicate stack frames.  Call it if possible,
152:                    // which is determined by checking whether JDK 1.4's getStackTrace method is present 
153:                    Class[] paramsClasses = new Class[] {};
154:                    this .getClass().getMethod("getStackTrace", paramsClasses);
155:                    super .printStackTrace(s);
156:                } catch (Exception ex) {
157:                    // If that didn't work, print it out ourselves
158:                    // First print this exception's stack trace.
159:                    super .printStackTrace(s);
160:                    if (cause != null) {
161:                        // Print out the exception that caused this one.
162:                        // This will recurse if the cause is another HttpException.
163:                        s.print("Caused by: ");
164:                        cause.printStackTrace(s);
165:                    }
166:                }
167:            }
168:
169:            /**
170:             * Sets the text description of the reason for an exception.
171:             *
172:             * @param reason The reason for the exception.
173:             *
174:             * @deprecated HttpClient no longer uses this for itself.  It is only
175:             * provided for compatibility with existing clients, and will be removed
176:             * in a future release.
177:             */
178:            public void setReason(String reason) {
179:                this .reason = reason;
180:            }
181:
182:            /**
183:             * Get the text description of the reason for an exception.
184:             *
185:             * @deprecated HttpClient no longer uses this for itself.  It is only
186:             * provided for compatibility with existing clients, and will be removed
187:             * in a future release.
188:             */
189:            public String getReason() {
190:                return reason;
191:            }
192:
193:            /**
194:             * Sets the status code description of the reason for an exception.
195:             *
196:             * @param code The reason for the exception.  This is intended to be an
197:             *  HTTP status code.
198:             *
199:             * @deprecated HttpClient no longer uses this for itself.  It is only
200:             * provided for compatibility with existing clients, and will be removed
201:             * in a future release.
202:             */
203:            public void setReasonCode(int code) {
204:                reasonCode = code;
205:            }
206:
207:            /**
208:             * Get the status code description of the reason for an exception.
209:             *
210:             * @deprecated HttpClient no longer uses this for itself.  It is only
211:             * provided for compatibility with existing clients, and will be removed
212:             * in a future release.
213:             */
214:            public int getReasonCode() {
215:                return this .reasonCode;
216:            }
217:
218:            /**
219:             * A "reason" string provided for compatibility with older clients.
220:             *
221:             * @deprecated HttpClient no longer uses this field for itself.  It
222:             * is only provided for compatibility with existing clients.
223:             */
224:            private String reason;
225:
226:            /**
227:             * Reason code for compatibility with older clients.
228:             *
229:             * @deprecated  HttpClient no longer uses this field for itself.
230:             *  It is only provided for compatibility with existing clients.
231:             */
232:            private int reasonCode = HttpStatus.SC_OK;
233:
234:            /** The original Throwable representing the cause of this error */
235:            private final Throwable cause;
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.