y.util
Class D

java.lang.Object
  |
  +--y.util.D

public class D
extends Object

Provides some convenience methods for code debugging and exception handling.

The behaviour of this class can be adapted by starting the Java Virtual Machine with a set system property y.debug and y.debug.level. The default debug level is 2. It can be changed by setting the system property y.debug.level appropriately.


Field Summary
static int DEBUG_LEVEL
          The debug level threshold.
 
Constructor Summary
D()
           
 
Method Summary
static void bu(int level, String output)
          Like bug but uses no linefeed.
static void bu(Object msg)
          Like bug, but omits newline
static void bu(Object source, Object msg)
          Like D.bug, but does not append a newline to the output
static void bug(int level, String msg)
          Prints the given string to System.out if the given debug level if bigger than DEBUG_LEVEL
static void bug(Object msg)
          Prints the given object to System.err unconditionally.
static void bug(Object source, int level, Object msg)
          Print the given message to System.err if the fully qualified class name of the given source object is encoded in the system property y.debug.
static void bug(Object source, Object msg)
          Print the given message to System.err if the fully qualified class name of the given source object is encoded in the system property y.debug and if the given debug level if bigger than DEBUG_LEVEL.
static void fatal(Object msg)
          Called on a fatal error.
static void fatal(Object source, Object msg)
          Outputs the class of the given object and the given message.
static void show(Exception ex)
          Displays the stack trace generated by the given exception in a dialog window.
static void showError(Object obj)
          Displays the string representation of the given object in a dialog window.
static void trace()
          Outputs a stack trace on System.err
static void trace(Exception ex)
          Outputs a stack trace on System.err
static boolean watch(String source)
          Returns true if the given object type is under observation due to the -Dy.debug=...
static boolean watchSource(Object source)
          Returns true if the given object type is under observation due to the -Dy.debug=...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_LEVEL

public static final int DEBUG_LEVEL
The debug level threshold. It's default value is 2 but may be changed by setting the system property y.debug.level.

Constructor Detail

D

public D()
Method Detail

bug

public static final void bug(int level,
                             String msg)
Prints the given string to System.out if the given debug level if bigger than DEBUG_LEVEL


bug

public static final void bug(Object msg)
Prints the given object to System.err unconditionally.


bu

public static final void bu(Object msg)
Like bug, but omits newline


bug

public static final void bug(Object source,
                             Object msg)
Print the given message to System.err if the fully qualified class name of the given source object is encoded in the system property y.debug and if the given debug level if bigger than DEBUG_LEVEL.

The value of the y.debug property is a colon separated list of fully qualified class name prefixes. If the name of the given class starts with one of the specifed prefixes the debug message will be printed to System.err


bug

public static final void bug(Object source,
                             int level,
                             Object msg)
Print the given message to System.err if the fully qualified class name of the given source object is encoded in the system property y.debug.

The value of the y.debug property is a colon separated list of fully qualified class name prefixes. If the name of the given class starts with one of the specifed prefixes the debug message will be printed to System.err


bu

public static final void bu(Object source,
                            Object msg)
Like D.bug, but does not append a newline to the output


watchSource

public static boolean watchSource(Object source)
Returns true if the given object type is under observation due to the -Dy.debug=... mechanism.


watch

public static boolean watch(String source)
Returns true if the given object type is under observation due to the -Dy.debug=... mechanism.


fatal

public static final void fatal(Object source,
                               Object msg)
Outputs the class of the given object and the given message. Then throws a RuntimeException using the same message.

Mostly used in a catch statement to signal a definite bug.


fatal

public static final void fatal(Object msg)
Called on a fatal error. Mostly used in a catch statement to signal a definite bug.


bu

public static final void bu(int level,
                            String output)
Like bug but uses no linefeed.


trace

public static void trace(Exception ex)
Outputs a stack trace on System.err


trace

public static void trace()
Outputs a stack trace on System.err


showError

public static void showError(Object obj)
Displays the string representation of the given object in a dialog window.


show

public static void show(Exception ex)
Displays the stack trace generated by the given exception in a dialog window.


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003