View Javadoc

1   /*
2   * The contents of this file are subject to the BT "ZEUS" Open Source 
3   * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
4   * except in compliance with the Licence. You may obtain a copy of the Licence
5   * from $ZEUS_INSTALL/licence.html or alternatively from
6   * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7   * 
8   * Except as stated in Clause 7 of the Licence, software distributed under the
9   * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
10  * implied. See the Licence for the specific language governing rights and 
11  * limitations under the Licence.
12  * 
13  * The Original Code is within the package zeus.*.
14  * The Initial Developer of the Original Code is British Telecommunications
15  * public limited company, whose registered office is at 81 Newgate Street, 
16  * London, EC1A 7AJ, England. Portions created by British Telecommunications 
17  * public limited company are Copyright 1996-9. All Rights Reserved.
18  * 
19  * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
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 }