KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > innig > macker > recording > EventRecording


1 /*______________________________________________________________________________
2  *
3  * Macker http://innig.net/macker/
4  *
5  * Copyright 2003 Paul Cantrell
6  *
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License version 2, as published by the
9  * Free Software Foundation. See the file LICENSE.html for more information.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the license for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
17  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
18  *______________________________________________________________________________
19  */

20  
21 package net.innig.macker.recording;
22
23 import net.innig.macker.event.*;
24 import net.innig.macker.rule.Rule;
25 import net.innig.macker.rule.RuleSet;
26
27 import java.io.PrintStream JavaDoc;
28 import java.io.PrintWriter JavaDoc;
29 import org.jdom.Element;
30 import net.innig.collect.CollectionDiff;
31
32 public abstract class EventRecording
33     {
34     public EventRecording(EventRecording parent)
35         { this.parent = parent; }
36     
37     protected EventRecording getParent()
38         { return parent; }
39     
40     public abstract EventRecording record(MackerEvent event);
41     
42     public abstract void read(Element elem);
43     
44     public boolean compare(EventRecording actual, PrintWriter JavaDoc out)
45         {
46         if(getClass() != actual.getClass())
47             {
48             out.println("expected " + this + ", but got " + actual);
49             return false;
50             }
51         
52         return true;
53         }
54     
55     public void dump(PrintStream JavaDoc out, int indent)
56         {
57         PrintWriter JavaDoc outWriter = new PrintWriter JavaDoc(out);
58         dump(outWriter, indent);
59         outWriter.flush();
60         }
61         
62     public void dump(PrintWriter JavaDoc out, int indent)
63         {
64         for(int n = 0; n < indent; n++)
65             out.print(' ');
66         out.println(this);
67         }
68         
69     private EventRecording parent;
70     }
71
Popular Tags