KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > resolver > helpers > Debug


1 // Debug.java - Print debug messages
2

3 /*
4  * Copyright 2001-2004 The Apache Software Foundation or its licensors,
5  * as applicable.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package com.sun.org.apache.xml.internal.resolver.helpers;
21
22 /**
23  * Static debugging/messaging class for Catalogs.
24  *
25  * <p>This class defines a set of static methods that can be called
26  * to produce debugging messages. Messages have an associated "debug
27  * level" and messages below the current setting are not displayed.</p>
28  *
29  * @author Norman Walsh
30  * <a HREF="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
31  *
32  * @version 1.0
33  */

34 public class Debug {
35   /** The internal debug level. */
36   protected int debug = 0;
37
38   /** Constructor */
39   public Debug() {
40     // nop
41
}
42
43   /** Set the debug level for future messages. */
44   public void setDebug(int newDebug) {
45     debug = newDebug;
46   }
47
48   /** Get the current debug level. */
49   public int getDebug() {
50     return debug;
51   }
52
53   /**
54    * Print debug message (if the debug level is high enough).
55    *
56    * <p>Prints "the message"</p>
57    *
58    * @param level The debug level of this message. This message
59    * will only be
60    * displayed if the current debug level is at least equal to this
61    * value.
62    * @param message The text of the message.
63    */

64   public void message(int level, String JavaDoc message) {
65     if (debug >= level) {
66       System.out.println(message);
67     }
68   }
69
70   /**
71    * Print debug message (if the debug level is high enough).
72    *
73    * <p>Prints "the message: spec"</p>
74    *
75    * @param level The debug level of this message. This message
76    * will only be
77    * displayed if the current debug level is at least equal to this
78    * value.
79    * @param message The text of the message.
80    * @param spec An argument to the message.
81    */

82   public void message(int level, String JavaDoc message, String JavaDoc spec) {
83     if (debug >= level) {
84       System.out.println(message + ": " + spec);
85     }
86   }
87
88   /**
89    * Print debug message (if the debug level is high enough).
90    *
91    * <p>Prints "the message: spec1" and "spec2" indented on the next line.</p>
92    *
93    * @param level The debug level of this message. This message
94    * will only be
95    * displayed if the current debug level is at least equal to this
96    * value.
97    * @param message The text of the message.
98    * @param spec1 An argument to the message.
99    * @param spec2 Another argument to the message.
100    */

101   public void message(int level, String JavaDoc message,
102                  String JavaDoc spec1, String JavaDoc spec2) {
103     if (debug >= level) {
104       System.out.println(message + ": " + spec1);
105       System.out.println("\t" + spec2);
106     }
107   }
108 }
109
Popular Tags