1 /**
2 * .
3 * Copyright � 1999 Erich P G.
4 *
5 */
6
7 package autohit;
8
9 import java.io.Serializable;
10 import java.util.Vector;
11
12 import autohit.vm.VMInstruction;
13
14 /**
15 * Sim is the basic class for a simulation. Each represents a use-flow for
16 * a single user. It can handle authentication for a single user.
17 * <p>
18 * Sim's do <b>not</b> have a version reference. Putting a compiled Sim from one
19 * version into a vm of another version can have unpredictable results.
20 * <p>
21 * When creating a new Sim, you must call the init() member after construction.
22 * If you do not, you will eventually get an internal exception. If you are
23 * deserializing, don't worry about it.
24 * <p>
25 * @author Erich P. Gatejen
26 * @version 1.0
27 * <i>Version History</i>
28 * <code>EPG - Initial - 5Jan99</code>
29 *
30 */
31 public class Sim implements Serializable {
32
33 // --- FINAL FIELDS ------------------------------------------------------
34
35 // --- FIELDS ------------------------------------------------------------
36
37 /**
38 * A vector containing the Simulation executable.
39 * Each member-object will be a vmInstruction derived class object.
40 *
41 * @see autohit.vm.VMInstruction
42 * @serial
43 */
44 public Vector exec;
45
46 /**
47 * This sim's name.
48 *
49 * NOTE! SimCompiler currently requires a uid attribute for the <name> tag,
50 * but it isn't used for anything now.
51 * @serial
52 */
53 public String name;
54
55 /**
56 * Associated note.
57 *
58 * @serial
59 */
60 public String note;
61
62 // --- PUBLIC METHODS ----------------------------------------------------
63
64 /**
65 * Default Constructor. It will create an empty Sim. Remember! If you are
66 * creating a new Sim, but sure to call init().
67 *
68 * @see #init()
69 */
70 public Sim() {
71
72 }
73
74 /**
75 * Initializes a brand-new Sim().
76 */
77 public void init() {
78
79 exec = new Vector();
80 }
81
82 /**
83 * Dump this SIM. I'm putting this in for debugging. It might have some other
84 * uses...
85 *
86 * @return a String containing the dump.
87 */
88 public String toString() {
89
90 StringBuffer d = new StringBuffer();
91
92 d.append("Sim Dump ===============================\n");
93 d.append("Name = [" + name + "]\n");
94 d.append("Note ----------------------------------- \n");
95 d.append(note);
96 d.append("\n---------------------------------------- \n");
97 d.append("Executable ----------------------------- \n");
98 VMInstruction vmi;
99 for (int idx = 0; idx < exec.size(); idx++) {
100 d.append("IP = " + idx);
101 vmi = (VMInstruction)exec.get(idx);
102 d.append(vmi.toString());
103 }
104 d.append("---------------------------------------- \n");
105 return d.toString();
106 }
107
108 // --- PRIVATE METHODS ---------------------------------------------------
109
110
111 }
|