de.enough.polish.preprocess
Class DebugManager

java.lang.Object
  extended by de.enough.polish.preprocess.DebugManager

public class DebugManager
extends Object

Administers the debug-level for all classes.

Copyright Enough Software 2004 - 2008

 history
        19-Jan-2003 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Field Summary
static int DEBUG
           
static int ERROR
           
static int FATAL
           
static int INFO
           
static int TRACE
           
static int UNDEFINED
           
static int USER_DEFINED
           
static int WARN
           
 
Constructor Summary
DebugManager(int debugLevel, boolean verbose)
          Creates a new debug manager.
DebugManager(LogSetting setting, ExtensionManager manager, Environment environment)
          Creates a new debug manager.
DebugManager(String debugLevel, boolean verbose)
          Creates a new debug manager.
 
Method Summary
 void addDebugSetting(String pattern, String level)
          Adds a debug setting for a specific class or class-pattern.
 int getClassLevel(String className)
          Determines the level for a given class.
 String[] getDebuggingSymbols(String className)
          Creates the J2ME Polish debugging symbols for the specified class.
 int getLevelOrder(String level)
          Retrieves the order of the given level.
 boolean isDebugEnabled(String className, String levelName)
          Checks if for the given class and level the debugging is enabled.
 boolean isVerbose()
          Determines whether the verbose mode is enabled.
 boolean useGui()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

TRACE

public static final int TRACE
See Also:
Constant Field Values

DEBUG

public static final int DEBUG
See Also:
Constant Field Values

INFO

public static final int INFO
See Also:
Constant Field Values

WARN

public static final int WARN
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

FATAL

public static final int FATAL
See Also:
Constant Field Values

USER_DEFINED

public static final int USER_DEFINED
See Also:
Constant Field Values
Constructor Detail

DebugManager

public DebugManager(String debugLevel,
                    boolean verbose)
Creates a new debug manager.

Parameters:
debugLevel - the basic debug level for all classes, for which no debug level has been defined, e.g. "debug", "info", "warn", "error", "fatal" or userdefined.
verbose - true when before every debug information the class-name and the line-number should be printed out.

DebugManager

public DebugManager(int debugLevel,
                    boolean verbose)
Creates a new debug manager.

Parameters:
debugLevel - the basic debug level for all classes, for which no debug level has been defined.
verbose - true when before every debug information the class-name and the line-number should be printed out.
See Also:
DEBUG, INFO, WARN, ERROR, FATAL

DebugManager

public DebugManager(LogSetting setting,
                    ExtensionManager manager,
                    Environment environment)
             throws BuildException
Creates a new debug manager.

Parameters:
setting - The settings for this manager.
manager - the extension manager
environment - the environment settings
Throws:
BuildException - when the pattern of an included debug-filter is invalid
Method Detail

addDebugSetting

public void addDebugSetting(String pattern,
                            String level)
                     throws BuildException
Adds a debug setting for a specific class or class-pattern.

Parameters:
pattern - the class-name or class-pattern. A pattern is like an import-declaration, e.g. "com.company.package.*"
level - the level which should be allowed, e.g. "debug", "info", "warn", "error", "fatal" or userdefined.
Throws:
BuildException - when the pattern is invalid

isVerbose

public boolean isVerbose()
Determines whether the verbose mode is enabled. When the verbose mode is enabled, the current time in ms, the name of the class as well as the line number in the source code will be printed out before each debugged information. Example: "34877 - com.company.package.MyClass - line 23"

Returns:
true when the verbose mode is enabled.

isDebugEnabled

public boolean isDebugEnabled(String className,
                              String levelName)
Checks if for the given class and level the debugging is enabled.

Parameters:
className - the name of the class, e.g. "com.company.packackge.MyClass"
levelName - the level, e.g. "debug", "info", "warn", "error", "fatal" or userdefined.
Returns:
true when for the given class and level the debugging is enabled.

getClassLevel

public int getClassLevel(String className)
Determines the level for a given class.

Parameters:
className - the name of the class, e.g. "com.company.packackge.MyClass"
Returns:
the level assigned to the given class, either DEBUG, INFO, WARN, ERROR, FATAL or USER_DEFINED.

getLevelOrder

public int getLevelOrder(String level)
Retrieves the order of the given level.

Parameters:
level - the name of the level, e.g. "debug"
Returns:
the order or weight of the level

useGui

public boolean useGui()
Returns:
true when the visual gui mode is enabled.

getDebuggingSymbols

public String[] getDebuggingSymbols(String className)
Creates the J2ME Polish debugging symbols for the specified class. Example symbols are "polish.debug.info", "polish.debug.debug", "polish.debug.error".

Parameters:
className - the name of the class
Returns:
a String array with one preprocessing symbol for each supported debugging level.