ix.util
Class Debug

java.lang.Object
  |
  +--ix.util.Debug

public abstract class Debug
extends java.lang.Object

Class for useful static debugging tools


Field Summary
static boolean on
          Global on/off control over the debugging output produced by the note and noteln methods.
static java.io.PrintStream out
          The output destination used by note and noteln.
 
Method Summary
static void assert(boolean cond)
          assert checks a condition that should always be true and throws an AssertionFailure if it is not.
static void assert(boolean cond, java.lang.String message)
          A variant that allows a message that describes the assertion.
static void assert(boolean cond, java.lang.String message, java.lang.Object item)
          A variant that allows a message that describes the assertion plus an Object that the message is about.
static void error(java.lang.String message)
          Use this to tell the user about problems that should not be ignored and are not handled locally.
static void note(java.lang.String message)
          note writes a string to Debug.out if Debug.on is true.
static void noteElements(java.util.Enumeration e, java.lang.String prefix)
          Prints the elements of an enumeration on separate lines with a specified prefix at the start of each line.
static void noteEnumeration(java.util.Enumeration e)
          Numbers and prints the elements of an Enumeration on separate lines.
static void noteEnumerationClasses(java.util.Enumeration e)
          Prints the elements of an Enumeration on separate lines, with an index number and and class name at the start of each line.
static void noteException(java.lang.Exception e)
          Note an exception, together with a backtrace.
static void noteException(java.lang.Exception e, boolean backtrace)
          Note an exception, optionally with a backtrace.
static void noteln(java.lang.String message)
          noteln writes a string, followed by a newline, to Debug.out if Debug.on is true.
static void noteln(java.lang.String message, int i)
           
static void noteln(java.lang.String message, java.lang.Object whatever)
           
static void setNoteFile(java.lang.String filename)
          Sets the output destination for debugging notes.
static void setNoteStream(java.io.PrintStream s)
          Sets the output destination for debugging notes.
static void warn(java.lang.String message)
          Use this to tell the user about minor problems.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

on

public static boolean on
Global on/off control over the debugging output produced by the note and noteln methods.

out

public static java.io.PrintStream out
The output destination used by note and noteln. Do not assign directly to this variable. Call setNoteStream or setNoteFile instead.
Method Detail

note

public static void note(java.lang.String message)
note writes a string to Debug.out if Debug.on is true. It is intetended to replace System.out.print calls, for debugging output.

Unlike noteln, note does not print a newline after the message and does not have variants that take different arguments. The typical use of note is to use several calls to write a line of output. One potential problem with using note is that a different thread may print some other output between those calls.


noteln

public static void noteln(java.lang.String message)
noteln writes a string, followed by a newline, to Debug.out if Debug.on is true. It is intended to replace System.out.println calls, for debugging output. noteln has variants that take more than one argument. The arguments will be printed as strings with single spaces between. The aim here is to avoid string concatenation in the calls to noteln, so that the concatenation will not occur when debugging output is turned off.

noteln

public static void noteln(java.lang.String message,
                          java.lang.Object whatever)

noteln

public static void noteln(java.lang.String message,
                          int i)

setNoteStream

public static void setNoteStream(java.io.PrintStream s)
Sets the output destination for debugging notes.

setNoteFile

public static void setNoteFile(java.lang.String filename)
Sets the output destination for debugging notes.

noteException

public static void noteException(java.lang.Exception e)
Note an exception, together with a backtrace. The note is always printed to System.out or System.err, even if debug output has been turned off or redirected to a file.

noteException

public static void noteException(java.lang.Exception e,
                                 boolean backtrace)
Note an exception, optionally with a backtrace. The note is always printed to System.out or System.err, even if debug output has been turned off or redirected to a file.

warn

public static void warn(java.lang.String message)
Use this to tell the user about minor problems. Warn prints a message to System.err, followed by a backtrace for the current thread.

error

public static void error(java.lang.String message)
Use this to tell the user about problems that should not be ignored and are not handled locally.
Throws:
java.lang.RuntimeException - as notification of the problem.

noteEnumeration

public static void noteEnumeration(java.util.Enumeration e)
Numbers and prints the elements of an Enumeration on separate lines.

noteEnumerationClasses

public static void noteEnumerationClasses(java.util.Enumeration e)
Prints the elements of an Enumeration on separate lines, with an index number and and class name at the start of each line.

noteElements

public static void noteElements(java.util.Enumeration e,
                                java.lang.String prefix)
Prints the elements of an enumeration on separate lines with a specified prefix at the start of each line.

assert

public static void assert(boolean cond)
assert checks a condition that should always be true and throws an AssertionFailure if it is not. assert is typically used when all of the following apply: the subsequent code requires a condition to be true; in the absence of bugs, the condition always will be true at that point; and it is not obvious that the condition will be true.

AssertionFailure is a RuntimeException and so does not need to be listed in the "throws" clauses of method definitions. One reason for that is to avoid discouraging the use of assertions. If AssertionFailure had to be declared, then adding an assertion in a method that had none before would require nonlocal changes in the code.

Throws:
AssertionFailure - as notification of the problem
See Also:
AssertionFailure

assert

public static void assert(boolean cond,
                          java.lang.String message)
A variant that allows a message that describes the assertion. The message will be printed when the assertion fails and will be included in the AssertionFailure exception.

assert

public static void assert(boolean cond,
                          java.lang.String message,
                          java.lang.Object item)
A variant that allows a message that describes the assertion plus an Object that the message is about.