1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package zeus.generator.code;
25
26 import zeus.util.*;
27
28 public class AgentInfo extends GenerationInfo {
29 public boolean generate = true;
30 public String status = GenerationPlan.SAVE_NEEDED;
31 public String database = null;
32 public boolean has_gui = false;
33 public String zeus_external = null;
34 public String icon_file = null;
35 public String dns_file = NameserverInfo.DEFAULT_DNS;
36 public String ontology_file = null;
37
38 public AgentInfo(String id, String name, String file) {
39 super(id);
40 this.name = name;
41 ontology_file = file;
42 }
43
44 public String[] summarize() {
45 String[] out = new String[4];
46 out[NAME] = name;
47 out[TYPE] = AGENT;
48 out[ID] = id;
49
50 out[COMMAND] = name +
51 " -o " + ontology_file + " -s " + dns_file;
52
53 if ( has_gui )
54 out[COMMAND] += " -gui zeus.agentviewer.AgentViewer";
55 if ( zeus_external != null )
56 out[COMMAND] += " -e " + zeus_external;
57 if ( database != null )
58 out[COMMAND] += " -r " + database;
59
60 return out;
61 }
62
63 public String isValid() {
64 String error = null;
65 if ( dns_file == null )
66 error = "Agent " + name + ": domain nameserver file not specified\n";
67
68 return error;
69 }
70
71 public String toString() {
72 String s = "";
73 s += "(:id " + id;
74 s += " :generate " + generate;
75 s += " :status " + status;
76 s += " :has_gui " + has_gui;
77 if ( host != null && !host.equals(LOCALHOST) )
78 s += " :host \"" + Misc.escape(host) + "\"";
79 if ( database != null )
80 s += " :database \"" + Misc.escape(database) + "\"";
81 if ( zeus_external != null )
82 s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"";
83 if ( dns_file != null )
84 s += " :dns_file \"" + Misc.escape(dns_file) + "\"";
85 s += ")";
86 return s;
87 }
88
89 public String pprint(int sp) {
90 String tabs = Misc.spaces(sp);
91 String eol = "\n" + tabs;
92
93 String s = tabs;
94 s += "(:id " + id + eol;
95 s += " :generate " + generate + eol;
96 s += " :status " + status + eol;
97 s += " :has_gui " + has_gui + eol;
98 if ( host != null && !host.equals(LOCALHOST) )
99 s += " :host \"" + Misc.escape(host) + "\"" + eol;
100 if ( database != null )
101 s += " :database \"" + Misc.escape(database) + "\"" + eol;
102 if ( zeus_external != null )
103 s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"" + eol;
104 if ( dns_file != null )
105 s += " :dns_file \"" + Misc.escape(dns_file) + "\"" + eol;
106 s += ")";
107 return s;
108 }
109 }