public final class Debug extends java.lang.Object implements DebugMBean
Modifier and Type | Field and Description |
---|---|
static boolean |
ENABLE_ASSERTION
has to be set in order to enable assertion
|
static boolean |
ENABLE_DEBUG
has to be set in order to enable debugging
|
static java.lang.String[] |
showOnlyPrefixes
Using the command line switch "-Dkey.debug.prefix" one can choose
of which classes the debug output is to be send to the standard
output.
|
Constructor and Description |
---|
Debug() |
Modifier and Type | Method and Description |
---|---|
static void |
assertDeepNonNull(java.lang.Iterable<?> iterable,
java.lang.String message)
an assertion failure is thrown if an iterable object is either null or
contains the null element.
|
static void |
assertFalse(boolean isNotOK) |
static void |
assertFalse(boolean isNotOK,
java.lang.String message) |
static void |
assertTrue(boolean isOK)
an assertion failure is thrown if isOK is evaluated to false
|
static void |
assertTrue(boolean isOK,
java.lang.String message)
an assertion failure is thrown if isOK is evaluated to false the text in
message is handed over to this exception
|
static void |
assertTrue(boolean isOK,
java.lang.String message,
java.lang.Object parameter)
an assertion failure is thrown if isOK is evaluated to false the text in
message is handed over to this exception
|
private static void |
dbgPrint(java.lang.String string)
print a string to stdout, prefixed by the execution context of the caller
of the calling function.
|
static void |
fail() |
static void |
fail(java.lang.String message) |
static void |
fail(java.lang.String message,
java.lang.Object o) |
static java.lang.String |
getClassAndMethod()
return information about the current execution context (and line number
if available) as a string.
|
private static java.lang.String |
getClassAndMethod(int level)
return information about some execution context.
|
boolean |
getDebugState()
get the current debug state.
|
java.lang.String |
getShowOnlyPrefixes()
get the list of prefixes for which messages are shown.
|
static void |
log4jDebug(java.lang.String msg,
java.lang.String loggerID) |
static void |
log4jError(java.lang.String msg,
java.lang.String loggerID) |
static void |
log4jInfo(java.lang.String msg,
java.lang.String loggerID) |
static void |
log4jWarn(java.lang.String msg,
java.lang.String loggerID) |
static void |
out(java.lang.Exception e)
prints the stack trace if in debug mode
|
static void |
out(java.lang.String msg)
prints given string if in debug mode
|
static void |
out(java.lang.String msg,
boolean b)
prints the given string followed by the boolean if in debug mode.
|
static void |
out(java.lang.String msg,
long id)
prints the given string followed by the int if in debug mode.
|
static void |
out(java.lang.String msg,
long id1,
long id2)
prints the given string followed by the int if in debug mode.
|
static void |
out(java.lang.String msg,
java.lang.Object obj)
prints given string and the result of calling the toString method of of
the given obj if in debug mode.
|
static void |
out(java.lang.String msg,
java.lang.Object obj1,
java.lang.Object obj2)
prints given string and the result of calling the toString method of of
the given objects if in debug mode.
|
static void |
out(java.lang.String msg,
java.lang.Object obj1,
java.lang.Object obj2,
java.lang.Object obj3)
prints given string and the result of calling the toString method of of
the given objects if in debug mode.
|
static void |
out(java.lang.String msg,
java.lang.Throwable exc)
prints the given string followed by the stacktrace of the throwable
object.
|
static void |
outIfEqual(java.lang.String msg,
boolean cond)
prints given string, if the condition cond is true
|
static void |
outIfEqual(java.lang.String msg,
java.lang.Object obj1,
java.lang.Object obj2)
prints given string, if calling the equal method of obj1, with obj2 as
argument results in true
|
static void |
printStackTrace()
Prints a stack trace (without influencing the execution in any way).
|
static void |
printStackTrace(java.lang.Throwable e) |
void |
setDebugState(boolean debug)
set the current debug state.
|
void |
setShowOnlyPrefixes(java.lang.String showOnlyPrefixes)
set the list of prefixes for which messages are shown.
|
static java.lang.String |
stackTrace() |
public static boolean ENABLE_ASSERTION
public static boolean ENABLE_DEBUG
public static java.lang.String[] showOnlyPrefixes
public static void out(java.lang.String msg)
msg
- the String to be printedpublic static void out(java.lang.String msg, java.lang.Throwable exc)
msg
- message to be printedexc
- a throwable objectpublic static final void out(java.lang.String msg, java.lang.Object obj)
msg
- the String to be printedobj
- the Object where to call the toString methodpublic static final void out(java.lang.String msg, java.lang.Object obj1, java.lang.Object obj2)
msg
- the String to be printedobj1
- the first Object where to call the toString methodobj2
- the second Object where to call the toString methodpublic static final void out(java.lang.String msg, java.lang.Object obj1, java.lang.Object obj2, java.lang.Object obj3)
msg
- the String to be printedobj1
- the first Object where to call the toString methodobj2
- the second Object where to call the toString methodobj3
- the third Object where to call the toString methodpublic static final void out(java.lang.String msg, long id)
msg
- the String to be printedid
- the int printed after msgpublic static final void out(java.lang.String msg, long id1, long id2)
msg
- the String to be printedid1
- the int printed first after msgid2
- the int printed second after msgpublic static final void out(java.lang.String msg, boolean b)
msg
- the String to be printedb
- the boolean printed after msgpublic static final void outIfEqual(java.lang.String msg, boolean cond)
msg
- the String to be printedcond
- the boolean deciding if the message is printed or notpublic static final void outIfEqual(java.lang.String msg, java.lang.Object obj1, java.lang.Object obj2)
msg
- the String to be printedobj1
- the Object where to call the equals methodobj2
- the Object given to as parameter of the equals method of obj1public static final void out(java.lang.Exception e)
public static final void printStackTrace(java.lang.Throwable e)
public static final void assertTrue(boolean isOK)
isOK
- boolean the assertion that is checkedpublic static final void assertFalse(boolean isNotOK)
public static final void assertTrue(boolean isOK, java.lang.String message)
isOK
- boolean the assertion that is checkedmessage
- String describes the failed assertionpublic static final void assertTrue(boolean isOK, java.lang.String message, java.lang.Object parameter)
isOK
- boolean the assertion that is checkedmessage
- String describes the failed assertionpublic static final void assertDeepNonNull(java.lang.Iterable<?> iterable, java.lang.String message)
iterable
- The iterable object to checkmessage
- String describes the failed assertionpublic static final void assertFalse(boolean isNotOK, java.lang.String message)
public static final void fail()
public static final void fail(java.lang.String message)
public static final void fail(java.lang.String message, java.lang.Object o)
private static final void dbgPrint(java.lang.String string)
showOnlyPrefixes
is defined, the output is only written, if
the caller prefix begins with one of the specified stringsstring
- string to be printed outpublic static final void printStackTrace()
public static java.lang.String stackTrace()
public static java.lang.String getClassAndMethod()
de.uka.package.ClassName.methodName(ClassName.java:123)It uses the context of the calling method.
private static java.lang.String getClassAndMethod(int level)
level
- to go up in the context hierarchypublic void setDebugState(boolean debug)
DebugMBean
setDebugState
in interface DebugMBean
debug
- the new debug state to setpublic boolean getDebugState()
DebugMBean
getDebugState
in interface DebugMBean
public java.lang.String getShowOnlyPrefixes()
DebugMBean
getShowOnlyPrefixes
in interface DebugMBean
public void setShowOnlyPrefixes(java.lang.String showOnlyPrefixes)
DebugMBean
setShowOnlyPrefixes
in interface DebugMBean
showOnlyPrefixes
- a ":"-separated list of prefixespublic static void log4jDebug(java.lang.String msg, java.lang.String loggerID)
public static void log4jInfo(java.lang.String msg, java.lang.String loggerID)
public static void log4jWarn(java.lang.String msg, java.lang.String loggerID)
public static void log4jError(java.lang.String msg, java.lang.String loggerID)