|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.util.JCDebug
A useful mechanism for managing assertions and debug prints.
A perl script is provided to remove references to this class
to produce production code. See
com.klg.jclass/util/scripts/rmdebug.pl
.
The script removes any line containing
JCDebug.<print|assert>
AND any
import com.klg.jclass.util.JCDebug
statements that may exist.
Optionally you may call setEnabled(false)
to globally
disable JCDebug
printing.
By calling setEnabled(true)
, you can activate normal debug
output. If you wish to view code marked "mycode", then call
setTag("mycode")
.
Another useful construct is the concept of "levels". The advantage of
this is that by calling, for example, setLevel(2)
you will
avoid seeing any debug messages marked 3 or greater. This is useful for
controlling the amount of detail you are viewing without removing the
debug information.
Note: JClass distribution bytecode does not contain any references to this class.
Field Summary | |
protected static boolean |
enabled
|
protected static int |
level
|
protected static PrintStream |
stream
|
protected static String[] |
tags
|
Constructor Summary | |
JCDebug()
|
Method Summary | |
static void |
assertThat(boolean condition)
Invoked to assert that a particular condition is true . |
static void |
assertThat(boolean condition,
String message)
Invoked to assert that a particular condition is true and throw
an exception with the specified message if it is not. |
static int |
getLevel()
Returns the level that determines what gets printed. |
static PrintStream |
getPrintStream()
Returns the PrintStream currently in use. |
static String[] |
getTags()
Gets the tags currently used to filter output. |
static boolean |
isEnabled()
Returns whether or not Debug output is enabled. |
protected static boolean |
isPrintableLevel(int plevel)
If the passed-in level is less than or equal to the set level, then we deem the level to be printable. |
protected static boolean |
isPrintableTag(String tag)
If the passed-in tag is in the tags list or the tag is null, then we deem the tag to be printable; otherwise it is not. |
static void |
print(int plevel,
String text)
Equivalent to calling print(plevel, null, text) . |
static void |
print(int plevel,
String ptag,
String text)
Prints the text according to level and tag filter options. |
static void |
print(String text)
Equivalent to calling print(0, null, text) . |
static void |
print(String ptag,
String text)
Equivalent to calling "print(0, ptag, text)". |
static void |
println(int plevel,
String text)
Equivalent to calling println(plevel, null, text) . |
static void |
println(int plevel,
String ptag,
String text)
Prints the text followed by a newline according to level and tag filter options. |
static void |
println(String text)
Equivalent to calling println(0, null, text) . |
static void |
println(String ptag,
String text)
Equivalent to calling println(0, ptag, text) . |
static void |
printStackTrace()
Useful routine to force a stack trace at the current location by generating and catching a mock NullPointerException . |
static void |
printStackTrace(String s)
Useful routine to force a stack trace at the current location by generating and catching a mock NullPointerException . |
static void |
printStackTrace(String ptag,
Throwable t)
Prints a stack trace for the specified exception, but only if the specified tag is currently enabled. |
static void |
setEnabled(boolean e)
Controls global enable/disable of Debug printing. |
static void |
setLevel(int new_level)
Sets the level of debug information to print. |
static void |
setPrintStream(PrintStream pstream)
Sets the output stream to use. |
static void |
setTag(String tag)
Convienience method to allow setting of one tag. |
static void |
setTags(String[] new_tags)
Sets the list of tags to match against when determining which debug print statements to output. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static boolean enabled
protected static String[] tags
protected static int level
protected static PrintStream stream
Constructor Detail |
public JCDebug()
Method Detail |
public static void setEnabled(boolean e)
false
and should be turned on to see the debug output.
e
- Should Debug printing be enabled?public static boolean isEnabled()
public static void setPrintStream(PrintStream pstream)
System.out
.
pstream
- the new output streampublic static PrintStream getPrintStream()
PrintStream
currently in use.
public static void setLevel(int new_level)
new_level
- the new level of debug information to printpublic static int getLevel()
setLevel(int)
public static void setTags(String[] new_tags)
new_tags
- the new list of tagspublic static void setTag(String tag)
tag
- the new tagpublic static String[] getTags()
public static final void assertThat(boolean condition)
true
. Useful
if you need a pre JDK 1.4 assert mechanism.
condition
- the condition to assert true
or
false
public static final void assertThat(boolean condition, String message)
true
and throw
an exception with the specified message if it is not. Useful
if you need a pre JDK 1.4 assert mechanism.
condition
- the condition to assert true
or
false
message
- the message to print if the assertion failspublic static void printStackTrace()
NullPointerException
.
public static void printStackTrace(String s)
NullPointerException
.
s
- a String to display at the top of the tracepublic static void printStackTrace(String ptag, Throwable t)
ptag
- the "tag" to be used to determine whether to print the tracet
- exception to displaypublic static void print(int plevel, String ptag, String text)
plevel
- the "level" of the print commandptag
- the "tag" associated with the print command (note that
the tag must be in the tags list for the data to be output); a tag of
null means that the line should always be printedtext
- the text to printpublic static void print(int plevel, String text)
print(plevel, null, text)
.
plevel
- the "level" of the print commandtext
- the text to printpublic static void print(String ptag, String text)
ptag
- the "tag" associated with the print command (note that
the tag must be in the tags list for the data to be output); a tag of
null means that the line should always be printedtext
- the text to printpublic static void print(String text)
print(0, null, text)
.
text
- the text to printpublic static void println(int plevel, String ptag, String text)
plevel
- the "level" of the print commandptag
- the "tag" associated with the print command (note that
the tag must be in the tags list for the data to be output); a tag of
null means that the line should always be printedtext
- the text to printpublic static void println(int plevel, String text)
println(plevel, null, text)
.
plevel
- the "level" of the print commandtext
- the text to printpublic static void println(String ptag, String text)
println(0, ptag, text)
.
ptag
- the "tag" associated with the print command (note that
the tag must be in the tags list for the data to be output); a tag of
null means that the line should always be printedtext
- the text to printpublic static void println(String text)
println(0, null, text)
.
text
- the text to printprotected static boolean isPrintableLevel(int plevel)
plevel
- the level to be tested
protected static boolean isPrintableTag(String tag)
tag
- the tag to be tested
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |