/*
* $Author: bhevans $
* $Date: 1996/05/26 22:46:21 $
* $Source: /home/phoenix/cscstd/ijkl/jlarsen/box/RCS/Printer.java,v $
* $Revision: 1.1 $
* $Log: Printer.java,v $
# Revision 1.1 1996/05/26 22:46:21 bhevans
# Initial revision
#
*/
package com.nanosoft.pcm.machine;
import com.nanosoft.pcm.machine.*;
import java.util.*;
import java.io.*;
/**
* The printer class is the dumb class which
* prints any class derived from Log.
* @author $Author: bhevans $
* @version $Revision: 1.1 $
* @see ReportGenerator
* @see Log
*/
public
class Printer extends Object {
private String machineId; // unique ALPHA-NUM identifier
private String machineName; // machine name / location
private PrintStream Output; // ouput stream
private Queue data; // general data storage
/**
* @param ID The machine's id number
* @param Name The machine's location
* @param output The printstream which to print.
*/
public Printer(String ID, String Name, PrintStream output) {
machineId = ID;
machineName = Name;
Output = output;
}
/**
* Output goes to System.err
* @param ID The machine's id number
* @param Name The machine's location
*/
public Printer(String ID, String Name) {
machineId = ID;
machineName = Name;
Output = System.err;
}
/**
* Precondition: The log must be assembled correctly
* Notes: destroys the log's body
* This method prints any log.
* @param aLog The log which to print
*/
public void printLog (Log aLog) {
this.printHeader(aLog);
this.printString(aLog);
this.printFooter(aLog);
}
/**
* @param aLog the log from which to gram the header string
*/
private void printHeader(Log aLog) {
// GRAB HEADER PORTION FROM LOG
Output.println("-- ================================= --");
Output.println("-- " + machineId + " " + machineName);
Output.print(aLog.headerString() );
Output.println("-- ");
Output.flush();
}
/**
* Notes: destroys the log's body
* @param aLog the log from which to grab the body string
*/
private void printString(Log aLog) {
// GRAB BODY PORTION FROM LOG
while ( ! aLog.isEmpty() ) {
Output.print(aLog.dataString() );
}
}
/**
* @param aLog the log from which to grab the footer string
*/
private void printFooter(Log aLog) {
// GRAB FOOTER PORTION FROM LOG
Output.println("-- ");
Output.print(aLog.footerString() );
Output.println("-- ================================= --");
Output.flush();
}
}