com.microstar.xml
Class XmlException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.microstar.xml.XmlException
All Implemented Interfaces:
java.io.Serializable

public class XmlException
extends java.lang.Exception

Convenience exception class for reporting XML parsing errors.

This is an exception class that you can use to encapsulate all of the information from Ælfred's error callback. This is not necessary for routine use of Ælfred, but it is used by the optional HandlerBase class.

Note that the core Ælfred classes do not use this exception.

JDK1.4 supports exception chaining. We are implementing a version of exception chaining here ourselves so that we can use JVMs earlier than JDK1.4.

In this implementation, we have the following differences from the JDK1.4 exception chaining implementation:

  • In this implementation, the detail message includes the detail message from the cause argument.
  • In this implementation, we implement a protected _setCause() method, but not the public initCause() method that JDK1.4 has
  • Since:
    Ptolemy II 0.2
    Version:
    1.1
    Author:
    Copyright (c) 1998 by Microstar Software Ltd., written by David Megginson <dmeggins@microstar.com>, Exception Chaining added by Christopher Hylands
    See Also:
    XmlHandler.error(java.lang.String, java.lang.String, int, int), HandlerBase, Serialized Form

    Field Summary
    private  java.lang.Throwable _cause
               
    private  int _column
               
    private  int _line
               
    private  java.lang.String _message
               
    private  java.lang.String _systemId
               
     
    Constructor Summary
    XmlException(java.lang.String message, java.lang.String systemId)
              Construct a new XML parsing exception.
    XmlException(java.lang.String message, java.lang.String systemId, int line, int column)
              Construct a new XML parsing exception.
    XmlException(java.lang.String message, java.lang.String systemId, int line, int column, java.lang.Throwable cause)
              Construct a new XML parsing exception.
     
    Method Summary
     java.lang.Throwable getCause()
              Get the cause of this exception.
     int getColumn()
              Get the column number containing the error.
     int getLine()
              Get the line number containing the error.
     java.lang.String getMessage()
              Get the error message from the parser.
     java.lang.String getSystemId()
              Get the URI of the entity containing the error.
     void printStackTrace()
              Print the following to stderr: this exception, its stack trace and if the cause exception is known, print the cause exception and the cause stacktrace.
     void printStackTrace(java.io.PrintStream printStream)
              Print this exception, its stack trace and if the cause exception is known, print the cause exception and the cause stacktrace.
     void printStackTrace(java.io.PrintWriter printWriter)
              Print this exception, its stack trace and if the cause exception is known, print the cause exception and the cause stacktrace.
    static java.lang.String stackTraceToString(java.lang.Throwable throwable)
              Return the stack trace of the given argument as a String.
     
    Methods inherited from class java.lang.Throwable
    fillInStackTrace, getLocalizedMessage, getStackTrace, initCause, setStackTrace, toString
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    _message

    private java.lang.String _message

    _cause

    private java.lang.Throwable _cause

    _systemId

    private java.lang.String _systemId

    _line

    private int _line

    _column

    private int _column
    Constructor Detail

    XmlException

    public XmlException(java.lang.String message,
                        java.lang.String systemId)
    Construct a new XML parsing exception.

    Parameters:
    message - The error message from the parser.
    systemId - The URI of the entity containing the error.

    XmlException

    public XmlException(java.lang.String message,
                        java.lang.String systemId,
                        int line,
                        int column)
    Construct a new XML parsing exception.

    Parameters:
    message - The error message from the parser.
    systemId - The URI of the entity containing the error.
    line - The line number where the error appeared.
    column - The column number where the error appeared.

    XmlException

    public XmlException(java.lang.String message,
                        java.lang.String systemId,
                        int line,
                        int column,
                        java.lang.Throwable cause)
    Construct a new XML parsing exception.

    Parameters:
    message - The error message from the parser.
    systemId - The URI of the entity containing the error.
    line - The line number where the error appeared.
    column - The column number where the error appeared.
    cause - The cause of this exception, if any
    Method Detail

    getCause

    public java.lang.Throwable getCause()
    Get the cause of this exception.

    Overrides:
    getCause in class java.lang.Throwable
    Returns:
    The cause that was passed in as an argument to the constructor, or null of no cause was specified.

    getMessage

    public java.lang.String getMessage()
    Get the error message from the parser.

    Overrides:
    getMessage in class java.lang.Throwable
    Returns:
    A string describing the error.

    getSystemId

    public java.lang.String getSystemId()
    Get the URI of the entity containing the error.

    Returns:
    The URI as a string.

    getLine

    public int getLine()
    Get the line number containing the error.

    Returns:
    The line number as an integer.

    getColumn

    public int getColumn()
    Get the column number containing the error.

    Returns:
    The column number as an integer.

    printStackTrace

    public void printStackTrace()
    Print the following to stderr: this exception, its stack trace and if the cause exception is known, print the cause exception and the cause stacktrace.

    Overrides:
    printStackTrace in class java.lang.Throwable

    printStackTrace

    public void printStackTrace(java.io.PrintStream printStream)
    Print this exception, its stack trace and if the cause exception is known, print the cause exception and the cause stacktrace.

    Overrides:
    printStackTrace in class java.lang.Throwable
    Parameters:
    printStream - The PrintStream to write to.

    printStackTrace

    public void printStackTrace(java.io.PrintWriter printWriter)
    Print this exception, its stack trace and if the cause exception is known, print the cause exception and the cause stacktrace.

    Overrides:
    printStackTrace in class java.lang.Throwable
    Parameters:
    printWriter - The PrintWriter to write to.

    stackTraceToString

    public static java.lang.String stackTraceToString(java.lang.Throwable throwable)
    Return the stack trace of the given argument as a String. This method is useful if we are catching and rethrowing a throwable that does not take a throwable cause argument. For example, the XML parser exception does not take a cause argument, so we call this method instead. This method should be used instead of Throwable.printStackTrace(), which prints the stack trace to stderr, which is likely to be hidden if we are running a Ptolemy application from anything but a shell console.

    Parameters:
    throwable - A throwable.
    Returns:
    The stack trace of the throwable.