Source Code Cross Referenced for DodsBaseExceptionUtil.java in  » J2EE » Enhydra-Application-Framework » org » enhydra » dods » exceptions » 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 » org.enhydra.dods.exceptions 
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: DodsBaseExceptionUtil.java,v 1.1 2007-01-24 16:59:09 sinisa Exp $
022:         *
023:         * formatted with JxBeauty (c) johann.langhofer@nextra.at
024:         */
025:
026:        package org.enhydra.dods.exceptions;
027:
028:        import java.io.*;
029:
030:        /**
031:         * Utilities used to implement the DodsBaseException.
032:         */
033:        // compliance with WEBDOCWF begin
034:        // WebDocWf extension
035:        // The following line has been changed:
036:        public class DodsBaseExceptionUtil {
037:
038:            // before : class ChainedThrowableUtil {
039:            // end of WebDocWf extension
040:            // original line
041:            // class ChainedThrowableUtil {
042:            // compliance with WEBDOCWF end
043:            /**
044:             * Can't makes instances.
045:             */
046:            private DodsBaseExceptionUtil() {
047:            }
048:
049:            /**
050:             * Generate the message to set for the exception message.
051:             * When not explicit message is supplied.
052:             */
053:            // compliance with WEBDOCWF begin
054:            // WebDocWf extension
055:            // The following line has been changed:
056:            public static String makeMessage(Throwable cause) {
057:                // before:     protected static String makeMessage(Throwable cause) {
058:                // end of WebDocWf extension
059:                // original line
060:                //protected static String makeMessage(Throwable cause) {
061:                // compliance with WEBDOCWF end
062:                String causeMsg = cause.getMessage();
063:                if (causeMsg == null) {
064:                    return cause.getClass().getName();
065:                } else {
066:                    return causeMsg;
067:                }
068:            }
069:
070:            /**
071:             * Get the message associated with this exception.
072:             */
073:            // compliance with WEBDOCWF begin
074:            // WebDocWf extension
075:            // The following line has been changed:
076:            public static String getMessage(DodsBaseException except,
077:                    String super Msg) {
078:                //before:    protected static String getMessage(DodsBaseException except, String superMsg) {
079:                // end of WebDocWf extension
080:                // original line
081:                // protected static String getMessage(DodsBaseException except,
082:                // String superMsg) {
083:                // compliance with WEBDOCWF end
084:                Throwable cause = except.getCause();
085:                if (cause == null) {
086:                    return super Msg;
087:                } else {
088:                    String causeMsg = cause.getMessage();
089:                    if ((causeMsg == null) || (causeMsg.length() == 0)) {
090:                        causeMsg = cause.getClass().getName();
091:                    }
092:                    return super Msg + ": " + causeMsg;
093:                }
094:            }
095:
096:            /**
097:             * Do work of printing the causes of a chained exception.  This is
098:             * recursive. This attempts to following causing exceptions that are
099:             * chained in other types of exception objects.  If only Sun would
100:             * standardize a mechanism in throwable instead of letting it accumulate
101:             * in an ad-hoc manner.
102:             */
103:            private static void printChainedCauses(Throwable cause,
104:                    PrintWriter out) {
105:                if (cause != null) {
106:                    out.println("*** Caused by:");
107:                    cause.printStackTrace(out);
108:                    if (cause instanceof  DodsBaseException) {
109:                        // If cause was is a DodsBaseException, its chain has already
110:                        // been followed, otherwise, see what we can do.
111:                    } else if (cause instanceof  java.awt.print.PrinterIOException) {
112:                        printChainedCauses(
113:                                ((java.awt.print.PrinterIOException) cause)
114:                                        .getIOException(), out);
115:                    } else if (cause instanceof  java.io.WriteAbortedException) {
116:                        printChainedCauses(
117:                                ((java.io.WriteAbortedException) cause).detail,
118:                                out);
119:                    } else if (cause instanceof  java.lang.ClassNotFoundException) {
120:                        printChainedCauses(
121:                                ((java.lang.ClassNotFoundException) cause)
122:                                        .getException(), out);
123:                    } else if (cause instanceof  java.lang.ExceptionInInitializerError) {
124:                        printChainedCauses(
125:                                ((java.lang.ExceptionInInitializerError) cause)
126:                                        .getException(), out);
127:                    } else if (cause instanceof  java.lang.reflect.InvocationTargetException) {
128:                        printChainedCauses(
129:                                ((java.lang.reflect.InvocationTargetException) cause)
130:                                        .getTargetException(), out);
131:                    } else if (cause instanceof  java.rmi.RemoteException) {
132:                        printChainedCauses(
133:                                ((java.rmi.RemoteException) cause).detail, out);
134:                    } else if (cause instanceof  java.rmi.activation.ActivationException) {
135:                        printChainedCauses(
136:                                ((java.rmi.activation.ActivationException) cause).detail,
137:                                out);
138:                    } else if (cause instanceof  java.rmi.server.ServerCloneException) {
139:                        printChainedCauses(
140:                                ((java.rmi.server.ServerCloneException) cause).detail,
141:                                out);
142:                    } else if (cause instanceof  java.security.PrivilegedActionException) {
143:                        printChainedCauses(
144:                                ((java.security.PrivilegedActionException) cause)
145:                                        .getException(), out);
146:                    } else if (cause instanceof  java.sql.SQLException) {
147:                        printChainedCauses(((java.sql.SQLException) cause)
148:                                .getNextException(), out);
149:                    } else if (cause instanceof  org.xml.sax.SAXException) {
150:                        printChainedCauses(((org.xml.sax.SAXException) cause)
151:                                .getException(), out);
152:                    }
153:                }
154:            }
155:
156:            /**
157:             * Prints stacktrace and cause stacktrace.
158:             */
159:            // compliance with WEBDOCWF begin
160:            // WebDocWf extension
161:            // The following line has been changed:
162:            public static void printCauseTrace(DodsBaseException except) {
163:                //before:    protected static void printCauseTrace(DodsBaseException except) {
164:                // end of WebDocWf extension
165:                // original line
166:                // protected static void printCauseTrace(DodsBaseException except) {
167:                // compliance with WEBDOCWF end
168:                PrintWriter pw = new PrintWriter(System.err);
169:                printChainedCauses(except.getCause(), pw);
170:                pw.flush();
171:            }
172:
173:            /**
174:             * Prints stacktrace and cause stacktrace.
175:             */
176:            // compliance with WEBDOCWF begin
177:            // WebDocWf extension
178:            // The following line has been changed:
179:            public static void printCauseTrace(DodsBaseException except,
180:                    PrintStream s) {
181:                //before:    protected static void printCauseTrace(DodsBaseException except, PrintStream s) {
182:                // end of WebDocWf extension
183:                // original line
184:                // protected static void printCauseTrace(DodsBaseException except,
185:                //PrintStream s) {
186:                // compliance with WEBDOCWF end
187:                PrintWriter pw = new PrintWriter(s);
188:                printChainedCauses(except.getCause(), pw);
189:                pw.flush();
190:            }
191:
192:            /**
193:             * Prints stacktrace and cause stacktrace.
194:             */
195:            public static void printCauseTrace(DodsBaseException except,
196:                    PrintWriter out) {
197:                printChainedCauses(except.getCause(), out);
198:                out.flush();
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.