Path: blob/master/src/java.xml.crypto/share/classes/javax/xml/crypto/URIReferenceException.java
41159 views
/*1* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25* $Id: URIReferenceException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $26*/27package javax.xml.crypto;2829import java.io.PrintStream;30import java.io.PrintWriter;31import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;3233/**34* Indicates an exceptional condition thrown while dereferencing a35* {@link URIReference}.36*37* <p>A {@code URIReferenceException} can contain a cause: another38* throwable that caused this {@code URIReferenceException} to get thrown.39*40* @author Sean Mullan41* @author JSR 105 Expert Group42* @since 1.643* @see URIDereferencer#dereference(URIReference, XMLCryptoContext)44* @see RetrievalMethod#dereference(XMLCryptoContext)45*/46public class URIReferenceException extends Exception {4748private static final long serialVersionUID = 7173469703932561419L;4950/**51* The throwable that caused this exception to get thrown, or null if this52* exception was not caused by another throwable or if the causative53* throwable is unknown.54*55* @serial56*/57private Throwable cause;5859/**60* The {@code URIReference} that was being dereferenced61* when the exception was thrown, or {@code null} if not specified.62*/63private URIReference uriReference;6465/**66* Constructs a new {@code URIReferenceException} with67* {@code null} as its detail message.68*/69public URIReferenceException() {70super();71}7273/**74* Constructs a new {@code URIReferenceException} with the specified75* detail message.76*77* @param message the detail message78*/79public URIReferenceException(String message) {80super(message);81}8283/**84* Constructs a new {@code URIReferenceException} with the85* specified detail message and cause.86* <p>Note that the detail message associated with87* {@code cause} is <i>not</i> automatically incorporated in88* this exception's detail message.89*90* @param message the detail message91* @param cause the cause (A {@code null} value is permitted, and92* indicates that the cause is nonexistent or unknown.)93*/94public URIReferenceException(String message, Throwable cause) {95super(message);96this.cause = cause;97}9899/**100* Constructs a new {@code URIReferenceException} with the101* specified detail message, cause and {@code URIReference}.102* <p>Note that the detail message associated with103* {@code cause} is <i>not</i> automatically incorporated in104* this exception's detail message.105*106* @param message the detail message107* @param cause the cause (A {@code null} value is permitted, and108* indicates that the cause is nonexistent or unknown.)109* @param uriReference the {@code URIReference} that was being110* dereferenced when the error was encountered111* @throws NullPointerException if {@code uriReference} is112* {@code null}113*/114public URIReferenceException(String message, Throwable cause,115URIReference uriReference) {116this(message, cause);117if (uriReference == null) {118throw new NullPointerException("uriReference cannot be null");119}120this.uriReference = uriReference;121}122123/**124* Constructs a new {@code URIReferenceException} with the specified125* cause and a detail message of {@code (cause==null ? null :126* cause.toString())} (which typically contains the class and detail127* message of {@code cause}).128*129* @param cause the cause (A {@code null} value is permitted, and130* indicates that the cause is nonexistent or unknown.)131*/132public URIReferenceException(Throwable cause) {133super(cause==null ? null : cause.toString());134this.cause = cause;135}136137/**138* Returns the {@code URIReference} that was being dereferenced139* when the exception was thrown.140*141* @return the {@code URIReference} that was being dereferenced142* when the exception was thrown, or {@code null} if not specified143*/144public URIReference getURIReference() {145return uriReference;146}147148/**149* Returns the cause of this {@code URIReferenceException} or150* {@code null} if the cause is nonexistent or unknown. (The151* cause is the throwable that caused this152* {@code URIReferenceException} to get thrown.)153*154* @return the cause of this {@code URIReferenceException} or155* {@code null} if the cause is nonexistent or unknown.156*/157public Throwable getCause() {158return cause;159}160161/**162* Prints this {@code URIReferenceException}, its backtrace and163* the cause's backtrace to the standard error stream.164*/165public void printStackTrace() {166super.printStackTrace();167//XXX print backtrace of cause168}169170/**171* Prints this {@code URIReferenceException}, its backtrace and172* the cause's backtrace to the specified print stream.173*174* @param s {@code PrintStream} to use for output175*/176public void printStackTrace(PrintStream s) {177super.printStackTrace(s);178//XXX print backtrace of cause179}180181/**182* Prints this {@code URIReferenceException}, its backtrace and183* the cause's backtrace to the specified print writer.184*185* @param s {@code PrintWriter} to use for output186*/187public void printStackTrace(PrintWriter s) {188super.printStackTrace(s);189//XXX print backtrace of cause190}191}192193194