JavaView® v2.00.008

jv.object
Class PsDebug

java.lang.Object
  |
  +--jv.object.PsDebug

public final class PsDebug
extends java.lang.Object

Allows to issue messages and debug information on the console of JavaView, which is different from Java console. These calls are intended to replace System.out calls. Textual debug information may be issued with either of the following calls

	if (PsDebug.NOTIFY) PsDebug.notify(String) // Default: disabled in release version
	if (PsDebug.WARNING) PsDebug.warning(String)                    // Default: enabled
	PsDebug.error(String, PsObject)            // Default: enabled
 
and textual messages may be directly issued with
	PsDebug.message(String)                    // Default: enabled
 
All information is collected in a text area and shown in the dialog PsConsole. The checkboxes located in the header of the console allow to enable different warning levels. Remark: All messages are cached and flushed to console after some short intervals.

Debug methods parse the current stack trace and print additional information about the calling method and class.

Version:
16.12.00, 3.20 revised (kp) New methods to get/set maximal number of beeps. 04.11.00, 3.10 revised (kp) New private variables to identify debug messages. 03.11.00, 3.00 revised (kp) Message use method stack to print information about calling method.
30.09.99, 2.20 revised (kp) Thread in PsConsole deactivated because of mysterious dead lock.
11.07.99, 2.10 revised (kp) NOTIFY flag added.
09.06.99, 2.00 revised (kp) Caching of messages added to method append().
02.06.99, 1.60 revised (kp) Invoke a reset of static PsDebug when console is disposed.
20.05.99, 1.50 revised (kp) Handling of console moved here from PvViewer.
23.01.99, 1.20 revised (kp) method message(String) added.
16.11.98, 1.10 revised (kp) cleaned
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PsConsole

Field Summary
protected static boolean m_bError
          Switch to record heavy errors in JavaView console.
protected static boolean m_bMessage
          Switch to record info message in JavaView console.
protected static boolean m_bNotify
          Switch to record notify message, i.e. debug messages, in JavaView console.
protected static boolean m_bTrace
          Switch to print method trace to Java console when a warning or error message has been issued.
protected static boolean m_bWarning
          Switch to record warning messages in JavaView console.
protected static PsConsole m_console
          Console window as inspector for debug information.
protected static java.awt.Rectangle m_consoleSize
          Size of console window.
static boolean NOTIFY
          Global flag used during compile time to include or exclude all PsDebug.notify() calls.
static boolean WARNING
          Global flag used during compile time to include or exclude all PsDebug.notify() calls.
 
Constructor Summary
PsDebug()
           
 
Method Summary
static void beep(java.lang.String message)
          Issue a beep and print message to System.out.
static void disposeConsole()
          Dispose console window, e.g. when applet stops, remove textArea and reset variables.
static void error(java.lang.String aString)
          Error messages indicate fatal errors which cannot be handled.
static void error(java.lang.String aString, java.lang.Object what)
          Error messages indicate fatal errors which cannot be handled.
static void flushMessages()
          Flush cached messages into console window.
static PsConsole getConsole()
          Get console window.
static java.awt.Rectangle getConsoleSize()
          Get rectangle with size of JavaView console window.
static long getFlushInterval()
          Get length of least time interval between two successive flushs.
static int getMaxNumBeeps()
          Get maximal number of warning beeps.
static boolean hasConsole()
          Get state of console.
static boolean hasMessages()
          Check whether message buffer contains non-flushed messages.
static boolean isError()
          Check switch to record heavy errors in JavaView console.
static boolean isMessage()
          Check switch to record info message in JavaView console.
static boolean isNotify()
          Check switch to record notify message, i.e. debug messages, in JavaView console.
static boolean isWarning()
          Check switch to record warning messages in JavaView console.
static void message(java.lang.String aString)
          Print messages immediately to console, make rare use since no button to turn it off.
static void notify(java.lang.String aString)
          Heavily used during development process for all different messages.
static void setConsole(PsConsole console)
          Set console.
static void setError(boolean aFlag)
          Enable recording of heavy errors in JavaView console.
static void setMaxNumBeeps(int num)
          Set maximal number of warning beeps.
static void setMessage(boolean aFlag)
          Enable recording of info message in JavaView console.
static void setNotify(boolean aFlag)
          Enable recording of notify message, i.e. debug messages, in JavaView console.
static void setWarning(boolean aFlag)
          Enable recording of warning messages in JavaView console.
static void showStatus(java.lang.String aString)
          Display message in status bar of applet, and in console window.
static void warning(java.lang.String aString)
          Warning messages indicate real errors which are handled.
static void warning(java.lang.String aString, java.lang.Object what)
          Warning messages indicate real errors which are handled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTIFY

public static final boolean NOTIFY
Global flag used during compile time to include or exclude all PsDebug.notify() calls. If NOTIFY==false then all notification methods are removed by a Java compiler during optimization since the methods would never be executed.

The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable NOTIFY by hand.


WARNING

public static final boolean WARNING
Global flag used during compile time to include or exclude all PsDebug.notify() calls. If NOTIFY==false then all notification methods are removed by a Java compiler during optimization since the methods would never be executed.

The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable NOTIFY by hand.


m_console

protected static PsConsole m_console
Console window as inspector for debug information. There is just one console window even for different applets on same Html page.
See Also:
PsConsole

m_consoleSize

protected static java.awt.Rectangle m_consoleSize
Size of console window. Console is handled by PsDebug.

m_bMessage

protected static boolean m_bMessage
Switch to record info message in JavaView console.

m_bNotify

protected static boolean m_bNotify
Switch to record notify message, i.e. debug messages, in JavaView console.

m_bWarning

protected static boolean m_bWarning
Switch to record warning messages in JavaView console.

m_bError

protected static boolean m_bError
Switch to record heavy errors in JavaView console.

m_bTrace

protected static final boolean m_bTrace
Switch to print method trace to Java console when a warning or error message has been issued.
Constructor Detail

PsDebug

public PsDebug()
Method Detail

getConsole

public static PsConsole getConsole()
Get console window. It is no error if console window is not available, e.g. when during startup frame has not been registered in PsConfig. The textArea is available from the very beginning and records all information. If console is opened this information is displayed in the console.

disposeConsole

public static void disposeConsole()
Dispose console window, e.g. when applet stops, remove textArea and reset variables. Since PsDebug is a static class it is essential to remove the console and textArea when an applet stops, since otherwise the next applet will get the same console window and textArea.

setConsole

public static void setConsole(PsConsole console)
Set console.

hasConsole

public static boolean hasConsole()
Get state of console.

getConsoleSize

public static java.awt.Rectangle getConsoleSize()
Get rectangle with size of JavaView console window.

isMessage

public static boolean isMessage()
Check switch to record info message in JavaView console.

isNotify

public static boolean isNotify()
Check switch to record notify message, i.e. debug messages, in JavaView console.

isWarning

public static boolean isWarning()
Check switch to record warning messages in JavaView console.

isError

public static boolean isError()
Check switch to record heavy errors in JavaView console.

setMessage

public static void setMessage(boolean aFlag)
Enable recording of info message in JavaView console.

setNotify

public static void setNotify(boolean aFlag)
Enable recording of notify message, i.e. debug messages, in JavaView console.

setWarning

public static void setWarning(boolean aFlag)
Enable recording of warning messages in JavaView console.

setError

public static void setError(boolean aFlag)
Enable recording of heavy errors in JavaView console.

getFlushInterval

public static long getFlushInterval()
Get length of least time interval between two successive flushs.

hasMessages

public static boolean hasMessages()
Check whether message buffer contains non-flushed messages.

flushMessages

public static final void flushMessages()
Flush cached messages into console window. Console window is the Runnable and calls this method from time to time.

showStatus

public static final void showStatus(java.lang.String aString)
Display message in status bar of applet, and in console window.
Parameters:
aString - status message

message

public static final void message(java.lang.String aString)
Print messages immediately to console, make rare use since no button to turn it off.

notify

public static final void notify(java.lang.String aString)
Heavily used during development process for all different messages. Many calls should remain even after in the release version but with disabled notification.

warning

public static final void warning(java.lang.String aString)
Warning messages indicate real errors which are handled. A warning message indicates that something is wrong with the system, and further running may lead to unexpected behaviour.
Parameters:
aString - warning message

warning

public static final void warning(java.lang.String aString,
                                 java.lang.Object what)
Warning messages indicate real errors which are handled. A warning message indicates that something is wrong with the system, and further running may lead to unexpected behaviour.
Parameters:
aString - warning message
what - object containing more information, what.toString() is appended to message

error

public static final void error(java.lang.String aString)
Error messages indicate fatal errors which cannot be handled. The system is completely out of order. Method calls PsDebug.error(String, Object) with object==null. Console window pops up automaticallyif method is called.
Parameters:
aString - error message

error

public static final void error(java.lang.String aString,
                               java.lang.Object what)
Error messages indicate fatal errors which cannot be handled. The system is completely out of order. Console window pops up automatically if method is called.
Parameters:
aString - error message.
what - object containing more information, what.toString() is appended to message.

getMaxNumBeeps

public static int getMaxNumBeeps()
Get maximal number of warning beeps.
Returns:
the maximal number of warning beeps.

setMaxNumBeeps

public static void setMaxNumBeeps(int num)
Set maximal number of warning beeps.
Parameters:
num - maximal number of warning beeps.

beep

public static void beep(java.lang.String message)
Issue a beep and print message to System.out. Only the first invocations of this method leed to an actually beep.

The beep() method attempts to play an audio beep. You have no control over pitch, duration, or volume; it is like putting echo ^G in a UNIX shell script.

If run as application this method calls the beep method of the default toolkit. If run as applet then a beep from an audio file is played (pending).

Method is called if an error occurs, or, when in debug mode, also if a warning occurs. Information about the beep is given in the console window of JavaView.


JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.