KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Util > DFSRChecker > parser > Debug


1 /*
2  * $Id: Debug.java,v 1.4 2005/07/08 12:04:12 kofron Exp $
3  *
4  * Copyright 2004
5  * Distributed Systems Research Group
6  * Department of Software Engineering
7  * Faculty of Mathematics and Physics
8  * Charles University, Prague
9  *
10  * This code was implemented by Stanislav Visnovsky <visnovsky@nenya.ms.mff.cuni.cz>
11  */

12
13
14
15
16 package SOFA.SOFAnode.Util.DFSRChecker.parser;
17
18 /**
19  * The debug enabling class. If the {@link Debug#debug}is set to number higher
20  * than 0, all methods prints the arguments, otherwise the output is skipped.
21  * The set of methods allowing specification of a debug level to which the
22  * message is intended is also provided. Supposed use of debug level: 0 - no
23  * debug info 1 - only high level debug about progress 2 - progress of
24  * complicated methods 3 - all debug info
25  *
26  */

27 public class Debug {
28     /**
29      * Indication, if the debugging stuff should be send to the standard output
30      */

31     public static int debug = 0;
32
33     /**
34      * Print a string to the standard output and the new line.
35      *
36      * @param a
37      * a string to print
38      */

39     public static void println(String JavaDoc a) {
40         if (debug > 0)
41             System.out.println(a);
42     }
43
44     public static void println(int level, String JavaDoc a) {
45         if (debug >= level)
46             System.out.println(a);
47     }
48
49     /**
50      * Print a new line to the standard output.
51      *
52      */

53     public static void println() {
54         if (debug > 0)
55             System.out.println();
56     }
57
58     public static void println(int level) {
59         if (debug >= level)
60             System.out.println();
61     }
62
63     /**
64      * Print an integer to the standard output and the new line.
65      * @param a
66      * an integer to print
67      * @param level
68      * debug level the message should be printed at
69      */

70     public static void println(int level, int a) {
71         if (debug >= level)
72             System.out.println(a);
73     }
74
75     /**
76      * Print a string to the standard output.
77      * @param a
78      * a string to print
79      */

80     public static void print(String JavaDoc a) {
81         if (debug > 0)
82             System.out.print(a);
83     }
84
85     public static void print(int level, String JavaDoc a) {
86         if (debug >= level)
87             System.out.print(a);
88     }
89
90     /**
91      * Print an integer to the standard output.
92      *
93      * @param a
94      * an integer to print
95      * @param level
96      * debug level the message should be printed at
97      */

98     public static void print(int level, int a) {
99         if (debug >= level)
100             System.out.print(a);
101     }
102
103     /**
104      * Sets the debug level to the specified value
105      *
106      * @param level
107      * the new debug level
108      */

109     public static void setLevel(int level) {
110         debug = level;
111     }
112
113     /**
114      * Returns the current debug level
115      *
116      * @return the current debug level
117      */

118     public static int getLevel() {
119         return debug;
120     }
121 }
Popular Tags