KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > lifecycle > ExceptionHandlers


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Mar 17, 2005
10  *
11  * Author Michelle Lei
12  * ZBS
13  */

14 package jfun.yan.lifecycle;
15
16 /**
17  * Facade class to provide some basic ExceptionHandler implementations.
18  * <p>
19  * Codehaus.org.
20  *
21  * @author Michelle Lei
22  *
23  */

24 public class ExceptionHandlers {
25   private static final ExceptionHandler _printer =
26     new ExceptionPrinter(System.err);
27   /**
28    * Get an ExceptionHandler object that prints the stack trace
29    * to System.err.
30    * @return the ExceptionHandler object.
31    */

32   public static ExceptionHandler printer(){
33     return _printer;
34   }
35   /**
36    * Get an ExceptionHandler object that prints the stack trace
37    * to a PrintStream object.
38    * @return the ExceptionHandler object.
39    */

40   public static ExceptionHandler printer(java.io.PrintStream JavaDoc out){
41     return new ExceptionPrinter(out);
42   }
43   /**
44    * Get an ExceptionHandler object that prints the stack trace
45    * to a PrintWriter object.
46    * @return the ExceptionHandler object.
47    */

48   public static ExceptionHandler writer(java.io.PrintWriter JavaDoc out){
49     return new ExceptionWriter(out);
50   }
51   /**
52    * Get an ExceptionHandler object that silently ignores any exception
53    * thrown out of the action.
54    * @return the ExceptionHandler object.
55    */

56   public static ExceptionHandler suppresser(){
57     return ExceptionSuppresser.instance();
58   }
59   /**
60    * Get an ExceptionHandler object that re-throw the exception.
61    * If the exception is a checked exception, it is wrapped up
62    * in the InvocationException object and thrown out.
63    * @return the ExceptionHandler object.
64    */

65   public static ExceptionHandler thrower(){
66     return Thrower.instance();
67   }
68 }
69
Popular Tags