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


001:        /*
002:         * The contents of this file are subject to the terms
003:         * of the Common Development and Distribution License
004:         * (the "License").  You may not use this file except
005:         * in compliance with the License.
006:         *
007:         * You can obtain a copy of the license at
008:         * https://jwsdp.dev.java.net/CDDLv1.0.html
009:         * See the License for the specific language governing
010:         * permissions and limitations under the License.
011:         *
012:         * When distributing Covered Code, include this CDDL
013:         * HEADER in each file and include the License file at
014:         * https://jwsdp.dev.java.net/CDDLv1.0.html  If applicable,
015:         * add the following below this CDDL HEADER, with the
016:         * fields enclosed by brackets "[]" replaced with your
017:         * own identifying information: Portions Copyright [yyyy]
018:         * [name of copyright owner]
019:         */
020:        /*
021:         * $Id: SOAPExceptionImpl.java,v 1.2 2007/07/16 16:41:19 ofung Exp $
022:         * $Revision: 1.2 $
023:         * $Date: 2007/07/16 16:41:19 $
024:         */
025:
026:        /*
027:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
028:         * 
029:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
030:         * 
031:         * The contents of this file are subject to the terms of either the GNU
032:         * General Public License Version 2 only ("GPL") or the Common Development
033:         * and Distribution License("CDDL") (collectively, the "License").  You
034:         * may not use this file except in compliance with the License. You can obtain
035:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
036:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
037:         * language governing permissions and limitations under the License.
038:         * 
039:         * When distributing the software, include this License Header Notice in each
040:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
041:         * Sun designates this particular file as subject to the "Classpath" exception
042:         * as provided by Sun in the GPL Version 2 section of the License file that
043:         * accompanied this code.  If applicable, add the following below the License
044:         * Header, with the fields enclosed by brackets [] replaced by your own
045:         * identifying information: "Portions Copyrighted [year]
046:         * [name of copyright owner]"
047:         * 
048:         * Contributor(s):
049:         * 
050:         * If you wish your version of this file to be governed by only the CDDL or
051:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
052:         * elects to include this software in this distribution under the [CDDL or GPL
053:         * Version 2] license."  If you don't indicate a single choice of license, a
054:         * recipient has the option to distribute your version of this file under
055:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
056:         * its licensees as provided above.  However, if you add GPL Version 2 code
057:         * and therefore, elected the GPL Version 2 license, then the option applies
058:         * only if the new code is made subject to such option by the copyright
059:         * holder.
060:         */
061:        package com.sun.xml.messaging.saaj;
062:
063:        import java.io.PrintStream;
064:        import java.io.PrintWriter;
065:
066:        import javax.xml.soap.SOAPException;
067:
068:        /**
069:         * An exception that signals that a SOAP exception has occurred. A
070:         * <code>SOAPExceptionImpl</code> object may contain a <code>String</code>
071:         * that gives the reason for the exception, an embedded
072:         * <code>Throwable</code> object, or both. This class provides methods
073:         * for retrieving reason messages and for retrieving the embedded
074:         * <code>Throwable</code> object.
075:         *
076:         * <P> Typical reasons for throwing a <code>SOAPExceptionImpl</code>
077:         * object are problems such as difficulty setting a header, not being
078:         * able to send a message, and not being able to get a connection with
079:         * the provider.  Reasons for embedding a <code>Throwable</code>
080:         * object include problems such as input/output errors or a parsing
081:         * problem, such as an error in parsing a header.
082:         */
083:        public class SOAPExceptionImpl extends SOAPException {
084:            private Throwable cause;
085:
086:            /**
087:             * Constructs a <code>SOAPExceptionImpl</code> object with no
088:             * reason or embedded <code>Throwable</code> object.
089:             */
090:            public SOAPExceptionImpl() {
091:                super ();
092:                this .cause = null;
093:            }
094:
095:            /**
096:             * Constructs a <code>SOAPExceptionImpl</code> object with the given
097:             * <code>String</code> as the reason for the exception being thrown.
098:             *
099:             * @param reason a description of what caused the exception
100:             */
101:            public SOAPExceptionImpl(String reason) {
102:                super (reason);
103:                this .cause = null;
104:            }
105:
106:            /**
107:             * Constructs a <code>SOAPExceptionImpl</code> object with the given
108:             * <code>String</code> as the reason for the exception being thrown
109:             * and the given <code>Throwable</code> object as an embedded
110:             * exception.
111:             *
112:             * @param reason a description of what caused the exception
113:             * @param cause a <code>Throwable</code> object that is to
114:             *        be embedded in this <code>SOAPExceptionImpl</code> object
115:             */
116:            public SOAPExceptionImpl(String reason, Throwable cause) {
117:                super (reason);
118:                initCause(cause);
119:            }
120:
121:            /**
122:             * Constructs a <code>SOAPExceptionImpl</code> object initialized
123:             * with the given <code>Throwable</code> object.
124:             */
125:            public SOAPExceptionImpl(Throwable cause) {
126:                super (cause.toString());
127:                initCause(cause);
128:            }
129:
130:            /**
131:             * Returns the detail message for this <code>SOAPExceptionImpl</code>
132:             * object.
133:             * <P>
134:             * If there is an embedded <code>Throwable</code> object, and if the 
135:             * <code>SOAPExceptionImpl</code> object has no detail message of its 
136:             * own, this method will return the detail message from the embedded 
137:             * <code>Throwable</code> object.
138:             *
139:             * @return the error or warning message for this 
140:             *         <code>SOAPExceptionImpl</code> or, if it has none, the 
141:             *         message of the embedded <code>Throwable</code> object,
142:             *         if there is one
143:             */
144:            public String getMessage() {
145:                String message = super .getMessage();
146:                if (message == null && cause != null) {
147:                    return cause.getMessage();
148:                } else {
149:                    return message;
150:                }
151:            }
152:
153:            /**
154:             * Returns the <code>Throwable</code> object embedded in this 
155:             * <code>SOAPExceptionImpl</code> if there is one. Otherwise, this method 
156:             * returns <code>null</code>.
157:             *
158:             * @return the embedded <code>Throwable</code> object or <code>null</code> 
159:             *         if there is none
160:             */
161:
162:            public Throwable getCause() {
163:                return cause;
164:            }
165:
166:            /**
167:             * Initializes the <code>cause</code> field of this <code>SOAPExceptionImpl</code> 
168:             * object with the given <code>Throwable</code> object.
169:             * <P>
170:             * This method can be called at most once.  It is generally called from
171:             * within the constructor or immediately after the constructor has
172:             * returned a new <code>SOAPExceptionImpl</code> object.
173:             * If this <code>SOAPExceptionImpl</code> object was created with the
174:             * constructor {@link #SOAPExceptionImpl(Throwable)} or
175:             * {@link #SOAPExceptionImpl(String,Throwable)}, meaning that its
176:             * <code>cause</code> field already has a value, this method cannot be 
177:             * called even once.
178:             *
179:             * @param  cause the <code>Throwable</code> object that caused this
180:             *         <code>SOAPExceptionImpl</code> object to be thrown.  The value of this
181:             *         parameter is saved for later retrieval by the
182:             *         {@link #getCause()} method.  A <tt>null</tt> value is
183:             *         permitted and indicates that the cause is nonexistent or
184:             *         unknown.
185:             * @return  a reference to this <code>SOAPExceptionImpl</code> instance
186:             * @throws IllegalArgumentException if <code>cause</code> is this
187:             *         <code>Throwable</code> object.  (A <code>Throwable</code> object
188:             *         cannot be its own cause.)
189:             * @throws IllegalStateException if this <code>SOAPExceptionImpl</code> object
190:             *         was created with {@link #SOAPExceptionImpl(Throwable)} or
191:             *         {@link #SOAPExceptionImpl(String,Throwable)}, or this 
192:             *         method has already been called on this <code>SOAPExceptionImpl</code>
193:             *         object
194:             */
195:            public synchronized Throwable initCause(Throwable cause) {
196:                if (this .cause != null) {
197:                    throw new IllegalStateException("Can't override cause");
198:                }
199:                if (cause == this ) {
200:                    throw new IllegalArgumentException(
201:                            "Self-causation not permitted");
202:                }
203:                this .cause = cause;
204:
205:                return this ;
206:            }
207:
208:            public void printStackTrace() {
209:                super .printStackTrace();
210:                if (cause != null) {
211:                    System.err.println("\nCAUSE:\n");
212:                    cause.printStackTrace();
213:                }
214:            }
215:
216:            public void printStackTrace(PrintStream s) {
217:                super .printStackTrace(s);
218:                if (cause != null) {
219:                    s.println("\nCAUSE:\n");
220:                    cause.printStackTrace(s);
221:                }
222:            }
223:
224:            public void printStackTrace(PrintWriter s) {
225:                super .printStackTrace(s);
226:                if (cause != null) {
227:                    s.println("\nCAUSE:\n");
228:                    cause.printStackTrace(s);
229:                }
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.