1
/* Copyright 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/
21
package nu.xom.canonical;
25
* Indicates problems with canonicalization.
28
* @author Elliotte Rusty Harold
32
public class CanonicalizationException extends RuntimeException {
35
private static final long serialVersionUID = 6935623053373600014L;
37
private Throwable cause;
42
* Creates a new <code>CanonicalizationException</code>
43
* with a detail message.
46
* @param message a string indicating the specific problem
48
public CanonicalizationException(String message) {
55
* Return the original cause that led to this exception,
56
* or null if there was no original exception.
59
* @return the root cause of this exception
61
public final Throwable getCause() {
66
// null is insufficient for detecting an uninitialized cause.
67
// The cause may be set to null which may not then be reset.
68
private boolean causeSet = false;
73
* Sets the root cause of this exception. This may
74
* only be called once. Subsequent calls throw an
75
* <code>IllegalStateException</code>.
79
* This method is unnecessary in Java 1.4 where it could easily be
80
* inherited from the superclass. However, including it here
81
* allows this method to be used in Java 1.3 and earlier.
84
* @param cause the root cause of this exception
86
* @return this <code>XMLException</code>
88
* @throws IllegalArgumentException if the cause is this exception
89
* (An exception cannot be its own cause.)
90
* @throws IllegalStateException if this method is called twice
92
public final Throwable initCause(Throwable cause) {
95
throw new IllegalStateException("Can't overwrite cause");
97
else if (cause == this) {
98
throw new IllegalArgumentException("Self-causation not permitted");
100
else this.cause = cause;