1
/* Copyright 2002-2005 Elliotte Rusty Harold
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of version 2.1 of the GNU Lesser General Public
5
License as published by the Free Software Foundation.
7
This library is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU Lesser General Public License for more details.
12
You should have received a copy of the GNU Lesser General Public
13
License along with this library; if not, write to the
14
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
15
Boston, MA 02111-1307 USA
17
You can contact Elliotte Rusty Harold by sending e-mail to
18
elharo@metalab.unc.edu. Please include the word "XOM" in the
19
subject line. The XOM home page is located at http://www.xom.nu/
22
package nu.xom.xinclude;
26
* The generic superclass for all checked exceptions that may be thrown
27
* as a result of a violation of XInclude's rules.
30
* @author Elliotte Rusty Harold
33
public class XIncludeException extends Exception {
36
private static final long serialVersionUID = 969926723618314277L;
42
* Constructs an <code>XIncludeException</code> with the specified
46
* @param message a string indicating the specific problem
48
public XIncludeException(String message) {
55
* Constructs an <code>XIncludeException</code> with the specified
56
* detail message and initial cause. The error message string
57
* <code>message</code> can later be retrieved by the
58
* <code>{@link java.lang.Throwable#getMessage}</code>
59
* method of class <code>java.lang.Throwable</code>.
62
* @param message a string indicating the specific problem
63
* @param cause the initial cause of the exception
65
public XIncludeException(String message, Throwable cause) {
73
* Creates a new <code>XIncludeException</code> with a detail
74
* message, line and column numbers, and the URI of the document
75
* that caused the exception.
78
* @param message a string indicating the specific problem
79
* @param uri the URI of the document that caused this exception
81
public XIncludeException(String message, String uri) {
89
* Returns the URI of the document that caused this exception.
90
* If the URI is not known, null is returned.
93
* @return URI of the document where the exception occurred
95
public String getURI() {
100
private Throwable cause;
105
* When an <code>IOException</code>,
106
* <code>MalformedURLException</code>, or other generic
107
* exception is thrown while processing an XML document
108
* for XIncludes, it is customarily replaced
109
* by some form of <code>XIncludeException</code>.
110
* This method allows you to retrieve the original exception.
111
* It returns null if no such exception caused this
112
* <code>XIncludeException</code>.
115
* @return the underlying exception which
116
* caused this XIncludeException to be thrown
118
public Throwable getCause() {
123
// null is insufficient for detecting an uninitialized cause.
124
// The cause may be set to null which may not then be reset.
125
private boolean causeSet = false;
130
* When an <code>IOException</code>,
131
* <code>MalformedURLException</code>, or other generic exception
132
* is thrown while processing an XML document
133
* for XIncludes, it is customarily replaced
134
* by some form of <code>XIncludeException</code>.
135
* This method allows you to store the original exception.
138
* @param cause the root cause of this exception
140
* @return this <code>XIncludeException</code>
142
* @throws IllegalArgumentException if the cause is this exception
143
* (An exception cannot be its own cause.)
144
* @throws IllegalStateException if this method is called twice
146
public Throwable initCause(Throwable cause) {
148
throw new IllegalStateException("Can't overwrite cause");
150
else if (cause == this) {
151
throw new IllegalArgumentException("Self-causation not permitted");
153
else this.cause = cause;
b'\\ No newline at end of file'