d
Class g

java.lang.Object
  extended by d.g

public final class g
extends Object

This class provides static methods which send output to a GUI.

This class was designed to require as little typing as possible to use. In particular, all public names (package, class, and method) are lower case and very short. So, you can avoid import statements and easily invoke all methods using their fully qualified form. Here is a typical use:


    StringBuilder sb = new StringBuilder();
    d.g.s(sb);
 

Mnemonic: the package name d stands for debug; the class name g stands for GUI; all the methods named s stand for send.

Like typical Java GUI code, this class's gui parts (the g.ObjectStateDisplay inner class) are not multithread safe: they expect to only be called by EventQueue's dispatch thread. Note, however, that the public API s methods may be safely called by any thread.

Author:
Brent Boyer

Nested Class Summary
private static class g.ObjectStateDisplay
          ...
static class g.UnitTest
          See the Overview page of the project's javadocs for a general description of this unit test class.
 
Constructor Summary
private g()
          This private constructor suppresses the default (public) constructor, ensuring non-instantiability.
 
Method Summary
static void s(Object obj)
          Simply calls s(null, obj, true).
static void s(Object obj, boolean pauseExecution)
          Simply calls s(null, obj, pauseExecution).
static void s(String label, Object obj)
          Simply calls s(label, obj, true).
static void s(String label, Object obj, boolean pauseExecution)
          Displays obj's state in a new window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

g

private g()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability.

Method Detail

s

public static void s(Object obj)
              throws RuntimeException
Simply calls s(null, obj, true).

Throws:
RuntimeException

s

public static void s(Object obj,
                     boolean pauseExecution)
              throws RuntimeException
Simply calls s(null, obj, pauseExecution).

Throws:
RuntimeException

s

public static void s(String label,
                     Object obj)
              throws RuntimeException
Simply calls s(label, obj, true).

Throws:
RuntimeException

s

public static void s(String label,
                     Object obj,
                     boolean pauseExecution)
              throws RuntimeException
Displays obj's state in a new window.

Any thread may call this method with any combination of params except this one situation: if EventQueue's dispatch thread calls this method, then the pauseExecution param must be false (if it were true, then the GUI would freeze).

Parameters:
label - text labelling the new window
obj - the object whose state is displayed; there are no constraints on it (e.g. may be null)
pauseExecution - if true, then executes synchronously (i.e. the calling Thread waits until the user either closes the window or clicks on the "Continue Execution" button before returning from this method); otherwise executes asynchornously (i.e. exits almost immediately, regardless of user input)
Throws:
RuntimeException - (or some subclass) if any error occurs; this may merely wrap some other underlying Throwable