|
UC Berkeley Group for User Interface Research Updated November 17, 2000 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.berkeley.guir.lib.debugging.Debug
Lots of debugging utilities, including log file output, stream output, graphical window output, and object introspection.
Have an instance in each class you want and use that instance. For example:
private static final Debug debug = new Debug(Debug.ON);
Turn on debugging at runtime by setting the appropriate system environment variables. If no debugging output environment variables are set, debugging is off.
Here is an example of the introspection debugging:
This software is distributed under the Berkeley Software License.
Revisions: - GUIRLib-v1.0-1.0.0, Aug 25 1997, JH Created class - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH Touched for GUIRLib release - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH Touched for GUIRLib release - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH Touched for GUIRLib release
Field Summary | |
static boolean |
COMPILE_ASSERT
Set the guir.debug.assert system property to initialize this field. |
static boolean |
ENABLE_DEBUG
If one of guir.debug.output, guir.debug.window, or guir.debug.logerr is not set true, then this is false and turns off debugging output. |
static boolean |
LOGERR
Set the guir.debug.logerr system property to initialize this field. |
static boolean |
OFF
Constant for debug constructor to turn debugging off for this class. |
static boolean |
ON
Constant for debug constructor to turn debugging on for this class. |
static boolean |
OUTPUT
Set the guir.debug.output system property to initialize this field. |
static boolean |
WINDOW
Set the guir.debug.window system property to initialize this field. |
Constructor Summary | |
Debug()
Create a new debugging object. |
|
Debug(boolean newMode)
Create a new debugging object. |
Method Summary | |
void |
assert(boolean predicate,
String strErrorMessage)
Validate a predicate. |
static void |
displayObjectStream(Object obj)
Use introspection to debug an object, using the specified output i/o. |
static void |
displayObjectStream(Object obj,
OutputStream out)
Use introspection to debug an object, using the specified output i/o. |
static void |
displayObjectStream(Object obj,
PrintWriter out)
Use introspection to debug an object, using the specified output i/o. |
static void |
displayObjectTree(Object obj)
Use introspection to debug an object, using a JTree as output. |
static String[] |
getCallingClassAndMethod()
Get the name of the method that called you (the one that called the method that is calling this debug method). |
static String[] |
getCurrentClassAndMethod()
Get the name of the current method (the one that is calling this debug method). |
boolean |
getDebugMode()
|
DebugWindow |
getDebugWindow()
|
static void |
main(String[] argv)
|
void |
println()
Print out a blank line with no headers. |
void |
println(boolean flag)
|
void |
println(byte b)
|
void |
println(byte[] bArray)
|
void |
println(char ch)
|
void |
println(char[] chArray)
|
void |
println(double d)
|
void |
println(double[] dArray)
|
void |
println(float f)
|
void |
println(float[] fArray)
|
void |
println(int i)
|
void |
println(int[] intArray)
|
void |
println(Object obj)
Print out an error message. |
void |
println(Object[] objArray)
|
void |
println(Polygon poly)
This is because polygon is stoopid. |
void |
println(short s)
|
void |
println(short[] sArray)
|
void |
println(String str)
|
void |
println(Throwable e)
|
void |
printStackTrace()
Print the stack trace right now. |
void |
setDebug(boolean flag)
Turn debugging on or off. |
static void |
setUseShortClassNames(boolean flag)
Short class name is String . |
static void |
setUseWindow(boolean flag)
Create a new debug window and do output there. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean COMPILE_ASSERT
java -Dguir.debug.assert=true ...
public static boolean LOGERR
java -Dguir.debug.logerr=true ...
public static boolean WINDOW
java -Dguir.debug.window=true ...
public static boolean OUTPUT
java -Dguir.debug.output=true ...This will normally send output to stdout. The output stream can be redirected with method setOutput().
public static boolean ENABLE_DEBUG
public static final boolean ON
public static final boolean OFF
Constructor Detail |
public Debug()
public Debug(boolean newMode)
newMode
- is true if debugging is on, false otherwise.Method Detail |
public static void setUseShortClassNames(boolean flag)
String
. Long class name is
java.lang.String
.flag
- is true if short class names are to be used, false if
full package names are to be used.public static void setUseWindow(boolean flag)
public void setDebug(boolean flag)
public DebugWindow getDebugWindow()
public boolean getDebugMode()
public final void assert(boolean predicate, String strErrorMessage)
Sample: // This is okay. Assert.ASSERT(iValue > 0, "Message"); // This is also okay. Assert.ASSERT(cValue == 'a' || cValue == 'A', "Message"); // This is WRONG. Assert.ASSERT(iValue++, "Message");
predicate
- is an expression that evaluates to a boolean to test.
You should not pass in an expression with side any effects.strErrorMessage
- is the error message to print out if the
assertion should fail.AssertionFailedException
- if predicate is false.
AssertionFailedException is a subclass of
IllegalArgumentException, which is a RuntimeException.public void printStackTrace()
public static final String[] getCurrentClassAndMethod()
public static final String[] getCallingClassAndMethod()
public static void displayObjectTree(Object obj)
public static void displayObjectStream(Object obj, OutputStream out)
public static void displayObjectStream(Object obj, PrintWriter out)
public static void displayObjectStream(Object obj)
public final void println()
public void println(String str)
public final void println(Throwable e)
public final void println(Object obj)
obj
- is the Object to print out.public final void println(Object[] objArray)
public final void println(boolean flag)
public final void println(byte b)
public final void println(byte[] bArray)
public final void println(short s)
public final void println(short[] sArray)
public final void println(char ch)
public final void println(char[] chArray)
public final void println(double d)
public final void println(double[] dArray)
public final void println(float f)
public final void println(float[] fArray)
public final void println(int i)
public final void println(int[] intArray)
public final void println(Polygon poly)
Makes me wonder if there is some programming language model that lets you dynamically, safely, and securely attach methods to predefined classes, since developers can't always know beforehand what's needed.
public static void main(String[] argv)
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |