Source Code Cross Referenced for HarmoniseException.java in  » Content-Management-System » harmonise » org » openharmonise » rm » 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 » Content Management System » harmonise » org.openharmonise.rm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.rm;
020:
021:        import java.io.*;
022:
023:        import org.openharmonise.commons.xml.*;
024:        import org.openharmonise.rm.publishing.*;
025:        import org.openharmonise.rm.resources.publishing.*;
026:        import org.w3c.dom.*;
027:
028:        /**
029:         * Abstract base class for all exceptions thrown within Harmonise.
030:         * 
031:         * @author Michael Bell
032:         * @version $Revision: 1.1 $
033:         *
034:         */
035:        public abstract class HarmoniseException extends Exception implements 
036:                Publishable {
037:
038:            /**
039:             * Exception tag name
040:             */
041:            public static final String TAG_EXCEPTION = "Exception";
042:
043:            /**
044:             * Message tag name
045:             */
046:            public static final String TAG_MESSAGE = "Message";
047:
048:            /**
049:             * Stack trace tag name
050:             */
051:            public static final String TAG_STACKTRACE = "Stacktrace";
052:
053:            /**
054:             * Constructs an exception with no detail message and no cause
055:             *
056:             */
057:            public HarmoniseException() {
058:                super ();
059:            }
060:
061:            /**
062:             * Constructs an exception with the specified detail message and no
063:             * cause.
064:             * 
065:             * @param s the detail message
066:             */
067:            public HarmoniseException(String s) {
068:                super (s);
069:            }
070:
071:            /**
072:             * Constructs an exception with the specified detail message and
073:             * cause.
074:             * 
075:             * @param s the detail message
076:             * @param e the cause
077:             */
078:            public HarmoniseException(String s, Throwable e) {
079:                super (s, e);
080:            }
081:
082:            /**
083:             * Constructs an exception with the specified cause.
084:             * 
085:             * @param e the cause
086:             */
087:            public HarmoniseException(Throwable e) {
088:                super (e);
089:            }
090:
091:            /**
092:             * Prints the causes stack trace to the specified <code>PrintWriter</code>.
093:             * 
094:             * @param out the <code>PrintWriter</code>
095:             */
096:            public void printOriginalStackTrace(PrintWriter out) {
097:                if (getCause() != null) {
098:                    getCause().printStackTrace(out);
099:                }
100:            }
101:
102:            /**
103:             * Prints the causes stack trace to the specified <code>PrintStream</code>.
104:             * 
105:             * @param out the <code>PrintStream</code>
106:             */
107:            public void printOriginalStackTrace(PrintStream out) {
108:                if (getCause() != null) {
109:                    getCause().printStackTrace(out);
110:                }
111:            }
112:
113:            /**
114:             * Returns the XML element representation of this exception using the 
115:             * given <code>XMLDocument</code> as the owner <code>Document</code>.
116:             * 
117:             * @param xmlDoc the owner <code>Document</code>
118:             * @return the XML element representation of this exception
119:             */
120:            public Element publish(XMLDocument xmlDoc) {
121:                return publishThrowable(this , xmlDoc);
122:            }
123:
124:            /* (non-Javadoc)
125:             * @see org.openharmonise.rm.publishing.Publishable#publish(org.openharmonise.rm.resources.publishing.Template, org.openharmonise.rm.publishing.HarmoniseOutput, org.openharmonise.rm.publishing.State)
126:             */
127:            public Element publish(Template template, HarmoniseOutput output,
128:                    State state) throws PublishException {
129:                Element resultEl = null;
130:
131:                try {
132:                    resultEl = publish(template.getTemplateRootElement(),
133:                            output, state);
134:                } catch (DataAccessException e) {
135:                    throw new PublishException(e.getLocalizedMessage());
136:                }
137:
138:                return resultEl;
139:            }
140:
141:            /* (non-Javadoc)
142:             * @see org.openharmonise.rm.publishing.Publishable#publish(org.w3c.dom.Element, org.openharmonise.rm.publishing.HarmoniseOutput, org.openharmonise.rm.publishing.State)
143:             */
144:            public Element publish(Element topEl, HarmoniseOutput output,
145:                    State state) throws PublishException {
146:                return publish(output);
147:            }
148:
149:            /* (non-Javadoc)
150:             * @see org.openharmonise.rm.publishing.Publishable#populate(org.w3c.dom.Element, org.openharmonise.rm.publishing.State)
151:             */
152:            public void populate(Element xmlElement, State state)
153:                    throws PopulateException {
154:                //no need
155:
156:            }
157:
158:            /* (non-Javadoc)
159:             * @see org.openharmonise.rm.publishing.Publishable#getTagName()
160:             */
161:            public String getTagName() {
162:                return TAG_EXCEPTION;
163:            }
164:
165:            /**
166:             * Returns the XML element representation of the specified
167:             * <code>Throwable</code> using the given <code>XMLDocument</code>
168:             * as the owner <code>Document</code>.
169:             * 
170:             * @param thrown the <code>Throwable</code> object to publish
171:             * @param xmlDoc the owner <code>Document</code>
172:             * @return the XML element representation of the <code>Throwable</code>
173:             */
174:            private Element publishThrowable(Throwable thrown,
175:                    XMLDocument xmlDoc) {
176:                Element exEl = xmlDoc.createElement(TAG_EXCEPTION);
177:                Element msgEl = xmlDoc.createElement(TAG_MESSAGE);
178:                Element trcEl = xmlDoc.createElement(TAG_STACKTRACE);
179:                msgEl.appendChild(xmlDoc.createTextNode(thrown.getMessage()));
180:                exEl.appendChild(msgEl);
181:                StringWriter swriter = new StringWriter();
182:                PrintWriter out = new PrintWriter(swriter);
183:                thrown.printStackTrace(out);
184:                trcEl.appendChild(xmlDoc.createTextNode(swriter.toString()));
185:                out.close();
186:                exEl.appendChild(trcEl);
187:
188:                Throwable cause = thrown.getCause();
189:
190:                if (cause != null) {
191:                    exEl.appendChild(publishThrowable(cause, xmlDoc));
192:                }
193:
194:                return exEl;
195:            }
196:
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.