|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.borland.primetime.util.Debug
Used for testing preconditions and assertions as well as for logging output to help debug the JBuilder product and OpenTools addins. In the final build, the compiler should be told to exclude this class so that all references to it are removed. The compiler command option is: -exclude com.borland.primetime.util.Debug
Field Summary | |
static int |
count
Common counter variable used as 'line numbers' for debug output messages. |
static java.io.PrintStream |
out
Default output is defined here, initialized to System.err. |
Constructor Summary | |
Debug()
|
Method Summary | |
static void |
addTraceCategory(java.lang.Object category)
Add tracing and warning for given category of messages. |
static void |
assert(boolean condition)
Asserts a condition. |
static void |
assert(boolean condition,
java.lang.String description)
Asserts a condition before a method body is run. |
static void |
debugRect(java.awt.Graphics g,
int x,
int y,
int width,
int height)
Paints a color-cycled hashmarked rectangle in the passed bounds for debugging paint messages. |
static void |
enableAssert(boolean enable)
Enables or disables the checking of conditions in precondition() and check() |
static void |
enableOutput(boolean enable)
Enables or disables all output of debug messages to System.err. |
static void |
flush()
Flushes the current "out" stream buffer. |
static void |
print(java.lang.String message)
Prints a message (without line ending control characters) to the current "out" stream. |
static void |
println(java.lang.String message)
Prints a message (with line ending control characters) to the current "out" stream. |
static void |
printlnc(java.lang.String message)
Prints a message to the debug out stream preceded by a line number (incremented count) and a tab character. |
static void |
printStackTrace()
Prints a debug stack trace of the current thread to the current "out" stream. |
static void |
printStackTrace(java.lang.Throwable ex)
Prints given exception stack trace to the "out" stream. |
static void |
removeTraceCategory(java.lang.Object category)
Remove tracing and warning for given category of messages. |
static void |
setLogStream(java.io.PrintStream log)
Explicitly sets stream for debug messages to be sent to. |
static void |
trace(java.lang.Object category,
java.lang.String description)
Output a trace if the category is enabled and general output is enabled. |
static void |
trace(java.lang.Object category,
java.lang.Throwable ex)
Output a stack trace if the category is enabled and general output is enabled. |
static void |
warn(java.lang.Object category,
boolean condition,
java.lang.String description)
Output a warning if the category is enabled, and a condition is true, and general output is enabled. |
static void |
warn(java.lang.Object category,
java.lang.String description)
Outputs a warning if the category is enabled and general output is enabled. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.io.PrintStream out
public static int count
Common counter variable used as 'line numbers' for debug output messages.
Example useage: Debug.out.println(++Debug.count+"\tDebug Message");
or for the same output use: Debug.printlnc("Debug Message");
Constructor Detail |
public Debug()
Method Detail |
public static void enableOutput(boolean enable)
enable
- True to set "out" to System.err.public static void setLogStream(java.io.PrintStream log)
log
- Set "out" to this PrintStream.public static void enableAssert(boolean enable)
enable
- True to enable asserts.public static void assert(boolean condition) throws AssertionException
Asserts a condition. Use this to describe assumed state and parameter values. An AssertionExcpetion is raised if the given condition is not true.
An error here usually indicates a problem with the use of the class.
condition
- If false and asserts enabled, throws AssertionException.AssertionException
- if asserts enabled and input condition is false.public static void assert(boolean condition, java.lang.String description) throws AssertionException
Asserts a condition before a method body is run. Use this to describe assumed state and parameter values. A AssertionException is raised if the given condition is not true.
An error here usually indicates a problem with the use of the class.
condition
- If false and asserts enabled, throws AssertionException.description
- String to pass as message for AssertionException.AssertionException
- if asserts enabled and input condition is false.public static void addTraceCategory(java.lang.Object category)
Add tracing and warning for given category of messages.
Pass in a unique Class or other object that supports a meaningful toString operation. Then when any call to trace or warning is called, the trace is only displayed if an addTraceCategory() call was made with the same category object.
Typical useage is: addTraceCategory(SomeObject.class);
category
- Enable tracing of this category.public static void removeTraceCategory(java.lang.Object category)
Remove tracing and warning for given category of messages.
Pass in a unique Class or other object that supports a meaningful toString operation. Then when any call to trace or warning is called, the trace is only displayed if an addTraceCategory() call was made with the same category object.
category
- Remove previously added category to trace.public static void trace(java.lang.Object category, java.lang.String description)
Output a trace if the category is enabled and general output is enabled.
Typical useage is: trace(SomeObject.class, "doing something to SomeObject now...");
category
- Category to which this message belongs.description
- Descriptive text to print if category enabled.public static void trace(java.lang.Object category, java.lang.Throwable ex)
Output a stack trace if the category is enabled and general output is enabled.
category
- Category to which this message belongs.ex
- Source for a stack trace to print if category enabled.public static void warn(java.lang.Object category, boolean condition, java.lang.String description)
Output a warning if the category is enabled, and a condition is true, and general output is enabled.
Typical useage: warn(SomeObject.class, someObject1.isBroken(), "someObject1 is broken!");
category
- Category to which this message belongs.condition
- True if print wanted when category enabled.description
- Descriptive text to print if category enabled.public static void warn(java.lang.Object category, java.lang.String description)
Outputs a warning if the category is enabled and general output is enabled.
Typical useage: warn(SomeObject.class, "this shouldn't have happened!");
category
- Category to which this message belongs.description
- Descriptive text to print if category enabled.public static void printStackTrace()
public static void printStackTrace(java.lang.Throwable ex)
ex
- Source for a stack trace to print.public static void println(java.lang.String message)
message
- Text to be output.public static void print(java.lang.String message)
message
- Text to be output.public static void printlnc(java.lang.String message)
Prints a message to the debug out stream preceded by a line number (incremented count) and a tab character. This is used to track repetetive operations (like painting algorhythms).
Typical useage: printlnc("SomeObject.paint() called");
message
- Text to be output.public static void flush()
public static void debugRect(java.awt.Graphics g, int x, int y, int width, int height)
Paints a color-cycled hashmarked rectangle in the passed bounds for debugging paint messages. As subsequent calls are made to debugRect, the hash direction of the debug rectangle will alternate directions, cycle through colors, and vary in hash-mark spacing. This is to allow a viewer to distinguish between different and often repetitive calls to debugRect.
Typical useage:
public void paint(Graphics g) {
Rectangle clip = g.getClipBounds();
Debug.debugRect(g, clip.x, clip.y, clip.width, clip.height);
}
g
- Graphics object to paint with.x
- Left bound of rectangle.y
- Top bound of rectangle.width
- Width of rectangle.height
- Height of rectangle.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |