KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > commands > CompileCLICommands


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.cli.commands;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.Vector JavaDoc;
28 import java.util.Hashtable JavaDoc;
29 import java.util.Collections JavaDoc;
30 import java.util.Enumeration JavaDoc;
31 import java.lang.Character JavaDoc;
32
33 import com.sun.enterprise.cli.framework.*;
34
35
36 /**
37  * CompileCLICommands.java
38  * This class will generate a html file containing all the
39  * commands available in asadmin.
40  * @version $Revision: 1.3 $
41  */

42 public class CompileCLICommands
43 {
44     public static void main(String JavaDoc[] args)
45     {
46         try
47         {
48             CLIDescriptorsReader cdr = CLIDescriptorsReader.getInstance();
49             ValidCommandsList vcl = cdr.getCommandsList();
50             Iterator JavaDoc commands = vcl.getCommands();
51             printHTMLHeader();
52
53             Hashtable JavaDoc ht = new Hashtable JavaDoc();
54             while (commands.hasNext())
55             {
56                 ValidCommand command = (ValidCommand)commands.next();
57                     //System.out.println("command = " + command.getName());
58
ht.put(command.getName(), command.getUsageText());
59             }
60             
61             Vector JavaDoc v = new Vector JavaDoc(ht.keySet());
62                 //sort commands in alphabetical order
63
Collections.sort(v);
64
65             printHTMLCommands(v);
66             printHTMLUsageText(v, ht);
67
68                 /*
69             for (Enumeration e = v.elements(); e.hasMoreElements();) {
70                 String commandName = (String)e.nextElement();
71                 System.out.println("command = " + commandName + " usage-text = " + (String)ht.get(commandName));
72             }
73                 */

74             
75             printHTMLFooter();
76         }
77         catch (Exception JavaDoc e)
78         {
79             e.printStackTrace();
80         }
81     }
82
83     private static int printCommands(Vector JavaDoc commands, int ii, char ch)
84     {
85         System.out.println("<a name='" + ch + "'/>");
86         System.out.println("<B>" + Character.toUpperCase(ch) + "</B><br>");
87         while ( ii<commands.size() &&
88                 ((String JavaDoc)commands.get(ii)).charAt(0) == ch)
89         {
90             System.out.print("<a HREF='#");
91             System.out.println((String JavaDoc)commands.get(ii) + "'>" +
92                                (String JavaDoc)commands.get(ii++) + "</a> <br>");
93         }
94         System.out.println("<a HREF='#top'>top</a> <br><br>");
95         return ii;
96     }
97     
98
99     public static void printHTMLCommands(Vector JavaDoc commands)
100     {
101         for (int ii=0; ii+1<commands.size();)
102         {
103             String JavaDoc commandName = (String JavaDoc)commands.get(ii);
104             
105             if (commandName.charAt(0) == 'a')
106                 ii = printCommands(commands, ii, 'a');
107             else if (commandName.charAt(0) == 'b')
108                 ii = printCommands(commands, ii, 'b');
109             else if (commandName.charAt(0) == 'c')
110                 ii = printCommands(commands, ii, 'c');
111             else if (commandName.charAt(0) == 'd')
112                 ii = printCommands(commands, ii, 'd');
113             else if (commandName.charAt(0) == 'e')
114                 ii = printCommands(commands, ii, 'e');
115             else if (commandName.charAt(0) == 'f')
116                 ii = printCommands(commands, ii, 'f');
117             else if (commandName.charAt(0) == 'g')
118                 ii = printCommands(commands, ii, 'g');
119             else if (commandName.charAt(0) == 'h')
120                 ii = printCommands(commands, ii, 'h');
121             else if (commandName.charAt(0) == 'i')
122                 ii = printCommands(commands, ii, 'i');
123             else if (commandName.charAt(0) == 'j')
124                 ii = printCommands(commands, ii, 'j');
125             else if (commandName.charAt(0) == 'k')
126                 ii = printCommands(commands, ii, 'k');
127             else if (commandName.charAt(0) == 'l')
128                 ii = printCommands(commands, ii, 'l');
129             else if (commandName.charAt(0) == 'm')
130                 ii = printCommands(commands, ii, 'm');
131             else if (commandName.charAt(0) == 'n')
132                 ii = printCommands(commands, ii, 'n');
133             else if (commandName.charAt(0) == 'o')
134                 ii = printCommands(commands, ii, 'o');
135             else if (commandName.charAt(0) == 'p')
136                 ii = printCommands(commands, ii, 'p');
137             else if (commandName.charAt(0) == 'q')
138                 ii = printCommands(commands, ii, 'q');
139             else if (commandName.charAt(0) == 'r')
140                 ii = printCommands(commands, ii, 'r');
141             else if (commandName.charAt(0) == 's')
142                 ii = printCommands(commands, ii, 's');
143             else if (commandName.charAt(0) == 't')
144                 ii = printCommands(commands, ii, 't');
145             else if (commandName.charAt(0) == 'u')
146                 ii = printCommands(commands, ii, 'u');
147             else if (commandName.charAt(0) == 'v')
148                 ii = printCommands(commands, ii, 'v');
149             else if (commandName.charAt(0) == 'w')
150                 ii = printCommands(commands, ii, 'w');
151             else if (commandName.charAt(0) == 'x')
152                 ii = printCommands(commands, ii, 'x');
153             else if (commandName.charAt(0) == 'y')
154                 ii = printCommands(commands, ii, 'y');
155             else if (commandName.charAt(0) == 'z')
156                 ii = printCommands(commands, ii, 'z');
157             
158         }
159     }
160
161
162     private static int printUsageText(Vector JavaDoc commands, Hashtable JavaDoc ht,
163                                       int ii, char ch)
164     {
165         while ( ii<commands.size() &&
166                 ((String JavaDoc)commands.get(ii)).charAt(0) == ch)
167         {
168             final String JavaDoc commandName = (String JavaDoc)commands.get(ii++);
169             System.out.println("<a name='"+commandName+"'/>");
170             System.out.println((String JavaDoc)ht.get(commandName) + " <br><br>");
171         }
172         return ii;
173     }
174     
175
176
177     public static void printHTMLUsageText(Vector JavaDoc commands, Hashtable JavaDoc ht)
178     {
179         System.out.println("<a name='usagetext'/>");
180         System.out.println("<br><B>Usage Text</B><br><br>");
181
182         for (int ii=0; ii+1<commands.size();)
183         {
184             String JavaDoc commandName = (String JavaDoc)commands.get(ii);
185             if (commandName.charAt(0) == 'a')
186                 ii= printUsageText(commands, ht, ii, 'a');
187             else if (commandName.charAt(0) == 'b')
188                 ii =printUsageText(commands, ht, ii, 'b');
189             else if (commandName.charAt(0) == 'c')
190                 ii =printUsageText(commands, ht, ii, 'c');
191             else if (commandName.charAt(0) == 'd')
192                 ii =printUsageText(commands, ht, ii, 'd');
193             else if (commandName.charAt(0) == 'e')
194                 ii =printUsageText(commands, ht, ii, 'e');
195             else if (commandName.charAt(0) == 'f')
196                 ii =printUsageText(commands, ht, ii, 'f');
197             else if (commandName.charAt(0) == 'g')
198                 ii =printUsageText(commands, ht, ii, 'g');
199             else if (commandName.charAt(0) == 'h')
200                 ii =printUsageText(commands, ht, ii, 'h');
201             else if (commandName.charAt(0) == 'i')
202                 ii =printUsageText(commands, ht, ii, 'i');
203             else if (commandName.charAt(0) == 'j')
204                 ii =printUsageText(commands, ht, ii, 'j');
205             else if (commandName.charAt(0) == 'k')
206                 ii =printUsageText(commands, ht, ii, 'k');
207             else if (commandName.charAt(0) == 'l')
208                 ii =printUsageText(commands, ht, ii, 'l');
209             else if (commandName.charAt(0) == 'm')
210                 ii =printUsageText(commands, ht, ii, 'm');
211             else if (commandName.charAt(0) == 'n')
212                 ii =printUsageText(commands, ht, ii, 'n');
213             else if (commandName.charAt(0) == 'o')
214                 ii =printUsageText(commands, ht, ii, 'o');
215             else if (commandName.charAt(0) == 'p')
216                 ii =printUsageText(commands, ht, ii, 'p');
217             else if (commandName.charAt(0) == 'q')
218                 ii =printUsageText(commands, ht, ii, 'q');
219             else if (commandName.charAt(0) == 'r')
220                 ii =printUsageText(commands, ht, ii, 'r');
221             else if (commandName.charAt(0) == 's')
222                 ii =printUsageText(commands, ht, ii, 's');
223             else if (commandName.charAt(0) == 't')
224                 ii =printUsageText(commands, ht, ii, 't');
225             else if (commandName.charAt(0) == 'u')
226                 ii =printUsageText(commands, ht, ii, 'u');
227             else if (commandName.charAt(0) == 'v')
228                 ii =printUsageText(commands, ht, ii, 'v');
229             else if (commandName.charAt(0) == 'w')
230                 ii =printUsageText(commands, ht, ii, 'w');
231             else if (commandName.charAt(0) == 'x')
232                 ii =printUsageText(commands, ht, ii, 'x');
233             else if (commandName.charAt(0) == 'y')
234                 ii =printUsageText(commands, ht, ii, 'y');
235             else if (commandName.charAt(0) == 'z')
236                 ii =printUsageText(commands, ht, ii, 'z');
237         }
238         System.out.println("<a HREF='#top'>top</a> <br><br>");
239 }
240     
241     
242
243     public static void printHTMLHeader()
244     {
245         System.out.println("<html>");
246         System.out.println("<h2 align=center>asadmin commands list</h2>");
247         System.out.println("<p align=center>");
248         System.out.println("<a HREF='http://appserver.red.iplanet.com/apollo/cli/s1as8ee_cli_commands.html'>8.1 EE CLI Commands -- Dev Page</a> </p>");
249         System.out.println("<a name='top'/>");
250         System.out.println("[<a HREF='#a'>a</a>],");
251         System.out.println("[<a HREF='#b'>b</a>],");
252         System.out.println("[<a HREF='#c'>c</a>],");
253         System.out.println("[<a HREF='#d'>d</a>],");
254         System.out.println("[<a HREF='#e'>e</a>],");
255         System.out.println("[<a HREF='#f'>f</a>],");
256         System.out.println("[<a HREF='#g'>g</a>],");
257         System.out.println("[<a HREF='#h'>h</a>],");
258         System.out.println("[<a HREF='#i'>i</a>],");
259         System.out.println("[<a HREF='#j'>j</a>],");
260         System.out.println("[<a HREF='#k'>k</a>],");
261         System.out.println("[<a HREF='#l'>l</a>],");
262         System.out.println("[<a HREF='#m'>m</a>],");
263         System.out.println("[<a HREF='#n'>n</a>],");
264         System.out.println("[<a HREF='#o'>o</a>],");
265         System.out.println("[<a HREF='#p'>p</a>],");
266         System.out.println("[<a HREF='#q'>q</a>],");
267         System.out.println("[<a HREF='#r'>r</a>],");
268         System.out.println("[<a HREF='#s'>s</a>],");
269         System.out.println("[<a HREF='#t'>t</a>],");
270         System.out.println("[<a HREF='#u'>u</a>],");
271         System.out.println("[<a HREF='#v'>v</a>],");
272         System.out.println("[<a HREF='#w'>w</a>],");
273         System.out.println("[<a HREF='#x'>x</a>],");
274         System.out.println("[<a HREF='#y'>y</a>],");
275         System.out.println("[<a HREF='#z'>z</a>],");
276         System.out.println("[<a HREF='#usagetext'>Usage Text</a>] <br><br>");
277     }
278
279     public static void printHTMLFooter()
280     {
281         System.out.println("</html>");
282     }
283     
284
285  
286 }
287
Popular Tags