001 /*
002 * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 /*
026 * $Id: URIReferenceException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
027 */
028 package javax.xml.crypto;
029
030 import java.io.PrintStream;
031 import java.io.PrintWriter;
032 import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
033
034 /**
035 * Indicates an exceptional condition thrown while dereferencing a
036 * {@link URIReference}.
037 *
038 * <p>A <code>URIReferenceException</code> can contain a cause: another
039 * throwable that caused this <code>URIReferenceException</code> to get thrown.
040 *
041 * @author Sean Mullan
042 * @author JSR 105 Expert Group
043 * @since 1.6
044 * @see URIDereferencer#dereference(URIReference, XMLCryptoContext)
045 * @see RetrievalMethod#dereference(XMLCryptoContext)
046 */
047 public class URIReferenceException extends Exception {
048
049 private static final long serialVersionUID = 7173469703932561419L;
050
051 /**
052 * The throwable that caused this exception to get thrown, or null if this
053 * exception was not caused by another throwable or if the causative
054 * throwable is unknown.
055 *
056 * @serial
057 */
058 private Throwable cause;
059
060 private URIReference uriReference;
061
062 /**
063 * Constructs a new <code>URIReferenceException</code> with
064 * <code>null</code> as its detail message.
065 */
066 public URIReferenceException() {
067 super ();
068 }
069
070 /**
071 * Constructs a new <code>URIReferenceException</code> with the specified
072 * detail message.
073 *
074 * @param message the detail message
075 */
076 public URIReferenceException(String message) {
077 super (message);
078 }
079
080 /**
081 * Constructs a new <code>URIReferenceException</code> with the
082 * specified detail message and cause.
083 * <p>Note that the detail message associated with
084 * <code>cause</code> is <i>not</i> automatically incorporated in
085 * this exception's detail message.
086 *
087 * @param message the detail message
088 * @param cause the cause (A <tt>null</tt> value is permitted, and
089 * indicates that the cause is nonexistent or unknown.)
090 */
091 public URIReferenceException(String message, Throwable cause) {
092 super (message);
093 this .cause = cause;
094 }
095
096 /**
097 * Constructs a new <code>URIReferenceException</code> with the
098 * specified detail message, cause and <code>URIReference</code>.
099 * <p>Note that the detail message associated with
100 * <code>cause</code> is <i>not</i> automatically incorporated in
101 * this exception's detail message.
102 *
103 * @param message the detail message
104 * @param cause the cause (A <tt>null</tt> value is permitted, and
105 * indicates that the cause is nonexistent or unknown.)
106 * @param uriReference the <code>URIReference</code> that was being
107 * dereferenced when the error was encountered
108 * @throws NullPointerException if <code>uriReference</code> is
109 * <code>null</code>
110 */
111 public URIReferenceException(String message, Throwable cause,
112 URIReference uriReference) {
113 this (message, cause);
114 if (uriReference == null) {
115 throw new NullPointerException(
116 "uriReference cannot be null");
117 }
118 this .uriReference = uriReference;
119 }
120
121 /**
122 * Constructs a new <code>URIReferenceException</code> with the specified
123 * cause and a detail message of <code>(cause==null ? null :
124 * cause.toString())</code> (which typically contains the class and detail
125 * message of <code>cause</code>).
126 *
127 * @param cause the cause (A <tt>null</tt> value is permitted, and
128 * indicates that the cause is nonexistent or unknown.)
129 */
130 public URIReferenceException(Throwable cause) {
131 super (cause == null ? null : cause.toString());
132 this .cause = cause;
133 }
134
135 /**
136 * Returns the <code>URIReference</code> that was being dereferenced
137 * when the exception was thrown.
138 *
139 * @return the <code>URIReference</code> that was being dereferenced
140 * when the exception was thrown, or <code>null</code> if not specified
141 */
142 public URIReference getURIReference() {
143 return uriReference;
144 }
145
146 /**
147 * Returns the cause of this <code>URIReferenceException</code> or
148 * <code>null</code> if the cause is nonexistent or unknown. (The
149 * cause is the throwable that caused this
150 * <code>URIReferenceException</code> to get thrown.)
151 *
152 * @return the cause of this <code>URIReferenceException</code> or
153 * <code>null</code> if the cause is nonexistent or unknown.
154 */
155 public Throwable getCause() {
156 return cause;
157 }
158
159 /**
160 * Prints this <code>URIReferenceException</code>, its backtrace and
161 * the cause's backtrace to the standard error stream.
162 */
163 public void printStackTrace() {
164 super .printStackTrace();
165 //XXX print backtrace of cause
166 }
167
168 /**
169 * Prints this <code>URIReferenceException</code>, its backtrace and
170 * the cause's backtrace to the specified print stream.
171 *
172 * @param s <code>PrintStream</code> to use for output
173 */
174 public void printStackTrace(PrintStream s) {
175 super .printStackTrace(s);
176 //XXX print backtrace of cause
177 }
178
179 /**
180 * Prints this <code>URIReferenceException</code>, its backtrace and
181 * the cause's backtrace to the specified print writer.
182 *
183 * @param s <code>PrintWriter</code> to use for output
184 */
185 public void printStackTrace(PrintWriter s) {
186 super .printStackTrace(s);
187 //XXX print backtrace of cause
188 }
189 }
|