Release Planner v1.0

rp.util
Class Debug

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

public class Debug
extends java.lang.Object

The Debug class is the API used for programatic insertion of debugging statements and assertions in code. Here is an example of its use:

    public class Test {
	public static void main(String args[]) {
	    Debug.parseOptions(args); // extracts -d options and consolidates remaining ones
	    Debug.put("hello world!"); // default message level 1
	    Debug.put("goodbye", 4); // message level 4
	    int i = 5;
	    Debug.assert(i==7); // message level 0 
	}
    }
 

Version:
$Revision: 1.3 $, $Date: 2001/12/10 22:32:11 $

Method Summary
static void assert(boolean condition)
          Insist on a condition.
static void assert(boolean condition, java.lang.String msg)
          Insist on a condition with an associated message.
static void classInvariant(boolean condition)
          Insist on a class invariant condition.
static void classInvariant(boolean condition, java.lang.String msg)
          Insist on a class invariant with an associated message.
static void loopInvariant(boolean condition)
          Insist on an loop invariant condition.
static void loopInvariant(boolean condition, java.lang.String msg)
          Insist on a loop invariant with an associated message.
static java.lang.String options(boolean summary)
          Returns debug command line option usage documentation suitable for merging into a larger command-line usage message.
static void parseOptions(java.lang.String[] args)
          Parses command-line debug options.
static void post(boolean condition)
          Insist on a post-condition.
static void post(boolean condition, java.lang.String msg)
          Insist on a post-condition with an associated message.
static void pre(boolean condition)
          Insist on a pre-condition.
static void pre(boolean condition, java.lang.String msg)
          Insist on a pre-condition with an associated message.
static void put(java.lang.String msg)
          Prints a message to the debug log file at debug level 1.
static void put(java.lang.String msg, int messageLevel)
          Prints a message to the debug log file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

put

public static void put(java.lang.String msg)
Prints a message to the debug log file at debug level 1.

Parameters:
msg - Message to write to the log file.

put

public static void put(java.lang.String msg,
                       int messageLevel)
Prints a message to the debug log file.

Parameters:
msg - Message to write to the log file.
messageLevel - the debug Level 0-9 (0 always prints)

assert

public static void assert(boolean condition)
Insist on a condition. If false a message is written to the debug log file and execution may terminate.

Parameters:
condition - Boolean value to test the assertion.

assert

public static void assert(boolean condition,
                          java.lang.String msg)
Insist on a condition with an associated message.

Parameters:
condition - Boolean value to test the assertion.
msg - Message to write the debug log file on failure of the the assertion.

pre

public static void pre(boolean condition)
Insist on a pre-condition. If false a message is written to the debug log file and execution may terminate.

Parameters:
condition - Boolean value to test the assertion.

pre

public static void pre(boolean condition,
                       java.lang.String msg)
Insist on a pre-condition with an associated message.

Parameters:
condition - Boolean value to test the assertion.
msg - Message to write the debug log file on failure of the the assertion.

post

public static void post(boolean condition)
Insist on a post-condition. If false a message is written to the debug log file and execution may terminate.

Parameters:
condition - Boolean value to test the assertion.

post

public static void post(boolean condition,
                        java.lang.String msg)
Insist on a post-condition with an associated message.

Parameters:
condition - Boolean value to test the assertion.
msg - Message to write the debug log file on failure of the the assertion.

loopInvariant

public static void loopInvariant(boolean condition)
Insist on an loop invariant condition. If false a message is written to the debug log file and execution may terminate.

Parameters:
condition - Boolean value to test the assertion.

loopInvariant

public static void loopInvariant(boolean condition,
                                 java.lang.String msg)
Insist on a loop invariant with an associated message.

Parameters:
condition - Boolean value to test the assertion.
msg - Message to write the debug log file on failure of the the assertion.

classInvariant

public static void classInvariant(boolean condition)
Insist on a class invariant condition. If false a message is written to the debug log file and execution may terminate.

Parameters:
condition - Boolean value to test the assertion.

classInvariant

public static void classInvariant(boolean condition,
                                  java.lang.String msg)
Insist on a class invariant with an associated message.

Parameters:
condition - Boolean value to test the assertion.
msg - Message to write the debug log file on failure of the the assertion.

options

public static java.lang.String options(boolean summary)
Returns debug command line option usage documentation suitable for merging into a larger command-line usage message.

Parameters:
summary - When true returns single-line usage summary. When false, returns multi-line option details.

parseOptions

public static void parseOptions(java.lang.String[] args)
                         throws CommandLineOptionError
Parses command-line debug options. Stops at the end of 'args' or at the first null element in 'args'. Moves non-parsed options towards the front of 'args'.

Parameters:
args - command line options
Throws:
CommandLineOptionError - If a parsing error.

Release Planner v1.0