KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > actions > Debug


1 /*
2  * $Id: Debug.java,v 1.1.1.1 2004/06/16 01:43:39 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.actions;
9
10 /**
11  * Simple class that holds the value of the debug flag.
12  * use Debug.setDebug(true). Can be passed as an applet value.
13  *
14  * Should figure a way to set the default value ie.
15  *
16  * debug = Boolean.valueOf(System.getProperty("debug")).booleanValue();
17  *
18  * However, System.getProperty is not allowed by the applet security model.
19  *
20  * TODO: This should also contain the logger.
21  */

22 class Debug {
23
24     public static boolean debug = false;
25
26     public static void setDebug(boolean isdebug) {
27     debug = isdebug;
28     }
29
30     public static boolean isDebug() {
31     return debug;
32     }
33
34     /**
35      * A helper method to print exceptions
36      * TODO: should probabaly use the logger API.
37      */

38     public static void printException(String JavaDoc message, Exception JavaDoc ex) {
39     System.out.println("Exception encountered: " + message);
40     if (isDebug()) {
41         ex.printStackTrace();
42     }
43     }
44 }
45
Popular Tags