286N/A/*
286N/A * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/A// SAX exception class.
286N/A// http://www.saxproject.org
286N/A// No warranty; no copyright -- use this as you will.
286N/A// $Id: SAXException.java,v 1.3 2004/11/03 22:55:32 jsuttor Exp $
286N/A
286N/Apackage org.xml.sax;
286N/A
286N/A/**
286N/A * Encapsulate a general SAX error or warning.
286N/A *
286N/A * <blockquote>
286N/A * <em>This module, both source code and documentation, is in the
286N/A * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
286N/A * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
286N/A * for further information.
286N/A * </blockquote>
286N/A *
286N/A * <p>This class can contain basic error or warning information from
286N/A * either the XML parser or the application: a parser writer or
286N/A * application writer can subclass it to provide additional
286N/A * functionality. SAX handlers may throw this exception or
286N/A * any exception subclassed from it.</p>
286N/A *
286N/A * <p>If the application needs to pass through other types of
286N/A * exceptions, it must wrap those exceptions in a SAXException
286N/A * or an exception derived from a SAXException.</p>
286N/A *
286N/A * <p>If the parser or application needs to include information about a
286N/A * specific location in an XML document, it should use the
286N/A * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
286N/A *
286N/A * @since SAX 1.0
286N/A * @author David Megginson
286N/A * @version 2.0.1 (sax2r2)
286N/A * @see org.xml.sax.SAXParseException
286N/A */
286N/Apublic class SAXException extends Exception {
286N/A
286N/A
286N/A /**
286N/A * Create a new SAXException.
286N/A */
286N/A public SAXException ()
286N/A {
286N/A super();
286N/A this.exception = null;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * Create a new SAXException.
286N/A *
286N/A * @param message The error or warning message.
286N/A */
286N/A public SAXException (String message) {
286N/A super(message);
286N/A this.exception = null;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * Create a new SAXException wrapping an existing exception.
286N/A *
286N/A * <p>The existing exception will be embedded in the new
286N/A * one, and its message will become the default message for
286N/A * the SAXException.</p>
286N/A *
286N/A * @param e The exception to be wrapped in a SAXException.
286N/A */
286N/A public SAXException (Exception e)
286N/A {
286N/A super();
286N/A this.exception = e;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * Create a new SAXException from an existing exception.
286N/A *
286N/A * <p>The existing exception will be embedded in the new
286N/A * one, but the new exception will have its own message.</p>
286N/A *
286N/A * @param message The detail message.
286N/A * @param e The exception to be wrapped in a SAXException.
286N/A */
286N/A public SAXException (String message, Exception e)
286N/A {
286N/A super(message);
286N/A this.exception = e;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * Return a detail message for this exception.
286N/A *
286N/A * <p>If there is an embedded exception, and if the SAXException
286N/A * has no detail message of its own, this method will return
286N/A * the detail message from the embedded exception.</p>
286N/A *
286N/A * @return The error or warning message.
286N/A */
286N/A public String getMessage ()
286N/A {
286N/A String message = super.getMessage();
286N/A
286N/A if (message == null && exception != null) {
286N/A return exception.getMessage();
286N/A } else {
286N/A return message;
286N/A }
286N/A }
286N/A
286N/A
286N/A /**
286N/A * Return the embedded exception, if any.
286N/A *
286N/A * @return The embedded exception, or null if there is none.
286N/A */
286N/A public Exception getException ()
286N/A {
286N/A return exception;
286N/A }
286N/A
286N/A /**
286N/A * Return the cause of the exception
286N/A *
286N/A * @return Return the cause of the exception
286N/A */
286N/A public Throwable getCause() {
286N/A return exception;
286N/A }
286N/A
286N/A /**
286N/A * Override toString to pick up any embedded exception.
286N/A *
286N/A * @return A string representation of this exception.
286N/A */
286N/A public String toString ()
286N/A {
286N/A if (exception != null) {
286N/A return super.toString() + "\n" + exception.toString();
286N/A } else {
286N/A return super.toString();
286N/A }
286N/A }
286N/A
286N/A
286N/A
286N/A //////////////////////////////////////////////////////////////////////
286N/A // Internal state.
286N/A //////////////////////////////////////////////////////////////////////
286N/A
286N/A
286N/A /**
286N/A * @serial The embedded exception if tunnelling, or null.
286N/A */
286N/A private Exception exception;
286N/A
286N/A // Added serialVersionUID to preserve binary compatibility
286N/A static final long serialVersionUID = 583241635256073760L;
286N/A}
286N/A
286N/A// end of SAXException.java