de.kosi.util
Class ExceptionHandler

java.lang.Object
  |
  +--de.kosi.util.ExceptionHandler
Direct Known Subclasses:
SwingExceptionHandler

public abstract class ExceptionHandler
extends java.lang.Object

The ExceptionHandlers implements a ''Chain of Responibility'' pattern for Exceptions. When the handleException() of a ExceptionHandler is called, it should either handle the Exception by itself, or invoke its parent handler. The last handler in the chain is a PrintExceptionHandler, that does nothing but print the Exception to System.err. To handle an Exception using the default exceptionhandler ExceptionHandler.handle() is called. This should be the default way of handling an exception, if no concrete handler is available.

ChangeLog:

 $Log: ExceptionHandler.java,v $
 Revision 1.2  2001/06/04 14:21:10  jiriki
 Made source more comliant to coding guidelines.

 Revision 1.1.1.1  2001/04/29 18:05:20  jiriki
 Imported sources from zola.

 Revision 1.1  2001/04/29 16:50:44  wombat
 Added ExceptionHandlers

 

Version:
$Revision: 1.2 $ ($Date: 2001/06/04 14:21:10 $)
Author:
Niklas Mehner

Constructor Summary
ExceptionHandler()
          Create a new ExceptionHandler with the default exception handler as parent.
ExceptionHandler(ExceptionHandler parent)
          Create a new ExceptionHandler with the given parent.
 
Method Summary
static void addDefaultExceptionHandler(ExceptionHandler handler)
          Add an ExceptionHandler to the ''Chain of Responsibility'' of ExceptionHandler.
protected  ExceptionHandler getParent()
          Get the parent handler of this handler.
static void handle(java.lang.Throwable e)
          Handle an Exception.
abstract  void handleException(java.lang.Throwable e)
          Handle an Throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionHandler

public ExceptionHandler()
Create a new ExceptionHandler with the default exception handler as parent.

ExceptionHandler

public ExceptionHandler(ExceptionHandler parent)
Create a new ExceptionHandler with the given parent.
Parameters:
parent - Parent handler.
Method Detail

handleException

public abstract void handleException(java.lang.Throwable e)
Handle an Throwable. This method is abstract and has to be implemented by concrete subclasses of ExceptionHandler. Implementations of this method have to call parent.handleException() if the cannot handle the Exception themselves.
Parameters:
e - Throwable to be handled.

getParent

protected ExceptionHandler getParent()
Get the parent handler of this handler.
Returns:
The parent handler.

handle

public static void handle(java.lang.Throwable e)
Handle an Exception. This invokes the handleException() of the default exception handler.
Parameters:
e - The Exception to be handled.

addDefaultExceptionHandler

public static void addDefaultExceptionHandler(ExceptionHandler handler)
Add an ExceptionHandler to the ''Chain of Responsibility'' of ExceptionHandler. New ExceptionHandlers are added at the beginning of the chain, so they first get the chance to handle an Exception.
Parameters:
handler - The ExceptionHandler to be added.