FileDocCategorySizeDatePackage
Reminder.javaAPI DocGlassfish v2 API5608Fri May 04 22:32:14 BST 2007com.sun.enterprise.util.diagnostics

Reminder

public class Reminder extends Object
This class makes it easy to add a message to be displayed at runtime, and/or a message requiring a Yes/No answer. The message appears in a MODAL dialog so it will always get your full attention. It is designed for development-time only. In fact every message box screams out a message to not allow it into the release. The class name, file name, method name and line number of the caller is automatically added to the message window.

Examples:

1) You just temporarily did something -- like commented-out some code -- and you don't want to forget to comment it back in later:
Reminder.message("Don't forget to uncomment the code here!");

2) You want to add a branch in some code, temporarily. Instead of changing the source and recompiling again and again do the following and determine the branching at runtime:
if(Reminder.message("Use the new improved code?"))
new_code();
else
old_code();

3) Poor Man's Debugger
Add watch statements, pause execution so you can check something in the filesystem, etc.

author
bnevins
version
$Revision: 1.4 $

Fields Summary
private static final String
title
private static final String
preMessage
private static final Object[]
me
Constructors Summary
private Reminder()

	
Methods Summary
private static java.lang.StringcreateMessage(java.lang.String s)

		String location;
		
		try
		{
			location = "\n\nCode Location: " + new CallerInfo(me).toString();
		}
		catch(CallerInfoException e)
		{
			location = "\n\nUnknown code location";
		}
		
		return preMessage + s + location;
	
public static voidmain(java.lang.String[] notUsed)
Simple test code to exercise the class.

	
	//////////////////////////////////////////////////////////

	       	 	
	    
	
		ReminderTester rt = new ReminderTester();
		rt.test();
		System.exit(0);
	
public static voidmessage(java.lang.String msg)
Displays a Message Box that reminds you to do something. You can't ignore it -- it is a modal dialog box.

param
msg The message to display in the Message Box

		String s = createMessage(msg);
		JOptionPane.showMessageDialog(null, s, title, JOptionPane.ERROR_MESSAGE); 
    
public static booleanyesno(java.lang.String msg)
Displays a Message Box with Yes and No buttons. Handy for temporarily adding a runtime-chosen decision point in your code. Use this instead of commenting out code that you have to remember to uncomment later.

param
msg The message to display in the Message Box
return
returns true if yes was chosen, false if no was chosen.

		String s = createMessage(msg);
		//return true for yes, false for no...
		int reply = JOptionPane.showConfirmDialog(null, s, title, JOptionPane.YES_NO_OPTION);
		
		if(reply == JOptionPane.YES_OPTION)
			return true;
		
		return false;