 |
File PrintMessage.java:
/*
* Class Name: PrintMessage
*
* Purpose: Provide development 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);
/* Development time trace variables */
public static final boolean traceLow = ((SharedConstants.DEBUG
SharedConstants.TRACE_LOW) ==
SharedConstants.TRACE_LOW)
? true : false;
public static final boolean traceMedium = ((SharedConstants.DEBUG
SharedConstants.TRACE_MEDIUM) ==
SharedConstants.TRACE_MEDIUM)
? true : false;
public static final boolean traceHigh = ((SharedConstants.DEBUG
SharedConstants.TRACE_HIGH) ==
SharedConstants.TRACE_HIGH)
? true : false;
public static final boolean traceAll = ((SharedConstants.DEBUG
SharedConstants.TRACE_ALL) ==
SharedConstants.TRACE_ALL)
? true : false;
/* 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.
|  |
|