 |
File PrintMessage.java:
/*
* Class Name: PrintMessage
*
* Purpose: Provide run-time time trace capabilities
*
* Owner:
* Version: 1.0
*/
import java.text.DateFormat;
import java.util.Date;
public class PrintMessage
{
static DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.MEDIUM);
/* The following static variable and function are needed to implement */
/* run-time tracing. The function isRunTimeDebugOn() should be called */
/* by your application code prior to making use of any of the output */
/* trace calls. */
/* Retrieve customer run-time trace on/off indication */
static boolean debugOn = ((System.getProperty("debug") != null)
(System.getProperty("debug").equals("1"))) ? true : false;
/* Method to query if run-time trace is turned on */
public static boolean isRuntimeDebugOn()
{
return debugOn;
}
/* The following set of functions are made available for your application */
/* code. Write a re-usable set of methods allows implementation of trace */
/* output to be controlled from one central place. Later, the output */
/* location can be changed, the format of the output message can be */
/* changed, etc. */
/* Output trace functions */
public static void printMessageWithDateTime(String msg)
{
msg = new String(df.format(new Date()) + ": " + msg);
print(msg, true);
return;
}
public static void printMessage(String msg)
{
print(msg, true);
return;
}
public static void printMessageNoNewLine(String msg)
{
print(msg, false);
return;
}
/* private method that all public print messages call to output msg */
private static void print(String msg, boolean newLine)
{
if (newLine)
System.out.println(msg);
else
System.out.print(msg);
return;
}
private static final String COPYRIGHT = SharedConstants.COPYRIGHT;
}
|
Return to the
article.
|  |
|