KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > generator > DODSGenerator


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  */

19
20 /*
21  *
22  * @author Tanja Jovanovic, Nenad Vico
23  * @version 1.0.0
24  *
25  */

26 package org.enhydra.dods.generator;
27
28 import java.io.BufferedReader JavaDoc;
29 import java.io.File JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.io.InputStreamReader JavaDoc;
32 import java.lang.reflect.InvocationTargetException JavaDoc;
33 import java.util.ArrayList JavaDoc;
34 import java.util.HashMap JavaDoc;
35 import java.util.HashSet JavaDoc;
36 import org.enhydra.dods.Common;
37 import org.enhydra.dods.wizard.DefaultDODSWizard;
38
39 /**
40  * This class is used for generating DODS code and DODS documentation.
41  */

42 public class DODSGenerator {
43    // constants
44
protected static final int HELP_PARAMETER = 0;
45    protected static final int ACTION_PARAMETER = 10;
46    protected static final int TEMPLATE_SET_PARAMETER = 20;
47    protected static final int FORCE_PARAMETER = 30;
48    protected static final int DATABASE_PARAMETER = 40;
49    protected static final int CONFIGURATION_DIR_PARAMETER = 50;
50    protected static final int HTML_PARAMETER = 100;
51    protected static final int PDF_PARAMETER = 110;
52    protected static final int XMI_PARAMETER = 120;
53    protected static final int PTL_PARAMETER = 130;
54    // Messages
55
protected static final String JavaDoc HELP_MESSAGE = "\n";
56    protected static final String JavaDoc INVALID_NUMBER_OF_PARAMETER_MESSAGE = "\nWrong number of input parameters.\n";
57    protected static final String JavaDoc INVALID_PARAMETER_MESSAGE = "\nWrong input parameter ";
58    protected static final String JavaDoc INVALID_ACTION_PARAMETER_MESSAGE = "\nWrong action parameter ";
59    protected static final String JavaDoc INVALID_TEMPLATE_SET_PARAMETER_MESSAGE = "\n Wrong template set ";
60    protected static final String JavaDoc INVALID_DOML_FILE = "\n Wrong .doml file ";
61    protected static final String JavaDoc NONEXISTING_DOML_FILE = "\n Doml file doesn't exist ";
62    protected static final String JavaDoc INVALID_CONF_DIR_MESSAGE = "\nWrong input parameter ";
63
64    public static final String JavaDoc DATABASE_NOT_SET = "database_not_set";
65
66    /**
67     * Wizard that will be used.
68     */

69    protected DODSWizard wizard = null;
70
71    /**
72     * Doml that will be used.
73     */

74    protected String JavaDoc doml = null;
75
76    /**
77     * Output directory that will be used.
78     */

79    protected String JavaDoc outputDir = null;
80
81    /**
82     * Action that will be performed.
83     */

84    protected String JavaDoc action = null;
85
86    /**
87     * Template set that will be used.
88     */

89    protected String JavaDoc templateSet = null;
90
91    /**
92     * Template set that will be used.
93     */

94    protected String JavaDoc configDir = null;
95
96    /**
97     * Indicator for force (overwrite) option.
98     */

99    protected String JavaDoc force = "false";
100
101    /**
102     * Database vendor.
103     */

104    protected String JavaDoc database = null;
105
106    /**
107     * Indicator for html option.
108     */

109    protected boolean html = false;
110
111    /**
112     * Indicator for pdf option.
113     */

114    protected boolean pdf = false;
115
116    /**
117     * Indicator for xmi option.
118     */

119    protected boolean xmi = false;
120
121    /**
122     * Indicator for ptl option.
123     */

124    protected boolean ptl = false;
125
126    /**
127     * Indicator whether dods generator should be involved during project ant rebuild.
128     */

129    protected boolean invoke = false;
130
131    /**
132     * Indicator for using kelp.
133     */

134    protected boolean kelp = false;
135    protected static boolean help = false;
136    protected static HashMap JavaDoc parameters;
137    protected static HashSet JavaDoc actions;
138    protected static HashSet JavaDoc templateSets;
139    static {
140       // initialize parameter mapings
141
parameters = new HashMap JavaDoc();
142       parameters.put("-?", new Integer JavaDoc(HELP_PARAMETER));
143       parameters.put("-help", new Integer JavaDoc(HELP_PARAMETER));
144       parameters.put("-a", new Integer JavaDoc(ACTION_PARAMETER));
145       parameters.put("-t", new Integer JavaDoc(TEMPLATE_SET_PARAMETER));
146       parameters.put("-f", new Integer JavaDoc(FORCE_PARAMETER));
147       parameters.put("-force", new Integer JavaDoc(FORCE_PARAMETER));
148       parameters.put("-b", new Integer JavaDoc(DATABASE_PARAMETER));
149       parameters.put("-databse", new Integer JavaDoc(DATABASE_PARAMETER));
150       parameters.put("-c", new Integer JavaDoc(CONFIGURATION_DIR_PARAMETER));
151       parameters.put("-h", new Integer JavaDoc(HTML_PARAMETER));
152       parameters.put("-html", new Integer JavaDoc(HTML_PARAMETER));
153       parameters.put("-p", new Integer JavaDoc(PDF_PARAMETER));
154       parameters.put("-pdf", new Integer JavaDoc(PDF_PARAMETER));
155       parameters.put("-x", new Integer JavaDoc(XMI_PARAMETER));
156       parameters.put("-xmi", new Integer JavaDoc(XMI_PARAMETER));
157       parameters.put("-r", new Integer JavaDoc(PTL_PARAMETER));
158       parameters.put("-ptl", new Integer JavaDoc(PTL_PARAMETER));
159       // initialize allowed actions
160
actions = new HashSet JavaDoc();
161       actions.add("dods:sql");
162       actions.add("dods:java");
163       actions.add("dods:javaNoCompile");
164       actions.add("dods:noCompile");
165       actions.add("dods:build_all_split");
166       actions.add("dods:sqlsplit");
167       actions.add("dods:noCompileSplit");
168       actions.add("dods:build_all");
169    }
170
171    /**
172     * Default constructor.
173     */

174    public DODSGenerator() {
175       wizard = new DefaultDODSWizard(this);
176       action = "dods:build_all";
177       templateSet = "standard";
178       database = DATABASE_NOT_SET;
179    }
180
181    /**
182     * Method returns used wizard.
183     *
184     * @return used wizard.
185     */

186    public DODSWizard getWizard() {
187       return wizard;
188    }
189
190    /**
191     * Method sets wizard that will be used.
192     *
193     * @param wizard wizard that will be used.
194     */

195    public void setWizard(DODSWizard wizard) {
196       this.wizard = wizard;
197    }
198
199    /**
200     * Method gets doml file that is used.
201     *
202     * @return doml file that is used.
203     */

204    public String JavaDoc getDoml() {
205       return doml;
206    }
207
208    /**
209     * Method sets doml file that will be used.
210     *
211     * @param doml doml file that will be used.
212     */

213    public void setDoml(String JavaDoc doml) {
214       this.doml = doml;
215    }
216
217    /**
218     * Method gets output directory that is used.
219     *
220     * @return output directory that is used.
221     */

222    public String JavaDoc getOutputDir() {
223       return outputDir;
224    }
225
226    /**
227     * Method sets output directory that will be used.
228     *
229     * @param outputDir output directory that will be used.
230     */

231    public void setOutputDir(String JavaDoc outputDir) {
232       this.outputDir = outputDir;
233    }
234
235    /**
236     * Method gets action that is performed.
237     *
238     * @return action that is performed.
239     */

240    public String JavaDoc getAction() {
241       return action;
242    }
243
244    /**
245     * Method sets action that will be performed.
246     *
247     * @return action action that will be performed.
248     */

249    public void setAction(String JavaDoc action) {
250       this.action = action;
251    }
252
253    /**
254     * Method gets template set that is used.
255     *
256     * @return template set that is used.
257     */

258    public String JavaDoc getTemplateSet() {
259       return templateSet;
260    }
261
262    /**
263     * Method sets template set that will be used.
264     *
265     * @param templateSet template set that will be used.
266     */

267    public void setTemplateSet(String JavaDoc templateSet) {
268       this.templateSet = templateSet;
269    }
270
271    /**
272     * Method gets indicator for force (overwrite) option.
273     *
274     * @return indicator for force (overwrite) option.
275     */

276    public String JavaDoc getForce() {
277       return force;
278    }
279
280    /**
281     * Method sets indicator for force (overwrite) option.
282     *
283     * @param force indicator for force (overwrite) option.
284     */

285    public void setForce(String JavaDoc force) {
286       this.force = force;
287    }
288
289    /**
290     * Method gets database vendor for generating sql.
291     *
292     * @return database vendor for generating sql.
293     */

294    public String JavaDoc getDatabase() {
295       return database;
296    }
297
298    /**
299     * Method sets database vendor for generating sql.
300     *
301     * @param database database vendor for generating sql.
302     */

303    public void setDatabase(String JavaDoc database) {
304       this.database = database;
305    }
306
307    /**
308     * Method gets indicator for html option.
309     *
310     * @return indicator for html option.
311     */

312    public boolean getHtml() {
313       return html;
314    }
315
316    /**
317     * Method sets indicator for html option.
318     *
319     * @param html indicator for html option.
320     */

321    public void setHtml(boolean html) {
322       this.html = html;
323    }
324
325    /**
326     * Method gets indicator for pdf option.
327     *
328     * @return indicator for pdf option.
329     */

330    public boolean getPdf() {
331       return pdf;
332    }
333
334    /**
335     * Method sets indicator for pdf option.
336     *
337     * @param pdf indicator for pdf option.
338     */

339    public void setPdf(boolean pdf) {
340       this.pdf = pdf;
341    }
342
343    /**
344     * Method gets indicator for xmi option.
345     *
346     * @return indicator for xmi option.
347     */

348    public boolean getXmi() {
349       return xmi;
350    }
351
352    /**
353     * Method sets indicator for xmi option.
354     *
355     * @param xmi indicator for xmi option.
356     */

357    public void setXmi(boolean xmi) {
358       this.xmi = xmi;
359    }
360
361    /**
362     * Method gets indicator for ptl option.
363     *
364     * @return indicator for ptl option.
365     */

366    public boolean getPtl() {
367       return ptl;
368    }
369
370    /**
371     * Method sets indicator for ptl option.
372     *
373     * @param ptl indicator for ptl option.
374     */

375    public void setPtl(boolean ptl) {
376       this.ptl = ptl;
377    }
378
379    /**
380     * Method gets invoke indicator.
381     *
382     * @return invoke indicator.
383     */

384    public boolean getInvoke() {
385       return invoke;
386    }
387
388    /**
389     * Method sets invoke indicator.
390     *
391     * @param invoke invoke indicator.
392     */

393    public void setInvoke(boolean invoke) {
394       this.invoke = invoke;
395    }
396
397    /**
398     * Method gets indicator for kelp option.
399     *
400     * @return indicator for kelp option.
401     */

402    public boolean getKelp() {
403       return kelp;
404    }
405
406    /**
407     * Method sets indicator for kelp option.
408     *
409     * @param kelp indicator for kelp option.
410     */

411    public void setKelp(boolean kelp) {
412       this.kelp = kelp;
413    }
414
415    /**
416     * Method runs wizard's GUI .
417     */

418    public void runWizard() {
419       wizard.startup();
420    }
421
422    /**
423     * This method is called by wizard before generate action. User should
424     * override this method to involve any pre-generating action.
425     */

426    public void preGenerate() {}
427
428    /**
429     * This method is called by wizard after generate action. User should
430     * override this method to involve any post-generating action.
431     */

432    public void postGenerate() {}
433
434    /**
435     * This method is called before wizard closing. User should
436     * override this method to involve any pre-closing action.
437     */

438    public void preClose() {}
439
440    /**
441     * This method is called after wizard closing. User should
442     * override this method to involve any post-closing action.
443     */

444    public void preCancel() {}
445
446    /**
447     * Generation of DODS code means generation of ant-build, sql and java files.
448     * Method produces <code>Procces</code> which will generate code.
449     *
450     * @param outputDir full path to output directory that will be used.
451     * @param domlFile full path to .doml file for generating code.
452     * @param action type of generation.
453     * @param templateSet template set which will be used for generating java code.
454     * @param forceBuild "true" if code will be always generated, otherwise only
455     * changes will be regenerated.
456     * @param database database vendor for generating sql files.
457     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
458     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
459     *
460     * @return procces which will generate code.
461     *
462     * @exception DODSGenerateException if any error occurs.
463     * <p>
464     * Example:
465     * <blockquote><pre>
466     * String s;
467     * Process p = DODSGenerator.generateCode(outputDir,doml,action,template,force,false);
468     * BufferedReader buffer = new BufferedReader(new InputStreamReader(p.getInputStream()));
469     * while((s = buffer.readLine()) != null) {
470     * System.out.println(s);
471     * }
472     * </pre></blockquote>
473     */

474
475
476
477    public static Process JavaDoc generateCode(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc action, String JavaDoc templateSet,
478                                       String JavaDoc forceBuild, String JavaDoc database, boolean ownErrorReader)
479       throws DODSGenerateException {
480       java.lang.Process JavaDoc process = null;
481
482       try {
483          if (action == null) {
484             action = "dods:build_all";
485          } // default action
486
if (templateSet == null) {
487             templateSet = "standard";
488          } // default template set
489
if (forceBuild == null) {
490             forceBuild = "false";
491          } // default no force generating
492
if (database == null) {
493             database = DATABASE_NOT_SET;
494          } // default no force generating
495
// call org.enhydra.dods.generator.DODSEjenProperties
496
java.util.ArrayList JavaDoc argsList = new ArrayList JavaDoc();
497
498          argsList.add(domlFile);
499          argsList.add(outputDir);
500          argsList.add(templateSet);
501          argsList.add(database);
502          argsList.add(forceBuild);
503          String JavaDoc className = "org.enhydra.dods.generator.DODSEjenProperties";
504          java.lang.reflect.Method JavaDoc m = null;
505          java.lang.Class JavaDoc c = null;
506
507          c = java.lang.Class.forName(className);
508          m = c.getMethod("main", new java.lang.Class JavaDoc[] {
509                   String JavaDoc[].class
510                });
511          String JavaDoc args[] = (String JavaDoc[]) argsList.toArray(((java.lang.Object JavaDoc[]) (
512                                                          new String JavaDoc[argsList.size()])));
513
514          if (m != null) {
515             m.invoke(((java.lang.Object JavaDoc) (null)), new java.lang.Object JavaDoc[] {
516                      args
517                   });
518          }
519
520          String JavaDoc as[] = null;
521          String JavaDoc endorsing = System.getProperty("DODS_ENDORSED", null);
522          //System.err.println("DODS_ENDORSED is "+ endorsing);
523
as = new String JavaDoc[12];
524          as[0] = System.getProperty("JAVA_HOME") + File.separator + "bin"
525             + File.separator + "java";
526          as[1] = "-DDODS_HOME=" + System.getProperty("DODS_HOME");
527          as[2] = "-DPROJECT_ROOT=" + outputDir;
528          as[3] = "-DDOML_FILE=" + domlFile;
529          as[4] = "-DTEMPLATESET=" + templateSet;
530          as[5] = "-DDATABASE_VENDOR=" + database;
531          as[6] = "-DFORCE=" + forceBuild;
532          as[7] = (null != endorsing)
533             ?("-Djava.endorsed.dirs=" + endorsing)
534             :("-DDODS_HOME=" + System.getProperty("DODS_HOME"));
535          as[8] = "org.apache.tools.ant.Main";
536          as[9] = "-f";
537          as[10] = new String JavaDoc(System.getProperty("DODS_HOME") + File.separator
538                                 + "build" + File.separator + "generate.xml");
539          as[11] = action;
540          process = Runtime.getRuntime().exec(as);
541          if (!ownErrorReader) {
542             BufferedReader JavaDoc errorBufferedReader = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
543
544             (new ErrorReader(errorBufferedReader, true)).start();
545          }
546       } catch (ClassNotFoundException JavaDoc e) {
547          throw new DODSGenerateException(e);
548       } catch (NoSuchMethodException JavaDoc e) {
549          throw new DODSGenerateException(e);
550       } catch (IllegalAccessException JavaDoc e) {
551          throw new DODSGenerateException(e);
552       } catch (IOException JavaDoc e) {
553          throw new DODSGenerateException(e);
554       } catch (InvocationTargetException JavaDoc e) {
555          throw new DODSGenerateException(e);
556       }
557       return process;
558    }
559
560    /**
561     * Generation of DODS code means generation of ant-build, sql and java files.
562     * Method produces <code>Procces</code> which will generate code.
563     *
564     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
565     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
566     *
567     * @return procces which will generate code.
568     *
569     * @exception DODSGenerateException if any error occurs.
570     * <p>
571     * Example:
572     * <blockquote><pre>
573     * String s;
574     * Process p = DODSGenerator.generateCode(false);
575     * BufferedReader buffer = new BufferedReader(new InputStreamReader(p.getInputStream()));
576     * while((s = buffer.readLine()) != null) {
577     * System.out.println(s);
578     * }]
579     * </pre></blockquote>
580     */

581    public Process JavaDoc generateCode(boolean ownErrorReader)
582       throws DODSGenerateException {
583       return generateCode(outputDir, doml, action, templateSet, force,
584                           database, ownErrorReader);
585    }
586
587    /**
588     * Generates DODS html documentation from .doml file.
589     * Method produces <code>Procces</code> which will generate documentation.
590     *
591     * @param outputDir full path to output directory that will be used.
592     * @param domlFile full path to .doml file for generating code.
593     * @param htmlFile output html file.
594     * @param forceBuild "true" if code will be always generated, otherwise only changes
595     * will be regenerated.
596     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
597     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
598     *
599     * @return procces which will generate code.
600     *
601     * @exception DODSGenerateException if any error occurs.
602     *
603     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
604     */

605    public static Process JavaDoc generateHTML(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc htmlFile,
606                                       String JavaDoc forceBuild, boolean ownErrorReader)
607       throws DODSGenerateException {
608       return generateDocumentation(outputDir, domlFile, htmlFile, forceBuild,
609                                    ownErrorReader, "html", "html");
610    }
611
612    /**
613     * Generates DODS html documentation from .doml file.
614     * Method produces <code>Procces</code> which will generate documentation.
615     *
616     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
617     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
618     *
619     * @return procces which will generate code.
620     *
621     * @exception DODSGenerateException if any error occurs.
622     *
623     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
624     */

625
626    public Process JavaDoc generateHTML(boolean ownErrorReader)
627       throws DODSGenerateException {
628       return generateDocumentation(outputDir,doml,null,force,ownErrorReader,"html","html");
629    }
630    /**
631     * Generates DODS pdf documentation from .doml file.
632     * Method produces <code>Procces</code> which will generate documentation.
633     *
634     * @param outputDir full path to output directory that will be used.
635     * @param domlFile full path to .doml file for generating code.
636     * @param pdfFile output pdf file.
637     * @param forceBuild "true" if code will be always generated, otherwise only changes
638     * will be regenerated.
639     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
640     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
641     *
642     * @return procces which will generate code.
643     *
644     * @exception DODSGenerateException if any error occurs.
645     *
646     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
647     */

648    public static Process JavaDoc generatePDF(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc pdfFile,
649                                      String JavaDoc forceBuild, boolean ownErrorReader)
650       throws DODSGenerateException {
651       return generateDocumentation(outputDir, domlFile, pdfFile, forceBuild,
652                                    ownErrorReader, "pdf", "pdf");
653    }
654
655    /**
656     * Generates DODS pdf documentation from .doml file.
657     * Method produces <code>Procces</code> which will generate documentation.
658     *
659     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
660     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
661     *
662     * @return procces which will generate code.
663     *
664     * @exception DODSGenerateException if any error occurs.
665     *
666     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
667     */

668    public Process JavaDoc generatePDF(boolean ownErrorReader)
669       throws DODSGenerateException {
670       return generateDocumentation(outputDir, doml, null, force,
671                                    ownErrorReader, "pdf", "pdf");
672    }
673
674    /**
675     * Generates DODS xmi documentation from .doml file.
676     * Method produces <code>Procces</code> which will generate documentation.
677     *
678     * @param outputDir full path to output directory that will be used.
679     * @param domlFile full path to .doml file for generating code.
680     * @param xmiFile output xmi file.
681     * @param forceBuild "true" if code will be always generated, otherwise only changes
682     * will be regenerated.
683     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
684     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
685     *
686     * @return procces which will generate code.
687     *
688     * @exception DODSGenerateException if any error occurs.
689     *
690     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
691     */

692    public static Process JavaDoc generateXMI(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc xmiFile,
693                                      String JavaDoc forceBuild, boolean ownErrorReader)
694       throws DODSGenerateException {
695       return generateDocumentation(outputDir, domlFile, xmiFile, forceBuild,
696                                    ownErrorReader, "xmi", "xmi");
697    }
698
699    /**
700     * Generates DODS xmi documentation from .doml file.
701     * Method produces <code>Procces</code> which will generate documentation.
702     *
703     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
704     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
705     *
706     * @return procces which will generate code.
707     *
708     * @exception DODSGenerateException if any error occurs.
709     *
710     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
711     */

712    public Process JavaDoc generateXMI(boolean ownErrorReader)
713       throws DODSGenerateException {
714       return generateDocumentation(outputDir, doml, null, force,
715                                    ownErrorReader, "xmi", "xmi");
716    }
717
718    /**
719     * Generates DODS ptl (Rational Rose) documentation from .doml file.
720     * Method produces <code>Procces</code> which will generate documentation.
721     *
722     * @param outputDir full path to output directory that will be used.
723     * @param domlFile full path to .doml file for generating code.
724     * @param ptlFile output ptl file.
725     * @param forceBuild "true" if code will be always generated, otherwise only changes
726     * will be regenerated.
727     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
728     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
729     *
730     * @return procces which will generate code.
731     *
732     * @exception DODSGenerateException if any error occurs.
733     *
734     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
735     */

736    public static Process JavaDoc generatePTL(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc ptlFile,
737                                      String JavaDoc forceBuild, boolean ownErrorReader)
738       throws DODSGenerateException {
739       return generateDocumentation(outputDir, domlFile, ptlFile, forceBuild,
740                                    ownErrorReader, "ptl", "ptl");
741    }
742
743    /**
744     * Generates DODS ptl documentation from .doml file.
745     * Method produces <code>Procces</code> which will generate documentation.
746     *
747     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
748     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
749     *
750     * @return procces which will generate code.
751     *
752     * @exception DODSGenerateException if any error occurs.
753     *
754     * @see org.enhydra.dods.generator.DODSGenerator#generateCode(String, String, String, String, String, String, boolean)
755     */

756    public Process JavaDoc generatePTL(boolean ownErrorReader)
757       throws DODSGenerateException {
758       return generateDocumentation(outputDir, doml, null, force,
759                                    ownErrorReader, "ptl", "ptl");
760    }
761
762    /*
763     * Generates DODS documentation from .doml file.
764     * Method produces <code>Procces</code> which will generate documentation.
765     */

766    private static Process JavaDoc generateDocumentation(String JavaDoc outputDir, String JavaDoc doml, String JavaDoc outputName, String JavaDoc forceBuild,
767                                                 boolean ownErrorReader, String JavaDoc type, String JavaDoc extension)
768       throws DODSGenerateException {
769       java.lang.Process JavaDoc process = null;
770       String JavaDoc as[] = new String JavaDoc[3];
771
772       try {
773          if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
774             as[0] = System.getProperty("DODS_HOME") + File.separator + "bin"
775                + File.separator + "doml2" + type + ".bat";
776          } else {
777             as[0] = System.getProperty("DODS_HOME") + File.separator + "bin"
778                + File.separator + "doml2" + type;
779          }
780          as[1] = doml;
781          if (outputName == null) {
782             int index = doml.lastIndexOf(File.separator);
783
784             if (index != -1) {
785                outputName = doml.substring(index + 1);
786             } else {
787                outputName = doml;
788             }
789             outputName = outputName.substring(0,
790                                               outputName.lastIndexOf(".doml"));
791          }
792          as[2] = outputDir + File.separator + outputName + "." + extension;
793          process = Runtime.getRuntime().exec(as);
794          if (!ownErrorReader) {
795             BufferedReader JavaDoc errorBufferedReader = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
796
797             (new ErrorReader(errorBufferedReader, true)).start();
798          }
799       } catch (IOException JavaDoc e) {
800          throw new DODSGenerateException(e);
801       } catch (StringIndexOutOfBoundsException JavaDoc e) {
802          throw new DODSGenerateException(e);
803       }
804       return process;
805    }
806
807    /**
808     * Generation of DODS code means generation of ant-build, sql, java files, html, pdf,
809     * xmi and ptl. Method produces <code>Procces</code> which will generate code.
810     *
811     * @param outputDir full path to output directory that will be used.
812     * @param domlFile full path to .doml file for generating code.
813     * @param genAction type of generation.
814     * @param templateSet template set which will be used for generating java code.
815     * @param database database vendor for generating sql files.
816     * @param genHtml if <code>true</code> generates DODS html documentation from .doml file.
817     * @param genPdf if <code>true</code> generates DODS pdf documentation from .doml file.
818     * @param genXmi if <code>true</code> generates DODS xmi documentation from .doml file.
819     * @param genPtl if <code>true</code> generates DODS ptl documentation from .doml file.
820     *
821     * @return error code of executing process.
822     *
823     * @exception DODSGenerateException if any error occurs.
824     */

825    public static int generateAll(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc genAction, String JavaDoc templateSet,
826                                  String JavaDoc forceBuild, String JavaDoc database, boolean genHtml, boolean genPdf,
827                                  boolean genXmi, boolean genPtl)
828       throws DODSGenerateException {
829       int exit = 0;
830
831       try {
832          ErrorReader errorReader;
833          Process JavaDoc process;
834          BufferedReader JavaDoc buffer;
835          BufferedReader JavaDoc error;
836          String JavaDoc s;
837          File JavaDoc f = new File JavaDoc(domlFile);
838
839          outputDir = (new File JavaDoc(outputDir)).getAbsolutePath();
840          File JavaDoc dir = new File JavaDoc(outputDir);
841
842          dir.mkdirs();
843          domlFile = f.getAbsolutePath();
844          f = new File JavaDoc(domlFile);
845          if (!f.exists()) {
846             throw new DODSGenerateException(NONEXISTING_DOML_FILE + " "
847                                                + domlFile + "\n");
848          }
849          if (genHtml) {
850             process = DODSGenerator.generateHTML(outputDir, domlFile, null,
851                                                  "true", true);
852             buffer = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
853             error = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
854             (new ErrorReader(error, true)).start();
855             while ((s = buffer.readLine()) != null) {
856                System.out.println(s);
857             }
858             if (exit != 0) {
859                return exit;
860             }
861          }
862          if (genPdf) {
863             process = DODSGenerator.generatePDF(outputDir, domlFile, null,
864                                                 "true", true);
865             buffer = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
866             error = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
867             (new ErrorReader(error, true)).start();
868             while ((s = buffer.readLine()) != null) {
869                System.out.println(s);
870             }
871             if (exit != 0) {
872                return exit;
873             }
874          }
875          if (genXmi) {
876             process = DODSGenerator.generateXMI(outputDir, domlFile, null,
877                                                 "true", true);
878             buffer = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
879             error = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
880             (new ErrorReader(error, true)).start();
881             while ((s = buffer.readLine()) != null) {
882                System.out.println(s);
883             }
884             if (exit != 0) {
885                return exit;
886             }
887          }
888          if (genPtl) {
889             process = DODSGenerator.generatePTL(outputDir, domlFile, null,
890                                                 "true", true);
891             buffer = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
892             error = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
893             (new ErrorReader(error, true)).start();
894             while ((s = buffer.readLine()) != null) {
895                System.out.println(s);
896             }
897             if (exit != 0) {
898                return exit;
899             }
900          }
901          if(!genAction.equalsIgnoreCase("dods:generatorOff")){
902             process = DODSGenerator.generateCode(outputDir, domlFile, genAction,
903                                                  templateSet, forceBuild, database, true);
904             buffer = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
905             error = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
906             (new ErrorReader(error, true)).start();
907             while ((s = buffer.readLine()) != null) {
908                System.out.println(s);
909             }
910             exit = process.waitFor();
911          }
912       } catch (IOException JavaDoc e) {
913          throw new DODSGenerateException(e);
914       } catch (InterruptedException JavaDoc e) {
915          throw new DODSGenerateException(e);
916       } catch (DODSGenerateException e) {
917          Throwable JavaDoc pe = e.getCause();
918          if (pe instanceof java.lang.StringIndexOutOfBoundsException JavaDoc) {
919             System.out.println(INVALID_DOML_FILE + domlFile + "\n");
920          } else {
921             throw new DODSGenerateException(e);
922          }
923       }
924       return exit;
925    }
926
927    /**
928     * Generation of DODS code means generation of ant-build, sql, java files, html, pdf,
929     * xmi and ptl. Method produces <code>Procces</code> which will generate code.
930     *
931     * @param outputDir full path to output directory that will be used.
932     * @param domlFile full path to .doml file for generating code.
933     * @param genAction type of generation.
934     * @param templateDir template directory.
935     * @param templateSet template set which will be used for generating java code.
936     * @param database database vendor for generating sql files.
937     * @param genHtml if <code>true</code> generates DODS html documentation from .doml file.
938     * @param genPdf if <code>true</code> generates DODS pdf documentation from .doml file.
939     * @param genXmi if <code>true</code> generates DODS xmi documentation from .doml file.
940     * @param genPtl if <code>true</code> generates DODS ptl documentation from .doml file.
941     *
942     * @return error code of executing process.
943     *
944     * @exception DODSGenerateException if any error occurs.
945     */

946
947    public static int generateAll(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc genAction, String JavaDoc configDir, String JavaDoc templateDir,
948                                  String JavaDoc templateSet, String JavaDoc forceBuild, String JavaDoc database, boolean genHtml, boolean genPdf,
949                                  boolean genXmi, boolean genPtl)
950       throws DODSGenerateException {
951       Common.setCustomTemplateDir(templateDir);
952       Common.setConfigDir(configDir);
953
954       return generateAll(outputDir, domlFile, genAction, templateSet,
955                          forceBuild, database, genHtml, genPdf, genXmi, genPtl);
956    }
957
958    /**
959     * Generation of DODS code means generation of ant-build, sql, java files, html, pdf,
960     * xmi and ptl. Method produces <code>Procces</code> which will generate code.
961     *
962     * @return error code of executing process.
963     *
964     * @exception DODSGenerateException if any error occurs.
965     */

966    public int generateAll()
967       throws DODSGenerateException {
968       return generateAll(outputDir, doml, action, templateSet, force, database,
969                          html, pdf, xmi, ptl);
970    }
971
972    /**
973     * Generation of DODS code means generation of ant-build, sql, java files, html, pdf,
974     * xmi and ptl. Method produces <code>Procces</code> which will generate code.
975     * This method call (dods.bat/dods) with all parameters.
976     *
977     * @param outputDir full path to output directory that will be used.
978     * @param domlFile full path to .doml file for generating code.
979     * @param genAction type of generation.
980     * @param configDir path to configuration directory
981     * @param templateSet template set which will be used for generating java code.
982     * @param forceBuild "true" if code will be always generated, otherwise only
983     * changes will be regenerated.
984     * @param database database vendor for generating sql files.
985     * @param genHtml if <code>true</code> generates DODS html documentation from .doml file.
986     * @param genPdf if <code>true</code> generates DODS pdf documentation from .doml file.
987     * @param genXmi if <code>true</code> generates DODS xmi documentation from .doml file.
988     * @param genPtl if <code>true</code> generates DODS ptl documentation from .doml file.
989     * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
990     * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
991     *
992     * @return procces which will generate code.
993     *
994     * @exception DODSGenerateException if any error occurs.
995     */

996    public static Process JavaDoc generateAll(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc genAction, String JavaDoc configDir,
997                                      String JavaDoc templateSet, String JavaDoc forceBuild, String JavaDoc database,
998                                      boolean genHtml, boolean genPdf, boolean genXmi,
999                                      boolean genPtl, boolean ownErrorReader)
1000      throws DODSGenerateException {
1001      int exit = 0;
1002      Process JavaDoc process = null;
1003
1004      try {
1005         ErrorReader errorReader;
1006         BufferedReader JavaDoc buffer;
1007         BufferedReader JavaDoc error;
1008         String JavaDoc s;
1009         File JavaDoc f = new File JavaDoc(domlFile);
1010
1011         outputDir = (new File JavaDoc(outputDir)).getAbsolutePath();
1012         domlFile = f.getAbsolutePath();
1013         f = new File JavaDoc(domlFile);
1014         if (!f.exists()) {
1015            throw new DODSGenerateException(NONEXISTING_DOML_FILE + " "
1016                                               + domlFile + "\n");
1017         }
1018         String JavaDoc tmp[] = new String JavaDoc[16];
1019         int param = 1;
1020
1021         if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
1022            tmp[0] = System.getProperty("DODS_HOME") + File.separator
1023               + "bin" + File.separator + "dods.bat";
1024         } else {
1025            tmp[0] = System.getProperty("DODS_HOME") + File.separator
1026               + "bin" + File.separator + "dods";
1027         }
1028         if (genAction != null) {
1029            tmp[param] = "-a";
1030            param++;
1031            tmp[param] = genAction;
1032            param++;
1033         }
1034         if (configDir != null) {
1035            tmp[param] = "-c";
1036            param++;
1037            tmp[param] = configDir;
1038            param++;
1039         }
1040         if (templateSet != null) {
1041            tmp[param] = "-t";
1042            param++;
1043            tmp[param] = templateSet;
1044            param++;
1045         }
1046         if (forceBuild != null) {
1047            if (forceBuild.equals("true")) {
1048               tmp[param] = "-f";
1049               param++;
1050            }
1051         }
1052         if (database != null) {
1053            tmp[param] = "-b";
1054            param++;
1055            tmp[param] = database;
1056            param++;
1057         }
1058         if (genHtml) {
1059            tmp[param] = "-h";
1060            param++;
1061         }
1062         if (genPdf) {
1063            tmp[param] = "-p";
1064            param++;
1065         }
1066         if (genXmi) {
1067            tmp[param] = "-x";
1068            param++;
1069         }
1070         if (genPtl) {
1071            tmp[param] = "-r";
1072            param++;
1073         }
1074         tmp[param] = domlFile;
1075         param++;
1076         tmp[param] = outputDir;
1077         param++;
1078         String JavaDoc as[] = new String JavaDoc[param];
1079
1080         for (int i = 0; i < param; i++) {
1081            as[i] = tmp[i];
1082         }
1083         process = Runtime.getRuntime().exec(as);
1084         if (!ownErrorReader) {
1085            BufferedReader JavaDoc errorBufferedReader = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
1086
1087            (new ErrorReader(errorBufferedReader, true)).start();
1088         }
1089      } catch (IOException JavaDoc e) {
1090         e.printStackTrace();
1091         throw new DODSGenerateException(e);
1092      }
1093      return process;
1094   }
1095
1096   /**
1097    * Generation of DODS code means generation of ant-build, sql, java files, html, pdf,
1098    * xmi and ptl. Method produces <code>Procces</code> which will generate code.
1099    * This method call (dods.bat/dods) with all parameters.
1100    *
1101    * @param outputDir full path to output directory that will be used.
1102    * @param domlFile full path to .doml file for generating code.
1103    * @param genAction type of generation.
1104    * @param templateSet template set which will be used for generating java code.
1105    * @param forceBuild "true" if code will be always generated, otherwise only
1106    * changes will be regenerated.
1107    * @param database database vendor for generating sql files.
1108    * @param genHtml if <code>true</code> generates DODS html documentation from .doml file.
1109    * @param genPdf if <code>true</code> generates DODS pdf documentation from .doml file.
1110    * @param genXmi if <code>true</code> generates DODS xmi documentation from .doml file.
1111    * @param genPtl if <code>true</code> generates DODS ptl documentation from .doml file.
1112    * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
1113    * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
1114    *
1115    * @return procces which will generate code.
1116    *
1117    * @exception DODSGenerateException if any error occurs.
1118    */

1119   public static Process JavaDoc generateAll(String JavaDoc outputDir, String JavaDoc domlFile, String JavaDoc genAction,
1120                                     String JavaDoc templateSet, String JavaDoc forceBuild, String JavaDoc database,
1121                                     boolean genHtml, boolean genPdf, boolean genXmi,
1122                                     boolean genPtl, boolean ownErrorReader)
1123      throws DODSGenerateException {
1124      return generateAll(outputDir, domlFile, genAction, null, templateSet,
1125                          forceBuild, database, genHtml, genPdf, genXmi, genPtl,
1126                          ownErrorReader);
1127   }
1128
1129   /**
1130    * Generation of DODS code means generation of ant-build, sql, java files, html, pdf,
1131    * xmi and ptl. Method produces <code>Procces</code> which will generate code.
1132    * This method call (dods.bat/dods) with all parameters.
1133    *
1134    * @param ownErrorReader <code>true</code> if user needs to make its own ErrorReader,
1135    * otherwise (<code>false</code>) method will make <code>ErrorReader</code>.
1136    *
1137    * @return procces which will generate code.
1138    *
1139    * @exception DODSGenerateException if any error occurs.
1140    */

1141   public Process JavaDoc generateAll(boolean ownErrorReader)
1142      throws DODSGenerateException {
1143      return generateAll(outputDir, doml, action, configDir, templateSet,
1144                         force, database, html, pdf, xmi, ptl, ownErrorReader);
1145   }
1146
1147   /**
1148    * Generates Command line help.
1149    */

1150   public static void help() {
1151      String JavaDoc dods = "dods";
1152      String JavaDoc space = " ";
1153      String JavaDoc example = "/home/tanja/test/discRack.doml /home/tanja/test/discRack";
1154
1155      if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
1156         dods = "dods.bat";
1157         space = " ";
1158         example = "c:\\test\\discRack.doml c:\\test\\discRack";
1159      }
1160      System.out.println("\nCommand line help:\n");
1161      System.out.println(dods
1162                            + " [-?/help] [-a action] [-t templateset] [-b/-database] [-c confPath] ");
1163      System.out.println(space
1164                            + "[-f/force] [-h/html] [-p/pdf] [-x/xmi] [-r/ptl] domlfile outputdir\n");
1165      System.out.println(" where:\n");
1166      System.out.println(" outputdir full path to output directory that will be used.\n");
1167      System.out.println(" domlfile full path to .doml file for generating code.\n");
1168      System.out.println(" options:\n");
1169      System.out.println(" [-? -help] shows help.\n");
1170      System.out.println(" [-a action] ant task parameter for code generation:");
1171      System.out.println(" dods:build_all - to create all sql files and java classes (default).");
1172      System.out.println(" dods:sql - to create only sql files.");
1173      System.out.println(" dods:java - to create only java files and to compile them.");
1174      System.out.println(" dods:javaNoCompile - to create only java files and not to compile them.");
1175      System.out.println(" dods:noCompile - to create SQL files and java files and not to");
1176      System.out.println(" compile them.");
1177      System.out.println(" dods:build_all_split - to create all sql files and java classes and to");
1178      System.out.println(" compile it. SQL files will be divided into separate");
1179      System.out.println(" files using SQLSplitter .");
1180      System.out.println(" dods:sqlsplit - to create only sql files and separate in different");
1181      System.out.println(" files using SQLSplitter.");
1182      System.out.println(" dods:noCompileSplit - to create SQL files and separate sql commands using");
1183      System.out.println(" SQLSplitter and java files and not to compile them.\n");
1184      System.out.println(" [-t templateset] template set for generating java and sql code:");
1185      System.out.println(" standard - generate standard java code (default).");
1186      System.out.println(" <user_defined> - any user defined template set.\n");
1187      System.out.println(" [-b/-database] sets database vendor for generating sql.\n");
1188      System.out.println(" [-c confPath] sets folder with dodsConf.xml file \n");
1189      System.out.println(" [-f/-force] with this switch, code will be always generated, without it, only changes");
1190      System.out.println(" will be regenerated.\n");
1191      System.out.println(" [-h/-html] generates DODS html documentation from .doml file.\n");
1192      System.out.println(" [-p/-pdf] generates DODS pdf documentation from .doml file.\n");
1193      System.out.println(" [-x/-xmi] generates DODS xmi documentation from .doml file.\n");
1194      System.out.println(" [-r/-ptl] generates DODS ptl (Rational Rose) documentation from .doml file.\n");
1195      System.out.println("Example:\n");
1196      System.out.println(" " + dods + " -a dods:java -t standard -f -pdf -x "
1197                            + example + "\n");
1198   }
1199
1200   /**
1201    * Parses input parameters.
1202    *
1203    * @param args array of input command line parameters.
1204    * @return error message, null if parsing was OK.
1205    */

1206   public String JavaDoc parse(String JavaDoc[] args) {
1207      try {
1208         int curr = 0;
1209         int param = -1;
1210
1211         while (curr < args.length) {
1212            Integer JavaDoc integer = (Integer JavaDoc) parameters.get(args[curr]);
1213
1214            if (integer == null) {
1215               break;
1216            }
1217            param = integer.intValue();
1218            curr++;
1219            switch (param) {
1220               case HELP_PARAMETER: {
1221                     help = true;
1222                     return HELP_MESSAGE;
1223                  }
1224
1225               case ACTION_PARAMETER: {
1226                     if (actions.contains(args[curr])) {
1227                        action = args[curr];
1228                     } else {
1229                        return INVALID_ACTION_PARAMETER_MESSAGE + args[curr];
1230                     }
1231                     curr++;
1232                     break;
1233                  }
1234
1235               case CONFIGURATION_DIR_PARAMETER: {
1236                     configDir = args[curr];
1237                     curr++;
1238                     break;
1239                  }
1240
1241               case TEMPLATE_SET_PARAMETER: {
1242                     templateSet = args[curr];
1243                     curr++;
1244                     break;
1245                  }
1246
1247               case DATABASE_PARAMETER: {
1248                     database = args[curr];
1249                     curr++;
1250                     break;
1251                  }
1252
1253               case FORCE_PARAMETER: {
1254                     force = "true";
1255                     break;
1256                  }
1257
1258               case HTML_PARAMETER: {
1259                     html = true;
1260                     break;
1261                  }
1262
1263               case PDF_PARAMETER: {
1264                     pdf = true;
1265                     break;
1266                  }
1267
1268               case XMI_PARAMETER: {
1269                     xmi = true;
1270                     break;
1271                  }
1272
1273               case PTL_PARAMETER: {
1274                     ptl = true;
1275                     break;
1276                  }
1277            } // switch
1278
} // while
1279

1280         try {
1281            Common.setConfigDir(configDir);
1282         } catch (Error JavaDoc e) {
1283            return INVALID_CONF_DIR_MESSAGE + configDir;
1284         }
1285         templateSets = Common.getAllTemplateSets();
1286
1287         if (!templateSets.contains(templateSet)) {
1288            return INVALID_TEMPLATE_SET_PARAMETER_MESSAGE + templateSet;
1289         }
1290         if (args.length - curr < 2) {
1291            return INVALID_NUMBER_OF_PARAMETER_MESSAGE;
1292         }
1293         if (args[curr].startsWith("-") || args[curr + 1].startsWith("-")) {
1294            return INVALID_PARAMETER_MESSAGE + args[curr];
1295         }
1296         doml = args[curr];
1297         outputDir = args[curr + 1];
1298      } catch (NullPointerException JavaDoc e) {
1299         return INVALID_PARAMETER_MESSAGE;
1300      } catch (ArrayIndexOutOfBoundsException JavaDoc e) {
1301         return INVALID_NUMBER_OF_PARAMETER_MESSAGE;
1302      }
1303      return null;
1304   }
1305
1306   /**
1307    * Generates DODS.
1308    * Method parses command line parameters and, depending on that, calls wizard
1309    * or generates DODS.
1310    *
1311    * <blockquote><pre>
1312    * Command line:
1313    * dods [-?/help] [-a action] [-t templateset] [-b/-database] [-c confPath]
1314    * [-f/force] [-h/html] [-p/pdf] [-x/xmi] [-r/ptl] domlfile outputdir
1315    *
1316    * where:
1317    *
1318    * outputdir full path to output directory that will be used.
1319    *
1320    * domlfile full path to .doml file for generating code.
1321    *
1322    * options:
1323    *
1324    * [-? -help] shows help.
1325    *
1326    * [-a action] ant task parameter for code generation:
1327    * dods:build_all - to create all sql files and java classes (default).
1328    * dods:sql - to create only sql files.
1329    * dods:java - to create only java files and to compile them.
1330    * dods:javaNoCompile - to create only java files and not to compile them.
1331    * dods:noCompile - to create SQL files and java files and not to
1332    * compile them.
1333    * dods:build_all_split - to create all sql files and java classes and to
1334    * compile it. SQL files will be divided into separate
1335    * files using SQLSplitter .
1336    * dods:sqlsplit - to create only sql files and separate in different
1337    * files using SQLSplitter.
1338    * dods:noCompileSplit - to create SQL files and separate sql commands using
1339    * SQLSplitter and java files and not to compile them.
1340    *
1341    * [-t templateset] template set for generating java and sql code:
1342    * standard - generate standard java code (default).
1343    * <user_defined> - any user defined template set.
1344    *
1345    * [-b/-database] sets database vendor for generating sql.
1346    *
1347    * [-c confPath] sets folder with dodsConf.xml file.
1348    *
1349    * [-f/-force] with this switch, code will be always generated, without it, only changes
1350    * will be regenerated.
1351    *
1352    * [-h/-html] generates DODS html documentation from .doml file.
1353    *
1354    * [-p/-pdf] generates DODS pdf documentation from .doml file.
1355    *
1356    * [-x/-xmi] generates DODS xmi documentation from .doml file.
1357    *
1358    * [-r/-ptl] generates DODS ptl (Rational Rose) documentation from .doml file.
1359    *
1360    * <p>
1361    * Example:
1362    * DODSGenerator -a dods:java -t standard -f -pdf -x discrack.doml /test/discRack
1363    * </pre></blockquote>
1364    */

1365   public static void main(String JavaDoc[] args) {
1366      DODSGenerator generator = new DODSGenerator();
1367
1368      if (args.length == 0) {
1369         generator.runWizard();
1370         return;
1371      }
1372      try {
1373         String JavaDoc message = generator.parse(args);
1374
1375         if (message != null) {
1376            System.out.println(message);
1377            help();
1378            return;
1379         }
1380         int exit = generator.generateAll();
1381
1382         System.exit(exit);
1383      } catch (DODSGenerateException e) {
1384         String JavaDoc message = e.getLocalizedMessage();
1385
1386         if (message != null) {
1387            System.out.println(message);
1388         } else {
1389            e.printStackTrace();
1390         }
1391      } catch (Exception JavaDoc e) {
1392         e.printStackTrace();
1393      }
1394   }
1395
1396   /**
1397    * @param conDir Sets configuration directory
1398    */

1399   public void setConfigDir(String JavaDoc conDir) {
1400      configDir = conDir;
1401   }
1402
1403   /**
1404    * @return actual config dir
1405    */

1406   public String JavaDoc getConfigDir() {
1407      return configDir;
1408   }
1409}
1410
Popular Tags