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  /*** 
29    * used to generate the script that runs the visualiser
30    * Change log 
31    * ----------
32    * 26/06/01 removed java from command line
33    */
34  public class VisualiserInfo extends GenerationInfo {
35     protected static int count = 0;
36  
37     public boolean has_gui = false;
38     public String zeus_external = null;
39     public String dns_file = NameserverInfo.DEFAULT_DNS;
40     public String ontology_file = null;
41  
42     public VisualiserInfo(String file) {
43        name = VISUALISER + (count++);
44        ontology_file = file;
45     }
46  
47     public VisualiserInfo(String name, String file) {
48        this.name = name;
49        ontology_file = file;
50     }
51  
52      /*** 
53          removed java from command line (done in scriptwriter now) 
54          Simon 26.06.01
55          */
56     public String[] summarize() {
57        String[] out = new String[4];
58        out[NAME] = name;
59        out[TYPE] = VISUALISER;
60        out[ID]   = id;
61        out[COMMAND] = "zeus.visualiser.Visualiser " + name +
62                       " -s " + dns_file;
63  
64        if ( ontology_file != null )
65           out[COMMAND] += " -o " + ontology_file;
66        if ( has_gui )
67           out[COMMAND] += " -gui zeus.agentviewer.BasicViewer";
68        if ( zeus_external != null )
69           out[COMMAND] += " -e " + zeus_external;
70  
71        out[COMMAND] += " -quick";
72        return out;
73     }
74     public String isValid() {
75        String error = null;
76        if (dns_file == null )
77           error = "Visualiser " + name + ": domain nameserver file not specified\n";
78  
79        return error;
80     }
81  
82     public String toString() {
83        String s = "";
84        s += "(:name " + name;
85        s += " :has_gui " + has_gui;
86        if ( host != null && !host.equals(LOCALHOST) )
87           s += " :host \"" + Misc.escape(host) + "\"";
88        if ( zeus_external != null )
89           s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"";
90        if ( dns_file != null )
91           s += " :dns_file \"" + Misc.escape(dns_file) + "\"";
92        s += ")";
93        return s;
94     }
95  
96     public String pprint(int sp) {
97        String tabs = Misc.spaces(sp);
98        String eol  = "\n" + tabs;
99  
100       String s = tabs;
101       s += "(:name " + name + eol;
102       s += " :has_gui " + has_gui + eol;
103       if ( host != null && !host.equals(LOCALHOST) )
104          s += " :host \"" + Misc.escape(host) + "\"" + eol;
105       if ( zeus_external != null )
106          s += " :zeus_external \"" + Misc.escape(zeus_external) + "\"" + eol;
107       if ( dns_file != null )
108          s += " :dns_file \"" + Misc.escape(dns_file) + "\"" + eol;
109       s += ")";
110       return s;
111    }
112 }