|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.mortbay.util.Code
Coding Standards support. Support for defensive programming Coding defensively as follows:
{
...
Code.assertTrue(booleanExpression(),"Assert that expression evaluates true");
...
Code.assertEquals(objectA,objectB,"Assert equality");
Code.assertEquals(1,2,"Assert equality");
...
Code.debug("Debug message");
...
Code.debug("Debug message",exception,object);
...
Code.warning("warning message");
...
Code.warning("warning message",exception);
...
Code.notImplemented();
Code.fail("fatal error");
...
}
The debug output can be controlled with java properties:
java [-DDEBUG [-DDEBUG_PATTERNS="MyClass,my.package"] \\
[-DDEBUG_OPTIONS=[S][W]] \\
[-DDEBUG_VERBOSE=n] ] \\
my.package.main
| Nested Class Summary | |
static class |
Code.LogMsg
Log Message Object passed to the Log by Code. |
| Method Summary | |
static void |
assertContains(java.lang.String string,
java.lang.String sub,
java.lang.String m)
Check assertion that a string is a substring of another. |
static void |
assertEquals(char o1,
char o2,
java.lang.String m)
Check assertion that o1==o2. |
static void |
assertEquals(double o1,
double o2,
java.lang.String m)
Check assertion that o1==o2. |
static void |
assertEquals(long o1,
long o2,
java.lang.String m)
Check assertion that o1==o2. |
static void |
assertEquals(java.lang.Object o1,
java.lang.Object o2,
java.lang.String m)
Check assertion that o1==o2. |
static void |
assertTrue(boolean b,
java.lang.String m)
Check assertion that a boolean is true. |
static boolean |
debug()
Get debug status for the current stack frame. |
static void |
debug(int depth,
java.lang.Object o)
Debug with frame depth. |
static void |
debug(java.lang.Object o)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
long l)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
long l1,
java.lang.Object o2,
long l2)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6,
java.lang.Object o7)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6,
java.lang.Object o7,
java.lang.Object o8)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.String m)
Programming debugging output sent to the Log. |
static void |
debug(java.lang.String m,
java.lang.Throwable ex)
As debug(String) Do not rely on side-effects |
static void |
debug(java.lang.Throwable ex)
As debug(String) Dont rely on side-effects |
static void |
fail(java.lang.String m)
Programmer initiated fatal CodeException. |
static void |
fail(java.lang.String m,
java.lang.Throwable ex)
Programmer initiated fatal error. |
static void |
fail(java.lang.Throwable ex)
Programmer initiated fatal error. |
static boolean |
getDebug()
Get the debug status. |
static java.lang.String |
getDebugPatterns()
Get the debug patterns. |
static boolean |
getSuppressStack()
Get the stack suppression status. |
static boolean |
getSuppressWarnings()
Get the warnings suppression status. |
static int |
getVerbose()
Get the verbosity level. |
static void |
ignore(java.lang.Throwable ex)
Ignore an exception. |
static Code |
instance()
|
static void |
notImplemented()
Standard fatal error for a method not yet implemented. |
static void |
setDebug(boolean debug)
Set if debugging is on or off. |
static void |
setDebugPatterns(java.lang.String patterns)
Set debug patterns. |
static void |
setSuppressStack(boolean stack)
Suppress stack trace. |
static void |
setSuppressWarnings(boolean warnings)
Set warning suppression. |
static void |
setVerbose(int verbose)
Set verbosity level. |
static boolean |
verbose()
Get verbosity level. |
static boolean |
verbose(int v)
Get verbosity level. |
static void |
warning(java.lang.String m)
Programmer initiated warning, intended to be viewed by technical not operational staff. |
static void |
warning(java.lang.String m,
java.lang.Throwable ex)
Programmer initiated warning, intended to be viewed by technical not operational staff. |
static void |
warning(java.lang.Throwable ex)
Programmer initiated warning, intended to be viewed by technical not operational staff. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static Code instance()
public static void setDebug(boolean debug)
debug - public static boolean getDebug()
public static void setSuppressStack(boolean stack)
stack - if true stacks are not producedpublic static boolean getSuppressStack()
public static void setSuppressWarnings(boolean warnings)
warnings - Warnings suppress if this is true and debug is falsepublic static boolean getSuppressWarnings()
public static void setVerbose(int verbose)
verbose - public static int getVerbose()
public static void setDebugPatterns(java.lang.String patterns)
patterns - comma separated string of patternspublic static java.lang.String getDebugPatterns()
public static void assertTrue(boolean b,
java.lang.String m)
b - The boolean to assert is truem - Message to log if assertion fails
CodeException - Thrown if assertion fails
public static void assertEquals(java.lang.Object o1,
java.lang.Object o2,
java.lang.String m)
o1 - The first object to checko2 - The first object to checkm - Message to log if assertion fails
CodeException - Thrown if assertion fails
public static void assertEquals(long o1,
long o2,
java.lang.String m)
o1 - The first long to checko2 - The first long to checkm - Message to log if assertion fails
CodeException - Thrown if assertion fails
public static void assertEquals(double o1,
double o2,
java.lang.String m)
o1 - The first double to checko2 - The first double to checkm - Message to log if assertion fails
CodeException - Thrown if assertion fails
public static void assertEquals(char o1,
char o2,
java.lang.String m)
o1 - The first char to checko2 - The first char to checkm - Message to log if assertion fails
CodeException - Thrown if assertion fails
public static void assertContains(java.lang.String string,
java.lang.String sub,
java.lang.String m)
string - The stringsub - The sub stringm - Message to log if assertion fails
CodeException - Thrown if assertion failspublic static void warning(java.lang.String m)
m - The message body of the warning
public static void warning(java.lang.String m,
java.lang.Throwable ex)
m - The message body of the warningex - A Throwable objectpublic static void warning(java.lang.Throwable ex)
ex - A Throwable objectpublic static void fail(java.lang.String m)
m - The message body to log with the fatal error
CodeException - thrown to cause fatal error
public static void fail(java.lang.String m,
java.lang.Throwable ex)
m - The message body to log with the fatal errorex - The Throwable to print the full stack trace of
CodeException - thrown to cause fatal errorpublic static void fail(java.lang.Throwable ex)
ex - The Throwable to print the full stack trace of
CodeException - thrown to cause fatal errorpublic static void notImplemented()
public static boolean verbose()
public static boolean verbose(int v)
v - verbosity level to check against
public static boolean debug()
public static void debug(java.lang.String m)
m - The debug message to log.
public static void debug(java.lang.String m,
java.lang.Throwable ex)
m - The debug message to log.ex - The Throwable to print the full stack trace ofpublic static void debug(java.lang.Throwable ex)
ex - The Throwable to print the full stack trace of
public static void debug(int depth,
java.lang.Object o)
depth - Depth of debug frame, 1=caller, 2=callers caller...o - Objectpublic static void debug(java.lang.Object o)
o - The Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
long l)
o1 - An Object to pass to the debug Log.l - a long to wrap as a Long and pass to Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.o3 - Another Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.o3 - Another Object to pass to the debug Log.o4 - Another Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
long l1,
java.lang.Object o2,
long l2)
o1 - An Object to pass to the debug Log.l1 - a long to wrap as a Long and pass to Log.o2 - Another Object to pass to the debug Log.l2 - Another long to wrap as a Long and pass to Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.o3 - Another Object to pass to the debug Log.o4 - Another Object to pass to the debug Log.o5 - Another Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.o3 - Another Object to pass to the debug Log.o4 - Another Object to pass to the debug Log.o5 - Another Object to pass to the debug Log.o6 - Another Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6,
java.lang.Object o7)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.o3 - Another Object to pass to the debug Log.o4 - Another Object to pass to the debug Log.o5 - Another Object to pass to the debug Log.o6 - Another Object to pass to the debug Log.o7 - Another Object to pass to the debug Log.
public static void debug(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5,
java.lang.Object o6,
java.lang.Object o7,
java.lang.Object o8)
o1 - An Object to pass to the debug Log.o2 - Another Object to pass to the debug Log.o3 - Another Object to pass to the debug Log.o4 - Another Object to pass to the debug Log.o5 - Another Object to pass to the debug Log.o6 - Another Object to pass to the debug Log.o7 - Another Object to pass to the debug Log.o8 - Another Object to pass to the debug Log.public static void ignore(java.lang.Throwable ex)
ex - The Throwable to print the full stack trace of
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||