com.sun.javatest.util
Class Debug

java.lang.Object
  extended by com.sun.javatest.util.Debug

public class Debug
extends java.lang.Object

Access to debugging settings which have been activated. Indexing is by string matching; the key is usually but not always a fully qualified classname.

The system properties have three classes of "value" data. The string may be equal to the string "true" (case insensitive), it may be parsable into an integer (by Integer.parseInt()), or it may be any other string. In the latter case where it is not TRUE and is not an int, it will be interpreted as a zero if a integer is requested, and FALSE if a boolean is requested.

The following definitions define how integer and boolean settings are interpreted:

A lookup that results in a valid integer:
Will return that integer for any of the getInt() methods
Will return false for any getBoolean() method if the integer is less than or equal to zero
Will return true for and getBoolean() method if the integer is greater than zero
A lookup that results in "true" (any case combination):
Will return one for any of the getInt() methods
Will return true for any of the getBoolean() methods
A lookup that results in neither of the above cases (not "true", nor an integer):
Will return zero for any of the getInt() methods
Will return false for any of the getBoolean() methods

See Also:
Integer.parseInt(java.lang.String, int)

Method Summary
static boolean getBoolean(java.lang.Class c)
          Find out the debugging setting for class c.
static boolean getBoolean(java.lang.Class c, java.lang.String suffix)
          Find out the debugging setting for class c.
static boolean getBoolean(java.lang.String s)
          Get a named debugging setting.
static int getInt(java.lang.Class c)
          Find out the debugging setting for class c.
static int getInt(java.lang.Class c, java.lang.String suffix)
          Find out the debugging setting for class c.
static int getInt(java.lang.String s)
          Get a named debugging setting.
static java.lang.String getSetting(java.lang.String key)
          Do a raw lookup of a key, including matching of wildcard settings.
static java.io.PrintWriter getWriter()
          Get the debugging stream, used for writing debug messages.
static void init(boolean force)
          Initialize (or re-initialize) debugging support.
static boolean isEnabled()
          Check if overall debugging is enabled.
static void print(java.lang.String s)
          Print a debugging message.
static void println(java.lang.String s)
          Print a debugging message and end the line.
static void setProperties(java.util.Properties props)
          Set properties containing debugging settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

print

public static void print(java.lang.String s)
Print a debugging message.

Parameters:
s - the message to be printed.

println

public static void println(java.lang.String s)
Print a debugging message and end the line.

Parameters:
s - the message to be printed.

isEnabled

public static boolean isEnabled()
Check if overall debugging is enabled. If it is not enabled, methods will return null, false, and zero, as appropriate for the type.

Returns:
true if debugging is enabled, and false otherwise

getSetting

public static java.lang.String getSetting(java.lang.String key)
Do a raw lookup of a key, including matching of wildcard settings. Is the given string matched by any of the debug system properties. The matching is done according to import-style semantics, using the dot separator. In addition wildcards from the system properties are allowed at the end of the key specification. Unlike imports, the wildcard can match inner class names.

Parameters:
key - The name of the setting to be returned
Returns:
The setting, or null if not found. Null is returned if debugging is disabled entirely.

getBoolean

public static boolean getBoolean(java.lang.Class c)
Find out the debugging setting for class c. Lookup is done by looking for fully qualified class name.

Parameters:
c - Class whose name should be used to lookup the setting, null results in a return value of zero.
Returns:
the debugging setting for the specified class

getBoolean

public static boolean getBoolean(java.lang.Class c,
                                 java.lang.String suffix)
Find out the debugging setting for class c. Lookup is done by looking for fully qualified class name with a dot and the given suffix appended.

Parameters:
c - Class whose name should be used to lookup the setting, null results in a return value of zero.
suffix - String to append to the classname, null will result in a lookup of just the classname.
Returns:
the debugging setting for the specified class

getBoolean

public static boolean getBoolean(java.lang.String s)
Get a named debugging setting.

Parameters:
s - the name of the desired debugging setting
Returns:
the value of the debugging setting

getInt

public static int getInt(java.lang.Class c)
Find out the debugging setting for class c. Lookup is done by looking for fully qualified class name.

Parameters:
c - the class whose name should be used to lookup the setting
Returns:
the debugging setting for the given class, or 0 if no class was specified

getInt

public static int getInt(java.lang.Class c,
                         java.lang.String suffix)
Find out the debugging setting for class c. Lookup is done by looking for fully qualified class name with a dot and the given suffix appended.

Parameters:
c - a class whose name should be used to lookup the setting; null results in a return value of zero.
suffix - a string to append to the classname; null will result in a lookup of just the classname.
Returns:
the debugging setting for the class

getInt

public static int getInt(java.lang.String s)
Get a named debugging setting.

Parameters:
s - the name of the desired debugging setting
Returns:
the value of the debugging setting

getWriter

public static java.io.PrintWriter getWriter()
Get the debugging stream, used for writing debug messages.

Returns:
the debugging stream, used to write debug messages

setProperties

public static void setProperties(java.util.Properties props)
Set properties containing debugging settings. This is required if the security manager does not allow access to the system properties.

Parameters:
props - A table of properties containing debugging settings

init

public static void init(boolean force)
Initialize (or re-initialize) debugging support.

Parameters:
force - Force reprocessing of System properties.


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.