Search this API

y.util
Class D

java.lang.Object
  extended by y.util.D

public class D
extends java.lang.Object

Provides some convenience methods for code debugging and exception handling.

The behavior 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.

 
Your browser does not support SVG content.

Field Summary
static int DEBUG_LEVEL
          The debug level threshold.
 
Constructor Summary
D()
           
 
Method Summary
static void bu(int level, java.lang.String output)
          Like bug(int, String), but uses no line-feed.
static void bu(java.lang.Object msg)
          Like bug(Object), but omits newline.
static void bu(java.lang.Object source, java.lang.Object msg)
          Like bug(Object, Object), but does not append a newline to the output.
static void bug(int level, java.lang.String msg)
          Prints the given string to System.out if the given debug level if bigger than DEBUG_LEVEL.
static void bug(java.lang.Object msg)
          Prints the given object to System.err unconditionally.
static void bug(java.lang.Object source, int level, java.lang.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(java.lang.Object source, java.lang.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(java.lang.Object msg)
          Called on a fatal error.
static void fatal(java.lang.Object source, java.lang.Object msg)
          Outputs the class of the given object and the given message.
static boolean isLogToUI()
          Returns whether show(Exception), show(Throwable), and showError(Object) calls should log to the UI even if the current Thread is not the EDT.
static void setLogToUI(boolean newLogToUI)
          Determines whether show(Exception), show(Throwable), and showError(Object) calls should open a dialog UI even if the current Thread is not the EDT.
static void show(java.lang.Exception ex)
          Displays the stack trace generated by the given exception in a dialog window.
static void show(java.lang.Throwable t)
          Displays the stack trace generated by the given exception in a dialog window.
static void showError(java.lang.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(java.lang.Exception ex)
          Outputs a stack trace on System.err.
static boolean watch(java.lang.String source)
          Returns true if the given object type is under observation due to the -Dy.debug mechanism.
static boolean watchSource(java.lang.Object source)
          Returns true if the given object type is under observation due to the -Dy.debug mechanism.
 
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. Its 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 void bug(int level,
                       java.lang.String msg)
Prints the given string to System.out if the given debug level if bigger than DEBUG_LEVEL.


bug

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


isLogToUI

public static boolean isLogToUI()
Returns whether show(Exception), show(Throwable), and showError(Object) calls should log to the UI even if the current Thread is not the EDT.

Returns:
whether to display the error in a dialog.

setLogToUI

public static void setLogToUI(boolean newLogToUI)
Determines whether show(Exception), show(Throwable), and showError(Object) calls should open a dialog UI even if the current Thread is not the EDT.

Parameters:
newLogToUI - whether to display the error in a dialog.

bu

public static void bu(java.lang.Object msg)
Like bug(Object), but omits newline.


bug

public static void bug(java.lang.Object source,
                       java.lang.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 specified prefixes the debug message will be printed to System.err.


bug

public static void bug(java.lang.Object source,
                       int level,
                       java.lang.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 specified prefixes the debug message will be printed to System.err.


bu

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


watchSource

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


watch

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


fatal

public static void fatal(java.lang.Object source,
                         java.lang.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 void fatal(java.lang.Object msg)
Called on a fatal error. Mostly used in a catch statement to signal a definite bug.


bu

public static void bu(int level,
                      java.lang.String output)
Like bug(int, String), but uses no line-feed.


trace

public static void trace(java.lang.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(java.lang.Object obj)
Displays the string representation of the given object in a dialog window.


show

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


show

public static void show(java.lang.Throwable t)
Displays the stack trace generated by the given exception in a dialog window.


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