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 DbProxyInfo extends GenerationInfo {
29 protected static int count = 0;
30
31 public boolean has_gui = false;
32 public String zeus_external = null;
33 public String path = null;
34 public String dns_file = NameserverInfo.DEFAULT_DNS;
35
36 public DbProxyInfo() {
37 name = DBPROXY + (count++);
38 }
39 public DbProxyInfo(String name) {
40 this.name = name;
41 }
42
43 public String[] summarize() {
44 String[] out = new String[4];
45 out[NAME] = name;
46 out[TYPE] = DBPROXY;
47 out[ID] = id;
48
49 out[COMMAND] = "java zeus.agents.DbProxy " + name +
50 " -p " + path + " -s " + dns_file;
51 if ( has_gui )
52 out[COMMAND] += " -gui zeus.agentviewer.BasicViewer";
53 if ( zeus_external != null )
54 out[COMMAND] += " -e " + zeus_external;
55
56 return out;
57 }
58 public String isValid() {
59 String error = "";
60 if ( path == null )
61 error += "DbProxy " + name + ": path not specified\n";
62 if ( dns_file == null )
63 error += "DbProxy " + name + ": domain nameserver file not specified\n";
64
65 if ( error.equals("") ) return null;
66 return error;
67 }
68
69 public String toString() {
70 String s = "";
71 s += "(:name " + name;
72 s += " :has_gui " + has_gui;
73 if ( host != null && !host.equals(LOCALHOST) )
74 s += " :host \"" + Misc.escape(host) + "\"";
75 if ( zeus_external != null )
76 s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"";
77 if ( dns_file != null )
78 s += " :dns_file \"" + Misc.escape(dns_file) + "\"";
79 if ( path != null )
80 s += " :path \"" + Misc.escape(path) + "\"";
81 s += ")";
82 return s;
83 }
84
85 public String pprint(int sp) {
86 String tabs = Misc.spaces(sp);
87 String eol = "\n" + tabs;
88
89 String s = tabs;
90 s += "(:name " + name + eol;
91 s += " :has_gui " + has_gui + eol;
92 if ( host != null && !host.equals(LOCALHOST) )
93 s += " :host \"" + Misc.escape(host) + "\"" + eol;
94 if ( zeus_external != null )
95 s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"" + eol;
96 if ( dns_file != null )
97 s += " :dns_file \"" + Misc.escape(dns_file) + "\"" + eol;
98 if ( path != null )
99 s += " :path \"" + Misc.escape(path) + "\"" + eol;
100 s += ")";
101 return s;
102 }
103 }