|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectd.p
public final class p
This class provides static methods which send output to a PrintWriter
.
You can use the various s methods to simply print out primitive types or Strings, or print out complete Object states.
The getPrintWriter()
/setPrintWriter(java.io.PrintWriter)
methods are the accessor/mutator for the PrintWriter used.
The default PrintWriter wraps System.out
.
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 have the minmal length (one char each). So, you can avoid import statements and easily invoke all methods using their fully qualified form. Here are some typical uses:
d.p.s(); // prints a blank line
...
d.p.s("reached point #1"); // use to note that your program reached a certain point
...
d.p.s(i); // i is an int, previously defined and assigned, that you now want to print
...
d.p.s("l = " + l); // print out some descriptive text followed by some long value
...
OneOfMyTypes myObject = new OneOfMyTypes();
d.p.s("Complete state of OneOfMyTypes", myObject); // print out an object's fields
Mnemonic: the package name d stands for debug; the class name p stands for PrintWriter; the methods named s stand for send.
This class is multithread safe.
Nested Class Summary | |
---|---|
static class |
p.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private static PrintWriter |
pw
The PrintWriter used by the s methods. |
Constructor Summary | |
---|---|
private |
p()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability. |
Method Summary | |
---|---|
static PrintWriter |
getPrintWriter()
Accessor for pw . |
private static void |
onShutdown()
Performs actions that should only be done before the JVM shuts down, such as flushing pw. |
static void |
s()
Prints a blank line. |
static void |
s(boolean b)
Prints b on a line. |
static void |
s(char c)
Prints c on a line. |
static void |
s(CharSequence charSequence)
Prints charSequence on a line. |
static void |
s(double d)
Prints d on a line. |
static void |
s(long l)
Prints l on a line. |
static void |
s(String label,
Object obj)
Prints out label followed by obj. |
static void |
setPrintWriter(PrintWriter pw)
Mutator for pw . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static PrintWriter pw
PrintWriter
used by the s
methods.
Constructor Detail |
---|
private p()
Method Detail |
---|
public static PrintWriter getPrintWriter()
pw
.
public static void setPrintWriter(PrintWriter pw) throws IllegalArgumentException
pw
.
Before the existing PrintWriter
is swapped out, it is first flushed.
This class is typically used for debugging. In this context, the I/O performance of pw is less important than its reliability. Therefore, it is highly recommended that the pw arg be set to autoflush, since otherwise have seen problems with output not appearing in a timely manner or at all.
IllegalArgumentException
- if pw == null; pw is in the error statepublic static void s() throws IllegalStateException
IllegalStateException
- if pw
is in the error statepublic static void s(boolean b) throws IllegalStateException
IllegalStateException
- if pw
is in the error statepublic static void s(char c) throws IllegalStateException
IllegalStateException
- if pw
is in the error statepublic static void s(long l) throws IllegalStateException
IllegalStateException
- if pw
is in the error statepublic static void s(double d) throws IllegalStateException
IllegalStateException
- if pw
is in the error statepublic static void s(CharSequence charSequence) throws IllegalStateException
IllegalStateException
- if pw
is in the error statepublic static void s(String label, Object obj) throws IllegalStateException
If label is non-null, it is printed followed by ": " on one line.
Next, the complete state of obj is printed using ObjectState
.
IllegalStateException
- if pw
is in the error stateprivate static void onShutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |