|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.util.Debug
Class Debug holds the global environment settings and provides
a few utility methods that are used throughout all of the framework code.
Several flags are defined that apply to debug tracing (outputs), which makes
handling the different trace outputs easier. To begin, there is a global flag
DebugMode.DEBUG, which indicates that you want to build a debug
version or alternatively a release version of the software. Because of the
final declaration, the compiler can perform some optimizations on the
compiled code, so that a release class file is smaller than the debug
class file. Secondly, the debug tracing outputs are categorized so that it
becomes possible to turn off a complete category of traces. For example, the
DISPLAY_THROWABLES flag can be checked while used in combination
with try ... catch statements like the following code segment:
try
{
...
}
catch( Throwable throwable )
{
if( Debug.DISPLAY_THROWABLES )
{
throwable.printStackTrace()
}
}
If a flag is used in this way in all of the classes, you can turn on and off
all of the trace outputs that are part of a Throwable catch.
Another example is the DISPLAY_DEBUG_INFOS category, which
should be used in this way:
if( Debug.DISPLAY_DEBUG_INFOS )
{
System.out.println("do some tracings here ...")
}
By using this flag you can turn on and off all tracings that belongs
to the new category. Lastly, you can optionally define a flag in each class,
giving you the possibility to turn on and off the trace outputs for that specific
class. Remember that there can be a lot of traces to an output stream
and that you may have to search for specific trace information while debugging.
Using a combination of trace output flags, you can trace specific information
by turning on useful categories and turning off those that are not needed.
The if statement therefore looks like this:
if( Debug.DISPLAY_DEBUG_INFOS )
{
System.out.println("do some tracings here ...")
}
The trace output flags defined in specific classes should be set to
false by default.
Class Debug provides static methods only and no public constructors.
DebugMode.DEBUG flag
will disable all other global debugging info.
| Nested Class Summary | |
static class |
Debug.OnlyDoLastTriggered
This class uses the SwingUtilities.invokeLater(java.lang.Runnable) method to ensure
that a piece of code is only run once after all events have been
processed. |
| Field Summary | |
static boolean |
ALLOW_DYNAMIC_EXCEPTIONS
Global flag to allow throwing of DynamicExceptions |
static boolean |
ASSERT_THROWS_EXCEPTION
Determines whether to throw an assertion exception in case a check failed. |
static boolean |
DISPLAY_DEBUG_INFOS
global flag to turn on/turn off all tracings which are needed for debugging purposes This flag is dynamic and subject to change during runtime. |
static boolean |
DISPLAY_DEPRECATIONS
global flag to turn on/turn off all traces related to deprecations. |
static boolean |
DISPLAY_ERRORS
global flag to turn on/turn off all tracings related to errors. |
static boolean |
DISPLAY_OBSOLETE_INFO
global flag to turn on/turn off all traces related to obsolete data, method calls and such. |
static boolean |
DISPLAY_STATIC_INFOS
global flag to turn on/off static traces |
static boolean |
DISPLAY_THROWABLES
global flag to turn on/turn off all tracings related to throwables This flag is dynamic and subject to change during runtime. |
static boolean |
DISPLAY_WARNINGS
global flag to turn on/turn off all tracings related to warnings. |
static boolean |
DO_ASSERT
Globally enables or disables assertion checks. |
| Method Summary | |
static java.lang.String |
bits(int value)
Returns a string representation of a bit pattern. |
static java.lang.String |
createIndentation(java.lang.String string,
char blockStart,
char blockEnd)
Creates an indentation in the given string by using the given characters to increase or decrease indentation per line. |
static java.lang.String |
getMaskInfo(int mask,
int[] flags,
java.lang.String[] flagNames)
Returns a human readable string containing the ids of all flags that are set in the given mask. |
static java.lang.String |
getThrowableStackString(java.lang.Throwable t)
Returns a string containing the stack trace |
static java.lang.String |
getThrowableStackString(java.lang.Throwable t,
int maxLineCount)
Returns a string containing the stack trace |
static java.lang.String |
hashcode(java.lang.Object object)
Prints an object hashcode in a standard way. |
static java.lang.String |
hexStr(int i,
int len)
Returns a hex string for the given integer with at least the length len |
static boolean |
isPartOfStackTrace(java.lang.String pattern)
Returns true, if the current stack trace contains the given pattern. |
static java.lang.String |
list2String(java.util.List list)
Returns a String that represents the content of the
List given by list. |
static java.lang.String |
makeIndent(int level)
Returns a String that can be used as an indent when
displaying a hierarchy. |
static void |
printBlueStackTrace()
Displays a blue stack trace, used to check from where a method is called. |
static void |
printBlueStackTrace(int maxLineCount)
Displays a blue stack trace, used to check from where a method is called. |
static void |
printBlueStackTrace(java.lang.Throwable t,
int maxLineCount)
Displays a blue stack trace, used to check from where a method is called. |
static void |
printDebugInfo(java.lang.String message)
Prints a debug info message in a standard way. |
static void |
printDeprecation(java.lang.String message)
Prints a deprecation message in a standard way. |
static void |
printError(java.lang.String message)
Prints an error in a standard way. |
static void |
printMap(java.util.Map map)
Prints a map. |
static void |
printMapHashcodes(java.util.Map map)
Prints a map in hashcode format to stderr. |
static void |
printMapSorted(java.util.Map map)
Prints a map alphabetically sorted. |
static void |
printMapSortedHashcodes(java.util.Map map)
Prints a map alphabetically sorted and just print the hashcodes of the keys and values. |
static void |
printObsoleteInfo(java.lang.String message)
Prints a obsolete info message in a standard way. |
static void |
printSet(java.util.Set set)
Method printSet prints all elements of the parameter set to System.err. |
static void |
printStaticInfo(java.lang.String message)
|
static void |
printThrowable(java.lang.Throwable throwable)
Prints a throwable in a standard way. |
static void |
printWarning(java.lang.String message)
Prints a warning in a standard way. |
static void |
printWarning(java.lang.String message,
boolean toStdOut)
Prints a warning in a standard way. |
static boolean |
safeEquals(java.lang.Object obj1,
java.lang.Object obj2)
Deprecated. Use Comparison.safeEquals(Object, Object) instead! |
static boolean |
safeEqualsIgnoreCase(java.lang.String str1,
java.lang.String str2)
Deprecated. Use Comparison.safeEqualsIgnoreCase(String, String)
instead! |
static int |
safeHashCode(java.lang.Object obj)
Deprecated. Use Comparison.safeHashCode(Object) instead! |
static java.lang.String |
strReplace(java.lang.String string,
java.lang.String token,
java.lang.String replaceString)
String replace function, replaces all occurances of the token in the string with another string (Only necessary, because String.replaceAll(
java.lang.String, java.lang.String) is not implemented in jdk1.3). |
static java.lang.String[] |
strSplit(java.lang.String str,
java.lang.String delimiters)
Splits a string into an array of strings using the given delimiters. |
static java.lang.String |
toIndentedString(java.lang.String str,
int level)
Returns a string with an indentation after each linefeed |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final boolean DO_ASSERT
public static final boolean ASSERT_THROWS_EXCEPTION
public static final boolean ALLOW_DYNAMIC_EXCEPTIONS
public static final boolean DISPLAY_THROWABLES
public static final boolean DISPLAY_WARNINGS
public static final boolean DISPLAY_ERRORS
public static final boolean DISPLAY_DEBUG_INFOS
public static final boolean DISPLAY_OBSOLETE_INFO
public static final boolean DISPLAY_DEPRECATIONS
public static final boolean DISPLAY_STATIC_INFOS
| Method Detail |
public static final void printObsoleteInfo(java.lang.String message)
message - the debug info message to print.public static final void printDeprecation(java.lang.String message)
message - the deprecation message to print.public static final void printDebugInfo(java.lang.String message)
message - the debug info message to print.public static final void printThrowable(java.lang.Throwable throwable)
throwable - the throwable to print.public static final void printError(java.lang.String message)
message - the error message to print.public static final void printWarning(java.lang.String message)
message - the warning message to print.
public static final void printWarning(java.lang.String message,
boolean toStdOut)
message - the warning message to print.toStdOut - true, to print to out instead of errpublic static final void printStaticInfo(java.lang.String message)
public static final void printMap(java.util.Map map)
map - the map to print.public static final void printMapHashcodes(java.util.Map map)
map - the map to print.public static final void printSet(java.util.Set set)
System.err.
set - the instance of Set to print out.public static final void printMapSorted(java.util.Map map)
map - the map to print.public static final void printMapSortedHashcodes(java.util.Map map)
map - the map to print.public static final java.lang.String hashcode(java.lang.Object object)
object - the Object to retirive the hashcode for.
public static final java.lang.String bits(int value)
value - the value to return a bit representation for.
public static final java.lang.String makeIndent(int level)
String that can be used as an indent when
displaying a hierarchy. The int given by level
represents the level of indentation.
level - the level of indentation
public static final java.lang.String list2String(java.util.List list)
String that represents the content of the
List given by list.
list - the List to convert into a String
representation
Listpublic static final void printBlueStackTrace()
public static final void printBlueStackTrace(int maxLineCount)
maxLineCount - The maximum number of rows to display
public static final void printBlueStackTrace(java.lang.Throwable t,
int maxLineCount)
t - The throwable to print the stack trace ofmaxLineCount - The maximum number of rows to displaypublic static final boolean isPartOfStackTrace(java.lang.String pattern)
pattern - The item to look for in the stack trace
public static java.lang.String getThrowableStackString(java.lang.Throwable t)
t - The throwable to get the stack from
public static java.lang.String getThrowableStackString(java.lang.Throwable t,
int maxLineCount)
t - The throwable to get the stack frommaxLineCount - The maximum number of line to generate
public static java.lang.String toIndentedString(java.lang.String str,
int level)
str - The string to changelevel - The level of indentation to apply
public static java.lang.String createIndentation(java.lang.String string,
char blockStart,
char blockEnd)
string - The string to modifyblockStart - When this char occurs in a line, the FOLLOWING lines
will be indented.blockEnd - When this char occurs in a line, the indentation
will be decreased, starting in this line.
public static java.lang.String strReplace(java.lang.String string,
java.lang.String token,
java.lang.String replaceString)
String.replaceAll(
java.lang.String, java.lang.String) is not implemented in jdk1.3).
string - The original stringtoken - The substring to look forreplaceString - The string to replace the token with
public static final java.lang.String[] strSplit(java.lang.String str,
java.lang.String delimiters)
str - The string to splitdelimiters - The delimiters
public static java.lang.String hexStr(int i,
int len)
i - The integer to representlen - The minimum length of the string
public static final java.lang.String getMaskInfo(int mask,
int[] flags,
java.lang.String[] flagNames)
mask - the mask to examineflags - the flag values to look forflagNames - the names to return in the string
public static final boolean safeEquals(java.lang.Object obj1,
java.lang.Object obj2)
Comparison.safeEquals(Object, Object) instead!
obj1 - The first objectobj2 - The second object
public static final boolean safeEqualsIgnoreCase(java.lang.String str1,
java.lang.String str2)
Comparison.safeEqualsIgnoreCase(String, String)
instead!
str1 - The first stringstr2 - The second string
public static final int safeHashCode(java.lang.Object obj)
Comparison.safeHashCode(Object) instead!
obj - The object to get the hashcode of
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||