![JAR search and dependency download from the Maven repository](/logo.png)
javax.xml.registry.JAXRException Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html or
* glassfish/bootstrap/legal/CDDLv1.0.txt.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at glassfish/bootstrap/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
*/
package javax.xml.registry;
/**
* Signals that a JAXR exception has occurred. It contains no members other than the standard reason String.
*
* @see JAXRResponse
* @author Nicholas Kassem
* @author Mark Hapner
* @author Rajiv Mordani
* @author Farrukh Najmi
*/
public class JAXRException extends Exception implements JAXRResponse {
/**
* The Throwable that caused this JAXRException to occur.
* This is used when a JAXRException has a nested Throwable.
*/
protected Throwable cause;
/**
* Constructs a JAXRException
object with no
* reason or embedded Throwable.
*/
public JAXRException() {
super();
this.cause = null;
}
/**
* Constructs a JAXRException
object with the given
* String
as the reason for the exception being thrown.
*
* @param reason a description of what caused the exception
*/
public JAXRException(String reason) {
super(reason);
this.cause = null;
}
/**
* Constructs a JAXRException
object with the given
* String
as the reason for the exception being thrown
* and the given Throwable
object as an embedded
* Throwable.
*
* @param reason a description of what caused the exception
* @param cause a Throwable
object that is to
* be embedded in this JAXRException
object
*/
public JAXRException(String reason, Throwable cause) {
super(reason);
initCause(cause);
}
/**
* Constructs a JAXRException
object initialized
* with the given Throwable
object.
*
* @param cause the Throwable that caused this Exception
*/
public JAXRException(Throwable cause) {
super(cause.toString());
initCause(cause);
}
/**
* Returns the detail message for this JAXRException
* object.
*
* If there is an embedded Throwable, and if the
* JAXRException
object has no detail message of its
* own, this method will return the detail message from the embedded
* Throwable.
*
* @return the error or warning message for this
* JAXRException
or, if it has none, the
* message of the embedded Throwable, if there is one
*/
public String getMessage() {
String message = super.getMessage();
if (message == null && cause != null) {
return cause.getMessage();
} else {
return message;
}
}
/**
* Returns the Throwable embedded in this JAXRException
* if there is one. Otherwise, this method returns null
.
*
* @return the embedded Throwable or null
if there is
* none
*/
public Throwable getCause() {
return cause;
}
/**
* Initializes the cause of this throwable to the specified value.
* (The cause is the throwable that caused this throwable to get thrown.)
*
*
This method can be called at most once. It is generally called from
* within the constructor, or immediately after creating the
* throwable. If this throwable was created
* with {@link #JAXRException(Throwable)} or
* {@link #JAXRException(String,Throwable)}, this method cannot be
* called even once.
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A null value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @return a reference to this Throwable
instance.
* @throws IllegalArgumentException if cause
is this
* throwable. (A throwable cannot
* be its own cause.)
* @throws IllegalStateException if this throwable was
* created with {@link #JAXRException(Throwable)} or
* {@link #JAXRException(String,Throwable)}, or this
* method has already been called on this throwable.
*/
public synchronized Throwable initCause(Throwable cause) {
if(this.cause != null) {
throw new IllegalStateException("Can't override cause");
}
if(cause == this) {
throw new IllegalArgumentException("Self-causation not permitted");
}
this.cause = cause;
return this;
}
public String getRequestId(){
// Write your code here
return null;
}
public int getStatus(){
// Write your code here
return 0;
}
/**
* Returns true if a response is available, false otherwise.
* This is a polling method and must not block.
*/
public boolean isAvailable() throws JAXRException {
return true;
}
}