|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DocumentException.java | 12,5% | 18,2% | 22,2% | 17,9% |
|
1 | /* | |
2 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
3 | * | |
4 | * This software is open source. | |
5 | * See the bottom of this file for the licence. | |
6 | * | |
7 | * $Id: DocumentException.java,v 1.5 2004/06/25 08:03:33 maartenc Exp $ | |
8 | */ | |
9 | ||
10 | package org.dom4j; | |
11 | ||
12 | import java.io.PrintStream; | |
13 | import java.io.PrintWriter; | |
14 | ||
15 | /** <p><code>DocumentException</code> is a nested Exception which may be thrown | |
16 | * during the processing of a DOM4J document. | |
17 | * | |
18 | * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> | |
19 | * @version $Revision: 1.5 $ | |
20 | */ | |
21 | public class DocumentException extends Exception { | |
22 | ||
23 | /** A wrapped <code>Throwable</code> */ | |
24 | private Throwable nestedException; | |
25 | ||
26 | ||
27 | 0 | public DocumentException() { |
28 | 0 | super("Error occurred in DOM4J application."); |
29 | } | |
30 | ||
31 | 0 | public DocumentException(String message) { |
32 | 0 | super(message); |
33 | } | |
34 | ||
35 | 0 | public DocumentException(Throwable nestedException) { |
36 | 0 | super(nestedException.getMessage()); |
37 | 0 | this.nestedException = nestedException; |
38 | } | |
39 | ||
40 | 4 | public DocumentException(String message, Throwable nestedException) { |
41 | 4 | super(message); |
42 | 4 | this.nestedException = nestedException; |
43 | } | |
44 | ||
45 | 0 | public Throwable getNestedException() { |
46 | 0 | return nestedException; |
47 | } | |
48 | ||
49 | 2 | public String getMessage() { |
50 | 2 | if (nestedException != null) { |
51 | 2 | return super.getMessage() + " Nested exception: " + nestedException.getMessage(); |
52 | } else { | |
53 | 0 | return super.getMessage(); |
54 | } | |
55 | } | |
56 | ||
57 | 0 | public void printStackTrace() { |
58 | 0 | super.printStackTrace(); |
59 | 0 | if (nestedException != null) { |
60 | 0 | System.err.print("Nested exception: "); |
61 | 0 | nestedException.printStackTrace(); |
62 | } | |
63 | } | |
64 | ||
65 | 0 | public void printStackTrace(PrintStream out) { |
66 | 0 | super.printStackTrace(out); |
67 | 0 | if (nestedException != null) { |
68 | 0 | out.println("Nested exception: "); |
69 | 0 | nestedException.printStackTrace(out); |
70 | } | |
71 | } | |
72 | ||
73 | 0 | public void printStackTrace(PrintWriter writer) { |
74 | 0 | super.printStackTrace(writer); |
75 | 0 | if (nestedException != null) { |
76 | 0 | writer.println("Nested exception: "); |
77 | 0 | nestedException.printStackTrace(writer); |
78 | } | |
79 | } | |
80 | } | |
81 | ||
82 | ||
83 | ||
84 | ||
85 | /* | |
86 | * Redistribution and use of this software and associated documentation | |
87 | * ("Software"), with or without modification, are permitted provided | |
88 | * that the following conditions are met: | |
89 | * | |
90 | * 1. Redistributions of source code must retain copyright | |
91 | * statements and notices. Redistributions must also contain a | |
92 | * copy of this document. | |
93 | * | |
94 | * 2. Redistributions in binary form must reproduce the | |
95 | * above copyright notice, this list of conditions and the | |
96 | * following disclaimer in the documentation and/or other | |
97 | * materials provided with the distribution. | |
98 | * | |
99 | * 3. The name "DOM4J" must not be used to endorse or promote | |
100 | * products derived from this Software without prior written | |
101 | * permission of MetaStuff, Ltd. For written permission, | |
102 | * please contact dom4j-info@metastuff.com. | |
103 | * | |
104 | * 4. Products derived from this Software may not be called "DOM4J" | |
105 | * nor may "DOM4J" appear in their names without prior written | |
106 | * permission of MetaStuff, Ltd. DOM4J is a registered | |
107 | * trademark of MetaStuff, Ltd. | |
108 | * | |
109 | * 5. Due credit should be given to the DOM4J Project - | |
110 | * http://www.dom4j.org | |
111 | * | |
112 | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS | |
113 | * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT | |
114 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
115 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
116 | * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
117 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
118 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
119 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
120 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
121 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
122 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
123 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
124 | * | |
125 | * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. | |
126 | * | |
127 | * $Id: DocumentException.java,v 1.5 2004/06/25 08:03:33 maartenc Exp $ | |
128 | */ |
|