de.jaetzold.util
Class Debug

java.lang.Object
  |
  +--de.jaetzold.util.Debug

public class Debug
extends Object

This class encapsulates common code for debugging


Field Summary
 String className
          Name of the class, including package-name.
 boolean debug
          Reflects the value of the property className.debug at the time this class had been initialized.
 int errorLevel
          Set verbosity of error messages.
 int infoLevel
          Set verbosity of informational messages.
 String objectIdentifier
           
 
Constructor Summary
Debug(String className)
          Constructs a new debug-object for the Class named className.
 
Method Summary
 String createObjectIdentifier()
           
 String getCurrentStackTraceString()
           
 String getIdentifierFor(Object o)
           
 String getProperty(String name)
           
 void printError(int level, String message)
          Print message on stdout if level<=errorLevel or debug==true.
 void printError(String message)
          Print className and message on stderr
 void printInfo(int level, String message)
          Print message on stdout if level<=infoLevel or debug==true.
 void printInfo(String message)
          Print className and message on stdout
 String stackTraceToString(Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

className

public String className
Name of the class, including package-name. Useful for knowing the classname even in static-methods. Used as the header for any properties.
See Also:
debug

objectIdentifier

public String objectIdentifier

debug

public boolean debug
Reflects the value of the property className.debug at the time this class had been initialized. If such a property does not exist enclosing packages are tried for this property.

Example: If the package name is a.b and the class is called C, debug will be true if the property

In any other case debug will be set to false.

See Also:
className, printError(String), printInfo(String)

errorLevel

public int errorLevel
Set verbosity of error messages. The higher the value, the more and/or longer messages. A value of -1 switches (nearly) all error messages off. This value can be set as a System-Property similar to debug.
See Also:
debug, printError(int,String)

infoLevel

public int infoLevel
Set verbosity of informational messages. The higher the value, the more and/or longer messages. A value of -1 switches (nearly) all informational messages off. This value can be set as a System-Property similar to debug.
See Also:
debug, printInfo(int,String)
Constructor Detail

Debug

public Debug(String className)
Constructs a new debug-object for the Class named className. The given String should be full qualified classname (including package-name) for the normal funtion of this Debug-Object but any String is possible as the name isn't used to access a class.
Method Detail

createObjectIdentifier

public String createObjectIdentifier()

getIdentifierFor

public String getIdentifierFor(Object o)

getProperty

public String getProperty(String name)

getCurrentStackTraceString

public String getCurrentStackTraceString()

stackTraceToString

public String stackTraceToString(Throwable t)

printError

public void printError(String message)
Print className and message on stderr
See Also:
className, printInfo(String)

printInfo

public void printInfo(String message)
Print className and message on stdout
See Also:
className, printError(String)

printInfo

public void printInfo(int level,
                      String message)
Print message on stdout if level<=infoLevel or debug==true.
See Also:
infoLevel, debug

printError

public void printError(int level,
                       String message)
Print message on stdout if level<=errorLevel or debug==true.
See Also:
errorLevel, debug