/* * $Author: bhevans $ * $Date: 1996/05/26 22:45:39 $ * $Source: /home/phoenix/cscstd/ijkl/jlarsen/box/RCS/Log.java,v $ * $Revision: 1.1 $ * $Log: Log.java,v $ # Revision 1.1 1996/05/26 22:45:39 bhevans # Initial revision # */ package com.nanosoft.pcm.machine; import com.nanosoft.pcm.machine.*; import java.lang.*; import java.util.*; /** *The Log class is the intermittent object which * communicates data from the report generater to the printer, * a fairly stupid device which is only capable of printing * logs. *
Log is effectively an abstract class * @author $Author: bhevans $ * @version $Revision: 1.1 $ */ public class Log extends Object { protected int numb; // number of Records protected Queue items; // set of Records protected Date stamp; // time stamp protected boolean posted; // records whether or not log has been posted // kept for testing, not needed in production /** * Initializes the log and creates a queue to store data members */ protected Log() { // only subclassed objects allowed posted = false; items = new Queue(); numb = 0; } /** * @param obj The object to be added to the queue */ protected void add(Object obj) { // adds one record to the log numb += 1; items.push(obj); } /** * Time stamps the log and sets its posted state to true. */ protected void post() { stamp = new Date(); posted = true; } /** * Precondition: The input must cast into a string nicely. * @param obj The object to print * @return A default string standard to all logs. */ protected String addLine( Object obj) { // general formatting routine return "-- " + obj + "\n"; } /** * Precondition: The queue is not empty. * @return The next element from the queue */ protected StorageItem pop() { // removes one record from the log return (StorageItem)items.pop(); } /** * @return Whether or not the log is posted ( ready to print ). */ public boolean isPosted() { return posted; } /** * Empties the log and returns it to its inital state. */ public void clean() { // cleans up the log, resets its state items.clean(); stamp = null; posted = false; n = 0; } /** * Interface for printer
* Overriden by child class * @see ReportGenerator */ public String headerString() { return ""; } /** * Interface for printer
* Overriden by child class * @see ReportGenerator */ public String footerString() { return ""; } /** * Interface for printer
* Overriden by child class * @see ReportGenerator */ public String dataString() { return ""; } /** * Interface for printer * @return Whether or not the log is empty. */ public boolean isEmpty() { return items.isEmpty(); } }