org.thdl.util
Class ThdlDebug

java.lang.Object
  |
  +--org.thdl.util.ThdlDebug

public class ThdlDebug
extends Object

This uninstantiable class provides assertions and the like in a JVM-version-independent fashion.

Author:
David Chandler

Method Summary
static void abort(String message)
          Exits the program the hard way.
static void attemptToSetUpLogFile(String prefix, String suffix)
          Sets it up so that a call to System.out or System.err prints to standard output/error but ALSO prints to the log file named (prefix + suffix).
static void handleClasspathError(String whoseWhat, Throwable error)
          Exits the program with a message that the CLASSPATH is not set properly.
static void noteIffyCode()
          Call this from control-flow paths that are not well thought out.
static void verify(boolean condition)
          Throws an unchecked exception if condition is not true.
static void verify(String msg, boolean condition)
          Throws an unchecked exception if condition is not true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

verify

public static void verify(boolean condition)
Throws an unchecked exception if condition is not true. Note that unlike a real assertion, this happens always. We can certainly use AspectJ (with which I, DC, am intimately familiar) to avoid the overhead of such things in release builds if performance becomes a real issue.


verify

public static void verify(String msg,
                          boolean condition)
                   throws ThdlLazyException
Throws an unchecked exception if condition is not true. The exception's message will include the string msg if msg is not null. Note that unlike a real assertion, this happens always. We can certainly use AspectJ (with which I, DC, am intimately familiar) to avoid the overhead of such things in release builds if performance becomes a real issue. Throws a THDL-specific exception so that you can catch these specially in case you want to ignore them.

Throws:
ThdlLazyException - if condition is not true

noteIffyCode

public static void noteIffyCode()
                         throws ThdlLazyException
Call this from control-flow paths that are not well thought out. For example, if you have to catch an IOException, but you're fairly certain that it'll never be thrown, call this function if it is indeed thrown. Developers can set the thdl.debug property to true (using 'java -Dthdl.debug=true' or the properties files) in order to test the code's robustness. Throws a THDL-specific exception so that you can catch these specially in case you want to ignore them.

Throws:
ThdlLazyException - if the thdl.debug option is set to "true"

handleClasspathError

public static void handleClasspathError(String whoseWhat,
                                        Throwable error)
Exits the program with a message that the CLASSPATH is not set properly.


abort

public static void abort(String message)
Exits the program the hard way. Don't ever call this for code that you expect to be executed.


attemptToSetUpLogFile

public static void attemptToSetUpLogFile(String prefix,
                                         String suffix)
Sets it up so that a call to System.out or System.err prints to standard output/error but ALSO prints to the log file named (prefix + suffix). Be sure the log file name is a relative path, because we may put this file into an arbitrary directory.



These API docs were created 02/02/2003 08:19 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo