SOURCECODE

How to... define a new ProcessLogEntry


Description:
The ProcessLogEntry is a subclass of LogEntry. The extension consists of the Process being handed over to the constructor and the redefinition of the toString() method, which roughly describes the process that is being logged on by the String "Process \"" + getProcessName() + "\" logged on " + getLogDate() + ".". There is also an additonal public method getProcessName(), which returns the name of the handed over Process.
The reason for this subclass or for subclassing it by yourself might be the need to use the LogEntryFilter provided by the static field SaleProcess.LOGENTRYFILTER_PROCESSES_ONLY. It accepts only instances of ProcessLogEntry. So if you ever want to filter logs that belong directly to a SaleProcess, you have to subclass the ProcessLogEntry and use the LogEntryFilter on it.

ToDo's:
  1. Subclass the SaleProcess.ProcessLogEntry
  2. Call the superclass and hand over the SaleProcess
  3. Redefine the toString() method to suit your log description


Uses:
LogEntry  



SourceCode

import sale.*;
import log.*;

 1
public class GiveBackLogEntry extends SaleProcess.ProcessLogEntry {
    
    String name;
    String customerID;
    Object date;
    
    public GiveBackLogEntry(SaleProcess p, String name, String customerID, Object date) {

         2
        super(p);
        this.name = name;
        this.customerID = customerID;
        this.date = date;
    }
    

     3
    public String toString() {
        return name +
        " gave back by customer " + customerID +
        " (ID) at turn " + date;
    }
}