Source Code Cross Referenced for SOAPExceptionImpl.java in  » 6.0-JDK-Modules-com.sun » xml » com » sun » xml » internal » messaging » saaj » 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 » 6.0 JDK Modules com.sun » xml » com.sun.xml.internal.messaging.saaj 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: SOAPExceptionImpl.java,v 1.3 2006/01/27 12:49:17 vj135062 Exp $
003:         * $Revision: 1.3 $
004:         * $Date: 2006/01/27 12:49:17 $
005:         */
006:
007:        /*
008:         * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
009:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
010:         *
011:         * This code is free software; you can redistribute it and/or modify it
012:         * under the terms of the GNU General Public License version 2 only, as
013:         * published by the Free Software Foundation.  Sun designates this
014:         * particular file as subject to the "Classpath" exception as provided
015:         * by Sun in the LICENSE file that accompanied this code.
016:         *
017:         * This code is distributed in the hope that it will be useful, but WITHOUT
018:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
019:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
020:         * version 2 for more details (a copy is included in the LICENSE file that
021:         * accompanied this code).
022:         *
023:         * You should have received a copy of the GNU General Public License version
024:         * 2 along with this work; if not, write to the Free Software Foundation,
025:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
026:         *
027:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
028:         * CA 95054 USA or visit www.sun.com if you need additional information or
029:         * have any questions.
030:         */
031:        package com.sun.xml.internal.messaging.saaj;
032:
033:        import java.io.PrintStream;
034:        import java.io.PrintWriter;
035:
036:        import javax.xml.soap.SOAPException;
037:
038:        /**
039:         * An exception that signals that a SOAP exception has occurred. A
040:         * <code>SOAPExceptionImpl</code> object may contain a <code>String</code>
041:         * that gives the reason for the exception, an embedded
042:         * <code>Throwable</code> object, or both. This class provides methods
043:         * for retrieving reason messages and for retrieving the embedded
044:         * <code>Throwable</code> object.
045:         *
046:         * <P> Typical reasons for throwing a <code>SOAPExceptionImpl</code>
047:         * object are problems such as difficulty setting a header, not being
048:         * able to send a message, and not being able to get a connection with
049:         * the provider.  Reasons for embedding a <code>Throwable</code>
050:         * object include problems such as input/output errors or a parsing
051:         * problem, such as an error in parsing a header.
052:         */
053:        public class SOAPExceptionImpl extends SOAPException {
054:            private Throwable cause;
055:
056:            /**
057:             * Constructs a <code>SOAPExceptionImpl</code> object with no
058:             * reason or embedded <code>Throwable</code> object.
059:             */
060:            public SOAPExceptionImpl() {
061:                super ();
062:                this .cause = null;
063:            }
064:
065:            /**
066:             * Constructs a <code>SOAPExceptionImpl</code> object with the given
067:             * <code>String</code> as the reason for the exception being thrown.
068:             *
069:             * @param reason a description of what caused the exception
070:             */
071:            public SOAPExceptionImpl(String reason) {
072:                super (reason);
073:                this .cause = null;
074:            }
075:
076:            /**
077:             * Constructs a <code>SOAPExceptionImpl</code> object with the given
078:             * <code>String</code> as the reason for the exception being thrown
079:             * and the given <code>Throwable</code> object as an embedded
080:             * exception.
081:             *
082:             * @param reason a description of what caused the exception
083:             * @param cause a <code>Throwable</code> object that is to
084:             *        be embedded in this <code>SOAPExceptionImpl</code> object
085:             */
086:            public SOAPExceptionImpl(String reason, Throwable cause) {
087:                super (reason);
088:                initCause(cause);
089:            }
090:
091:            /**
092:             * Constructs a <code>SOAPExceptionImpl</code> object initialized
093:             * with the given <code>Throwable</code> object.
094:             */
095:            public SOAPExceptionImpl(Throwable cause) {
096:                super (cause.toString());
097:                initCause(cause);
098:            }
099:
100:            /**
101:             * Returns the detail message for this <code>SOAPExceptionImpl</code>
102:             * object.
103:             * <P>
104:             * If there is an embedded <code>Throwable</code> object, and if the 
105:             * <code>SOAPExceptionImpl</code> object has no detail message of its 
106:             * own, this method will return the detail message from the embedded 
107:             * <code>Throwable</code> object.
108:             *
109:             * @return the error or warning message for this 
110:             *         <code>SOAPExceptionImpl</code> or, if it has none, the 
111:             *         message of the embedded <code>Throwable</code> object,
112:             *         if there is one
113:             */
114:            public String getMessage() {
115:                String message = super .getMessage();
116:                if (message == null && cause != null) {
117:                    return cause.getMessage();
118:                } else {
119:                    return message;
120:                }
121:            }
122:
123:            /**
124:             * Returns the <code>Throwable</code> object embedded in this 
125:             * <code>SOAPExceptionImpl</code> if there is one. Otherwise, this method 
126:             * returns <code>null</code>.
127:             *
128:             * @return the embedded <code>Throwable</code> object or <code>null</code> 
129:             *         if there is none
130:             */
131:
132:            public Throwable getCause() {
133:                return cause;
134:            }
135:
136:            /**
137:             * Initializes the <code>cause</code> field of this <code>SOAPExceptionImpl</code> 
138:             * object with the given <code>Throwable</code> object.
139:             * <P>
140:             * This method can be called at most once.  It is generally called from
141:             * within the constructor or immediately after the constructor has
142:             * returned a new <code>SOAPExceptionImpl</code> object.
143:             * If this <code>SOAPExceptionImpl</code> object was created with the
144:             * constructor {@link #SOAPExceptionImpl(Throwable)} or
145:             * {@link #SOAPExceptionImpl(String,Throwable)}, meaning that its
146:             * <code>cause</code> field already has a value, this method cannot be 
147:             * called even once.
148:             *
149:             * @param  cause the <code>Throwable</code> object that caused this
150:             *         <code>SOAPExceptionImpl</code> object to be thrown.  The value of this
151:             *         parameter is saved for later retrieval by the
152:             *         {@link #getCause()} method.  A <tt>null</tt> value is
153:             *         permitted and indicates that the cause is nonexistent or
154:             *         unknown.
155:             * @return  a reference to this <code>SOAPExceptionImpl</code> instance
156:             * @throws IllegalArgumentException if <code>cause</code> is this
157:             *         <code>Throwable</code> object.  (A <code>Throwable</code> object
158:             *         cannot be its own cause.)
159:             * @throws IllegalStateException if this <code>SOAPExceptionImpl</code> object
160:             *         was created with {@link #SOAPExceptionImpl(Throwable)} or
161:             *         {@link #SOAPExceptionImpl(String,Throwable)}, or this 
162:             *         method has already been called on this <code>SOAPExceptionImpl</code>
163:             *         object
164:             */
165:            public synchronized Throwable initCause(Throwable cause) {
166:                if (this .cause != null) {
167:                    throw new IllegalStateException("Can't override cause");
168:                }
169:                if (cause == this ) {
170:                    throw new IllegalArgumentException(
171:                            "Self-causation not permitted");
172:                }
173:                this .cause = cause;
174:
175:                return this ;
176:            }
177:
178:            public void printStackTrace() {
179:                super .printStackTrace();
180:                if (cause != null) {
181:                    System.err.println("\nCAUSE:\n");
182:                    cause.printStackTrace();
183:                }
184:            }
185:
186:            public void printStackTrace(PrintStream s) {
187:                super .printStackTrace(s);
188:                if (cause != null) {
189:                    s.println("\nCAUSE:\n");
190:                    cause.printStackTrace(s);
191:                }
192:            }
193:
194:            public void printStackTrace(PrintWriter s) {
195:                super .printStackTrace(s);
196:                if (cause != null) {
197:                    s.println("\nCAUSE:\n");
198:                    cause.printStackTrace(s);
199:                }
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.