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

ReporterWriter

public class ReporterWriter extends Object implements IReporterEnum
The basic mechanism used to "report". sends output to a Swing window.

Fields Summary
private PrintStream
out
private ReporterFrame
frame
private int
longestSeverityLength
private String
title
Constructors Summary
protected ReporterWriter(String title)
Create a new place (or mechanism) for routing output from the Reporter classes.

param
title The title of the output window

		this.title = title;
		out = System.out;
	
Methods Summary
private voidcalcLongestString()

		int maxLen = 0;

		for(int i = 0; i < severityNames.length; i++)
		{
			int len = severityNames[i].length();

			if(len > maxLen)
				maxLen = len;
		}
		longestSeverityLength = maxLen + 2;
	
private ReporterFramegetFrame()

		if(frame == null)
		{
			// first call!!
			frame = new ReporterFrame(title);
			frame.show();
			calcLongestString();
		}

		return frame;
	
protected voidprintln(int severity, java.lang.String s)
puts a message in the window. Subclasses should redefine this function to change the report output destination.

param
severity The severity level of the message. This is translated into one of the named constants for output.
param
s The text of the message to "report".

		String type;
		String msg;
		
		/*
		if(severity > WARN)
		{
			type = "<B>" + severityNames[severity] + "</B>";
			msg = StringUtils.padRight(type, longestSeverityLength + 7) + s;
		}
        else
		*/
		{
			type = severityNames[severity];
			msg = StringUtils.padRight(severityNames[severity], longestSeverityLength) + s;
		}

        out.println(msg);
		getFrame().pr(msg);