Source Code Cross Referenced for ChainedThrowableUtil.java in  » J2EE » Enhydra-Application-Framework » com » lutris » util » 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 » J2EE » Enhydra Application Framework » com.lutris.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         *
021:         * $Id: ChainedThrowableUtil.java,v 1.2 2006-06-15 13:47:00 sinisa Exp $
022:         *
023:         * formatted with JxBeauty (c) johann.langhofer@nextra.at
024:         */
025:
026:        package com.lutris.util;
027:
028:        import java.io.PrintStream;
029:        import java.io.PrintWriter;
030:
031:        /**
032:         * Utilities used to implement the Chained* throwables.
033:         */
034:        // compliance with WEBDOCWF begin
035:        // WebDocWf extension
036:        // The following line has been changed:
037:        public class ChainedThrowableUtil {
038:
039:            // before : class ChainedThrowableUtil {
040:            // end of WebDocWf extension
041:            // original line
042:            // class ChainedThrowableUtil {
043:            // compliance with WEBDOCWF end
044:            /**
045:             * Can't makes instances.
046:             */
047:            private ChainedThrowableUtil() {
048:            }
049:
050:            /**
051:             * Generate the message to set for the exception message.
052:             * When not explicit message is supplied.
053:             */
054:            // compliance with WEBDOCWF begin
055:            // WebDocWf extension
056:            // The following line has been changed:
057:            public static String makeMessage(Throwable cause) {
058:                // before:     protected static String makeMessage(Throwable cause) {
059:                // end of WebDocWf extension
060:                // original line
061:                //protected static String makeMessage(Throwable cause) {
062:                // compliance with WEBDOCWF end
063:                String causeMsg = cause.getMessage();
064:                if (causeMsg == null) {
065:                    return cause.getClass().getName();
066:                } else {
067:                    return causeMsg;
068:                }
069:            }
070:
071:            /**
072:             * Get the message associated with this exception.
073:             */
074:            // compliance with WEBDOCWF begin
075:            // WebDocWf extension
076:            // The following line has been changed:
077:            public static String getMessage(ChainedThrowable except,
078:                    String super Msg) {
079:                //before:    protected static String getMessage(ChainedThrowable except, String superMsg) {
080:                // end of WebDocWf extension
081:                // original line
082:                // protected static String getMessage(ChainedThrowable except,
083:                // String superMsg) {
084:                // compliance with WEBDOCWF end
085:                Throwable cause = except.getCause();
086:                if (cause == null) {
087:                    return super Msg;
088:                } else {
089:                    String causeMsg = cause.getMessage();
090:                    if ((causeMsg == null) || (causeMsg.length() == 0)) {
091:                        causeMsg = cause.getClass().getName();
092:                    }
093:                    return super Msg + ": " + causeMsg;
094:                }
095:            }
096:
097:            /**
098:             * Do work of printing the causes of a chained exception.  This is
099:             * recursive. This attempts to following causing exceptions that are
100:             * chained in other types of exception objects.  If only Sun would
101:             * standardize a mechanism in throwable instead of letting it accumulate
102:             * in an ad-hoc manner.
103:             */
104:            private static void printChainedCauses(Throwable cause,
105:                    PrintWriter out) {
106:                if (cause != null) {
107:                    out.println("*** Caused by:");
108:                    cause.printStackTrace(out);
109:                    if (cause instanceof  ChainedThrowable) {
110:                        // If cause was is a ChainedThrowable, its chain has already
111:                        // been followed, otherwise, see what we can do.
112:                    } else if (cause instanceof  java.awt.print.PrinterIOException) {
113:                        printChainedCauses(
114:                                ((java.awt.print.PrinterIOException) cause)
115:                                        .getIOException(), out);
116:                    } else if (cause instanceof  java.io.WriteAbortedException) {
117:                        printChainedCauses(
118:                                ((java.io.WriteAbortedException) cause).detail,
119:                                out);
120:                    } else if (cause instanceof  java.lang.ClassNotFoundException) {
121:                        printChainedCauses(
122:                                ((java.lang.ClassNotFoundException) cause)
123:                                        .getException(), out);
124:                    } else if (cause instanceof  java.lang.ExceptionInInitializerError) {
125:                        printChainedCauses(
126:                                ((java.lang.ExceptionInInitializerError) cause)
127:                                        .getException(), out);
128:                    } else if (cause instanceof  java.lang.reflect.InvocationTargetException) {
129:                        printChainedCauses(
130:                                ((java.lang.reflect.InvocationTargetException) cause)
131:                                        .getTargetException(), out);
132:                    } else if (cause instanceof  java.rmi.RemoteException) {
133:                        printChainedCauses(
134:                                ((java.rmi.RemoteException) cause).detail, out);
135:                    } else if (cause instanceof  java.rmi.activation.ActivationException) {
136:                        printChainedCauses(
137:                                ((java.rmi.activation.ActivationException) cause).detail,
138:                                out);
139:                    } else if (cause instanceof  java.rmi.server.ServerCloneException) {
140:                        printChainedCauses(
141:                                ((java.rmi.server.ServerCloneException) cause).detail,
142:                                out);
143:                    } else if (cause instanceof  java.security.PrivilegedActionException) {
144:                        printChainedCauses(
145:                                ((java.security.PrivilegedActionException) cause)
146:                                        .getException(), out);
147:                    } else if (cause instanceof  java.sql.SQLException) {
148:                        printChainedCauses(((java.sql.SQLException) cause)
149:                                .getNextException(), out);
150:                    } else if (cause instanceof  org.xml.sax.SAXException) {
151:                        printChainedCauses(((org.xml.sax.SAXException) cause)
152:                                .getException(), out);
153:                    }
154:                }
155:            }
156:
157:            /**
158:             * Prints stacktrace and cause stacktrace.
159:             */
160:            // compliance with WEBDOCWF begin
161:            // WebDocWf extension
162:            // The following line has been changed:
163:            public static void printCauseTrace(ChainedThrowable except) {
164:                //before:    protected static void printCauseTrace(ChainedThrowable except) {
165:                // end of WebDocWf extension
166:                // original line
167:                // protected static void printCauseTrace(ChainedThrowable except) {
168:                // compliance with WEBDOCWF end
169:                PrintWriter pw = new PrintWriter(System.err);
170:                printChainedCauses(except.getCause(), pw);
171:                pw.flush();
172:            }
173:
174:            /**
175:             * Prints stacktrace and cause stacktrace.
176:             */
177:            // compliance with WEBDOCWF begin
178:            // WebDocWf extension
179:            // The following line has been changed:
180:            public static void printCauseTrace(ChainedThrowable except,
181:                    PrintStream s) {
182:                //before:    protected static void printCauseTrace(ChainedThrowable except, PrintStream s) {
183:                // end of WebDocWf extension
184:                // original line
185:                // protected static void printCauseTrace(ChainedThrowable except,
186:                //PrintStream s) {
187:                // compliance with WEBDOCWF end
188:                PrintWriter pw = new PrintWriter(s);
189:                printChainedCauses(except.getCause(), pw);
190:                pw.flush();
191:            }
192:
193:            /**
194:             * Prints stacktrace and cause stacktrace.
195:             */
196:            public static void printCauseTrace(ChainedThrowable except,
197:                    PrintWriter out) {
198:                printChainedCauses(except.getCause(), out);
199:                out.flush();
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.