1
/* Copyright 2003-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
* Indicates an error as defined by the XPointer specification.
29
* @author Elliotte Rusty Harold
32
class XPointerException extends Exception {
35
private static final long serialVersionUID = -533329510409448717L;
37
private Throwable cause = null;
41
* Constructs an <code>XPointerException</code> with the
42
* specified detail message.
45
* @param message a string indicating the specific problem
47
XPointerException(String message) {
54
* Constructs an <code>XPointerException</code> with the
55
* specified detail message and root cause.
58
* @param message a string indicating the specific problem
59
* @param cause the initial exception which caused this
60
* <code>XPointerException</code>
62
XPointerException(String message, Throwable cause) {
70
* When an <code>IOException</code>,
71
* <code>MalformedURLException</code>, or other generic
72
* exception is thrown while processing an XML document
73
* for XPointer, it is customarily replaced
74
* by some form of <code>XPointerSyntaxException</code>.
75
* This method allows you to retrieve the original exception.
76
* It returns null if no such exception caused this
77
* <code>XPointerSyntaxException</code>.
80
* @return the underlying exception which
81
* caused this XPointerSyntaxException to be thrown
83
public Throwable getCause() {
88
// null is insufficient for detecting an uninitialized cause.
89
// The cause may be set to null which may not then be reset.
90
private boolean causeSet = false;
95
* When an <code>IOException</code>,
96
* <code>MalformedURLException</code>, or other generic exception
97
* is thrown while processing an XML document
98
* for XPointers, it is customarily replaced
99
* by some form of <code>XPointerException</code>.
100
* This method allows you to store the original exception.
103
* @param cause the root cause of this exception
105
* @return this <code>XPointerException</code>
107
* @throws IllegalArgumentException if the cause is this exception
108
* (An exception cannot be its own cause.)
109
* @throws IllegalStateException if this method is called twice
111
public Throwable initCause(Throwable cause) {
113
throw new IllegalStateException("Can't overwrite cause");
115
else if (cause == this) {
116
throw new IllegalArgumentException("Self-causation not permitted");
118
else this.cause = cause;