borland Packages Class Hierarchy jb.util Package
java.lang.Object +----com.borland.jb.util.Diagnostic
Variables Properties Methods
The Diagnostic component collects useful diagnostic functions for debugging program flow and output.
All calls to Diagnostic methods with a void return type can be removed from the compiled classes by using the compiler's exclude class option:
-exclude com.borland.jb.util.Diagnostic
public static int count = 0A common counter variable used for line numbers for debug output messages. For example,
Diagnostic.out.println(++Diagnostic.count+"\tdebug message");
public static PrintStream out = System.errEnables or disables output of diagnostic messages to
System.err
.
public static boolean outputEnabled = System.getProperty("jb.util.diagnostic", "on").equals("on"))Specifies whether output logging is initially enabled or disabled.
public static void addTraceCategory(Object category)A category-based tracing or warning method.
To set up a category-based tracing or warning, pass in a unique String, Class or other object that supports a meaningful toString operation. When a call to a trace or warn method that takes a category is made (for example, trace(Object category, String description)), the trace is displayed if an addTraceCategory() call was made with the same category object.
public static void check(boolean condition)Checks a condition within a method body.
An IllegalStateException is thrown if the given condition is false.
public static void check(boolean condition, Object description)Checks a condition within a method body.
Use this method to describe assumed results and state after internal operations.
A check is raised if the given condition is not true. An error here usually indicates an internal problem with the class.
public static void enableChecking(boolean enable)Enables or disables the checking of conditions in precondition() and check().
public static void enableOutput(boolean enable)Enables or disables all output of diagnostic messages to
System.err
.
public static void exit(int code)Calls
System.exit(int code)
.
public static void fail()Calls check(false) to force a failure.
public static void fail(Exception ex)Calls check(false) to force a failure but prints the exception message on the stack trace first.
public static void fail(Object description)Causes a check exception if the code reaches an unexpected location.
public static void flush()Flushes the diagnostic out Stream buffer.
public static int getTraceLevel()Gets the minimum threshold for trace and warning output.
0
is highest level and +maxint
is lowest level.
public static void needException()Used to mark places where an Exception is needed.
Upon error, throws an IllegalStateException.
public static void precondition(boolean condition)Checks a condition. Same as check(boolean), but typically placed at the start of the method body.
An IllegalStateException is thrown if the given condition is false.
public static void precondition(boolean condition, String description)Checks a condition. Same as check(boolean, java.lang.String), but typically placed at the start of the method body.
An IllegalStateException is thrown if the given condition is false.
public static void print(String message)Prints a message to the diagnostic out stream.
public static void println(String message)Prints a message to the diagnostic out stream, preceded by a line number (incremented count).
public static void printlnc(String message)
Prints a message to the diagnostic out stream, preceded by a line number (incremented count) and a tab character.
public static void printStackTrace()Prints a diagnostic stack trace of the current thread to the diagnostic out stream.
public static void printStackTrace(Throwable ex)Prints a diagnostic stack trace of the current thread to the diagnostic out stream. Throws an exception.
public static void removeTraceCategory(Object category)Removes a trace added with addTraceCategory().
public static void setLogStream(PrintStream log)Explicitly sets the stream for diagnostic messages to be sent to.
public static void setTraceLevel(int level)Sets the minimum threshold for trace and warning output.
0
is highest level and +maxint
is lowest level. Setting this level to -1 effectively turns off traces and warnings.
public static void trace(int level, String description)Outputs a trace if the threshold level is high enough and general output is enabled.
0
is highest level and +maxint
is lowest level. Setting this level to -1 effectively turns off traces and warnings.
public static void trace(Object category, int level, String description)Outputs a trace if the category and general output are both enabled, and the threshold level is high enough.
0
is highest level and +maxint
is lowest level. Setting this level to -1 effectively turns off traces and warnings.
public static void trace(Object category, String description)Outputs a trace if the category and general output are enabled.
public static void warn(int level, boolean condition, String description)Outputs a warning if the threshold level is high enough, the boolean condition is true, and general output is enabled.
0
is highest level and +maxint
is lowest level. Setting this level to -1 effectively turns off traces and warnings.
public static void warn(Object category, boolean condition, String description)Outputs a warning if the category object is enabled, the boolean condition is true, and general output is enabled.
public static void warn(Object category, int level, boolean condition, String description)Outputs a warning if the category object is enabled, the boolean condition is true, and general output is enabled.
0
is highest level and +maxint
is lowest level. Setting this level to -1 effectively turns off traces and warnings.
public static void warn(Object category, String description)Outputs a warning if the category and general output are both enabled.