com.sas.edir
Class Debug

java.lang.Object
  |
  +--com.sas.edir.Debug

public class Debug
extends java.lang.Object

The Debug class provides a uniform debugging interface that is easily controllable from a properties file. It takes a Properties object and looks for properties that start with "Servlet.Debug" and the remainder of the key is a debugging class to turn on. Debug output can then be easily controlled by using specific classes in the Java code, and turning those classes on and off from the properties.

Version:
1.0
Author:
SAS

Constructor Summary
Debug()
           
 
Method Summary
static void addClass(java.lang.String debugClass)
          Add a class to enable for debugging.
static void debug(java.lang.String debugClass, java.lang.String output)
          Output text to the PrintStream.
static void debugFormat(java.lang.String debugClass, java.lang.Object source, java.util.Locale locale, java.lang.String resFile, java.lang.String msgId, java.lang.Object[] args)
          Output data formatted using a resource file.
static void debugFormat(java.lang.String debugClass, java.lang.Object source, java.lang.String resfile, java.lang.String msgId)
          Output data formatted using a resource file.
static void debugStackTrace(java.lang.String debugClass, java.lang.Object source, java.util.Locale locale, java.lang.String resFile, java.lang.Throwable t)
          Output a stack track to the debug stream.
static java.io.PrintStream getDebugStream()
          Get the PrintStream in use by the Debug class.
static java.io.PrintStream getDebugStream(java.lang.String debugClass)
          Get the PrintStream in use by the Debug class if the specified debugClass is activated.
static void init(java.util.Properties prop)
          Initialize the Debug class with a Properties object.
static boolean removeClass(java.lang.String debugClass)
          Remove a class from the enabled debug classes.
static void setDebugStream(java.io.PrintStream debugStream)
          Set the debugStream to use for output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Debug

public Debug()
Method Detail

init

public static void init(java.util.Properties prop)
                 throws java.lang.NullPointerException
Initialize the Debug class with a Properties object. Turn on debugging for any class with a property that starts with "Servlet.Debug" and has a value of true. Also turn on a class named "Any" for debugging that should be output if any debugging is enabled.

Parameters:
prop - A properties object with the debugging options.

addClass

public static void addClass(java.lang.String debugClass)
Add a class to enable for debugging.

Parameters:
debugClass - The class name to add. By convention, the class should be "objectclass.subclass", like Entity.caching to output messages related to caching Entity objects.

removeClass

public static boolean removeClass(java.lang.String debugClass)
Remove a class from the enabled debug classes.

Parameters:
debugClass - The class to remove.

setDebugStream

public static void setDebugStream(java.io.PrintStream debugStream)
Set the debugStream to use for output.

Parameters:
debugStream - The new stream to use

debug

public static void debug(java.lang.String debugClass,
                         java.lang.String output)
Output text to the PrintStream. No formatting is done.

Parameters:
debugClass - The class of this output string.
output - The data to output.

debugFormat

public static void debugFormat(java.lang.String debugClass,
                               java.lang.Object source,
                               java.lang.String resfile,
                               java.lang.String msgId)
Output data formatted using a resource file.

Parameters:
debugClass - The class of the output being generated
source - The object that's creating the output.
resfile - The resource file to use for formatting the output
msgId - The ID of the message in the resource file to create.

debugFormat

public static void debugFormat(java.lang.String debugClass,
                               java.lang.Object source,
                               java.util.Locale locale,
                               java.lang.String resFile,
                               java.lang.String msgId,
                               java.lang.Object[] args)
Output data formatted using a resource file.

Parameters:
debugClass - The class of the output.
source - The object that's creating the output
locale - The Locale object representing the current output locale (null for default).
resFile - The resource file to use to find the message.
msgId - The ID of the message to generate.
args - An array of arguments to provide for formatting the output.

debugStackTrace

public static void debugStackTrace(java.lang.String debugClass,
                                   java.lang.Object source,
                                   java.util.Locale locale,
                                   java.lang.String resFile,
                                   java.lang.Throwable t)
Output a stack track to the debug stream.

Parameters:
debugClass - The class of the output.
source - The object generating the output.
locale - The Locale representing the current output locale (null for default).
resFile - The resource file to use to generate the output.
ex - The exception which generated the stack trace

getDebugStream

public static java.io.PrintStream getDebugStream()
Get the PrintStream in use by the Debug class.

Returns:
The PrintStream being used for output.

getDebugStream

public static java.io.PrintStream getDebugStream(java.lang.String debugClass)
Get the PrintStream in use by the Debug class if the specified debugClass is activated.

Parameters:
debugClass - The class of the output.

Returns:
The PrintStream being used for output.