KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > crypto > dsig > XMLSignatureException


1 /*
2  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3  */

4 /*
5  * $Id: XMLSignatureException.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
6  */

7 package javax.xml.crypto.dsig;
8
9 import java.io.PrintStream JavaDoc;
10 import java.io.PrintWriter JavaDoc;
11
12 /**
13  * Indicates an exceptional condition that occured during the XML
14  * signature generation or validation process.
15  *
16  * <p>An <code>XMLSignatureException</code> can contain a cause: another
17  * throwable that caused this <code>XMLSignatureException</code> to get thrown.
18  *
19  * @since 1.6
20  */

21 public class XMLSignatureException extends Exception JavaDoc {
22
23     private static final long serialVersionUID = -3438102491013869995L;
24
25     /**
26      * The throwable that caused this exception to get thrown, or null if this
27      * exception was not caused by another throwable or if the causative
28      * throwable is unknown.
29      *
30      * @serial
31      */

32     private Throwable JavaDoc cause;
33
34     /**
35      * Constructs a new <code>XMLSignatureException</code> with
36      * <code>null</code> as its detail message.
37      */

38     public XMLSignatureException() {
39         super();
40     }
41
42     /**
43      * Constructs a new <code>XMLSignatureException</code> with the specified
44      * detail message.
45      *
46      * @param message the detail message
47      */

48     public XMLSignatureException(String JavaDoc message) {
49         super(message);
50     }
51
52     /**
53      * Constructs a new <code>XMLSignatureException</code> with the
54      * specified detail message and cause.
55      * <p>Note that the detail message associated with
56      * <code>cause</code> is <i>not</i> automatically incorporated in
57      * this exception's detail message.
58      *
59      * @param message the detail message
60      * @param cause the cause (A <tt>null</tt> value is permitted, and
61      * indicates that the cause is nonexistent or unknown.)
62      */

63     public XMLSignatureException(String JavaDoc message, Throwable JavaDoc cause) {
64         super(message);
65         this.cause = cause;
66     }
67
68     /**
69      * Constructs a new <code>XMLSignatureException</code> with the specified
70      * cause and a detail message of
71      * <code>(cause==null ? null : cause.toString())</code>
72      * (which typically contains the class and detail message of
73      * <code>cause</code>).
74      *
75      * @param cause the cause (A <tt>null</tt> value is permitted, and
76      * indicates that the cause is nonexistent or unknown.)
77      */

78     public XMLSignatureException(Throwable JavaDoc cause) {
79         super(cause==null ? null : cause.toString());
80         this.cause = cause;
81     }
82
83     /**
84      * Returns the cause of this <code>XMLSignatureException</code> or
85      * <code>null</code> if the cause is nonexistent or unknown. (The
86      * cause is the throwable that caused this
87      * <code>XMLSignatureException</code> to get thrown.)
88      *
89      * @return the cause of this <code>XMLSignatureException</code> or
90      * <code>null</code> if the cause is nonexistent or unknown.
91      */

92     public Throwable JavaDoc getCause() {
93         return cause;
94     }
95
96     /**
97      * Prints this <code>XMLSignatureException</code>, its backtrace and
98      * the cause's backtrace to the standard error stream.
99      */

100     public void printStackTrace() {
101     super.printStackTrace();
102     if (cause != null) {
103         cause.printStackTrace();
104     }
105     }
106
107     /**
108      * Prints this <code>XMLSignatureException</code>, its backtrace and
109      * the cause's backtrace to the specified print stream.
110      *
111      * @param s <code>PrintStream</code> to use for output
112      */

113     public void printStackTrace(PrintStream JavaDoc s) {
114     super.printStackTrace(s);
115     if (cause != null) {
116         cause.printStackTrace(s);
117     }
118     }
119
120     /**
121      * Prints this <code>XMLSignatureException</code>, its backtrace and
122      * the cause's backtrace to the specified print writer.
123      *
124      * @param s <code>PrintWriter</code> to use for output
125      */

126     public void printStackTrace(PrintWriter JavaDoc s) {
127         super.printStackTrace(s);
128     if (cause != null) {
129         cause.printStackTrace(s);
130     }
131     }
132 }
133
Popular Tags