Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/trapezium/chisel/CLChisel.java


1   /*
2    * @(#)CLChisel.java
3    *
4    * Copyright (c) 1998-2000 by Trapezium Development LLC.  All Rights Reserved.
5    *
6    * The information in this file is the property of Trapezium Development LLC
7    * and may be used only in accordance with the terms of the license granted
8    * by Trapezium.
9    *
10   */
11  package com.trapezium.chisel;
12  
13  import com.trapezium.chisel.gui.AboutPanel;
14  import com.trapezium.util.WildCardFilter;
15  
16  import java.io.File;
17  import java.util.StringTokenizer;
18  import java.util.Vector;
19  
20  
21  /** Main class for command line version of Chisel.
22   *
23   *  @author          Johannes N. Johannsen
24   *  @version         1.0, 4 Dec 1998
25   *
26   *  @since           1.0
27   */
28  
29  public class CLChisel {
30  
31      /** application directory */
32      public static String appDirectory;
33  
34      private static ChiselAccess access;
35  
36      static final boolean accessAllowed() {
37          return access.accessAllowed();
38      }
39  
40      public static void main(String[] args) {
41      System.out.println( "Command Line Chisel, Version 1.0, build 107x" );
42      System.out.println( Chisel.trapeziumHeader );
43  
44          String javaversion = System.getProperty("java.version");
45          if (javaversion.compareTo("1.1.2") < 0) {
46              System.out.println("Warning: outdated Java VM; some features will not be available.");
47              System.out.println("To enable all features run on a version 1.1.2 or higher VM.");
48          }
49  
50          /////
51          System.out.println("Java version " + javaversion);
52          String classpath = System.getProperty("java.class.path");
53          System.out.println("Classpath = " + classpath);
54  
55          appDirectory = "";
56          StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator);
57          while (st.hasMoreTokens()) {
58              String path = st.nextToken();
59              if (path.toLowerCase().endsWith("chisel.jar")) {
60                  if ( path.length() > 10 ) {
61                      appDirectory = path.substring( 0, path.length() - 10 );
62                  } else {
63                      appDirectory = "";
64                  }
65                  break;
66              }
67          }
68          System.out.println("Chisel directory: " + appDirectory);
69          /////
70  
71          ChiselSet[] sets = ChiselSet.createChiselSets();
72  
73          Vector filesToProcess = new Vector();
74          ChiselCommandList chiselCommandList = null;
75          boolean doGzip = false;
76          boolean preserveNames = false;
77          boolean stripComments = false;
78          boolean reformat = false;
79          String outputDir = null;
80      if ( args.length != 0 ) {
81        for ( int i = 0; i < args.length; i++ ) {
82                  if ( WildCardFilter.isWild( args[i] )) {
83                      File thisDir = new File( "." );
84                      String[] files = thisDir.list( new WildCardFilter( args[i] ));
85                      for ( int j = 0; j < files.length; j++ ) {
86                          filesToProcess.addElement( files[j] );
87                      }
88                  } else if ( isHtml( args[i] )) {
89                      chiselCommandList = new ChiselCommandList( args[i], sets );
90                  } else if ( args[i].compareTo( "-gzip" ) == 0 ) {
91                      doGzip = true;
92                  } else if ( args[i].compareTo( "-preserve" ) == 0 ) {
93                      preserveNames = true;
94                  } else if ( args[i].compareTo( "-nocomment" ) == 0 ) {
95                      stripComments = true;
96                  } else if ( args[i].compareTo( "-format" ) == 0 ) {
97                      reformat = true;
98                  } else if ( args[i].compareTo( "-output" ) == 0 ) {
99                      if (( i + 1 ) < args.length ) {
100                         i++;
101                         outputDir = args[i];
102                     }
103                 } else {
104                     filesToProcess.addElement( args[i] );
105                 }
106       }
107       }
108 
109       // If there is no HTML template file, print error message
110         boolean exitFlag = false;
111         if ( chiselCommandList == null ) {
112             System.out.println( "No HTML report file found." );
113             exitFlag = true;
114         }
115     if (( chiselCommandList == null ) || ( chiselCommandList.getNumberCommands() == 0 )) {
116       System.out.println( "No chisel requests found in HTML report file." );
117       exitFlag = true;
118     }
119         if ( filesToProcess.size() == 0 ) {
120             System.out.println( "No files to process." );
121             exitFlag = true;
122         }
123         if ( exitFlag ) {
124             System.exit( 0 );
125         }
126 
127         // Create the ChiselEngine and start it running
128         ChiselEngine theEngine = new ChiselEngine( filesToProcess, chiselCommandList, doGzip, outputDir, preserveNames, stripComments, reformat );
129         theEngine.start();
130         try {
131             theEngine.join();
132         } catch ( Exception e ) {
133         }
134         System.exit( theEngine.getResult() );
135     }
136 
137 
138     static boolean isHtml( String fileName ) {
139         String lowerFileName = fileName.toLowerCase();
140         return( lowerFileName.indexOf( ".htm" ) > 0 );
141     }
142  }
143