au.gov.tas.dpiwe.mr.tool
Class BatchFileCreator

java.lang.Object
  extended by au.gov.tas.dpiwe.mr.tool.BatchFileCreator
Direct Known Subclasses:
ObeyFileCreator

public class BatchFileCreator
extends Object

This tool creates batch file versions of all shell scripts. Shell scripts are turned into batch files as follows:

This is all pretty simplistic. If your shell scripts are using full pathnames as command paths, or a lot of switches or operational pipes, you will have problems. Also, the above is the complete command set you can use unless there is an equivalent executable in your DOS environment. e.g. You can call java and javac provided you have installed these into your DOS environment.

Since:
Mr Architecture 2.9
Version:
1.0.0.8
Author:
Kade Hansson

Field Summary
protected static ThreadLocal returnCode
           
 
Constructor Summary
BatchFileCreator()
           
 
Method Summary
static boolean createBatchFile(String toRewrite)
          Produce a batch file copy of a shell script.
protected static Process getBacktickProcess(String commandPath, StringTokenizer newCommand, File parentDir)
           
static void main(String[] argv)
          Initiates the BatchFileCreator tool.
static void rewriteAsBatch(Reader input, PrintWriter output, File parentDir)
          Produce a batch file corresponding to a shell script file.
protected static String translateLeaf(String leaf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

returnCode

protected static ThreadLocal returnCode
Constructor Detail

BatchFileCreator

public BatchFileCreator()
Method Detail

main

public static void main(String[] argv)
                 throws Throwable
Initiates the BatchFileCreator tool.

Parameters:
argv - arguments are filenames, directory names or switches (one of "-single" or "-multi").
Throws:
IOException - if the input files could not be read or the output files could not be written.
SecurityException - if the configured security policy is too restrictive.
Throwable - if something else goes wrong.

createBatchFile

public static boolean createBatchFile(String toRewrite)
                               throws InterruptedException,
                                      IOException,
                                      SecurityException
Produce a batch file copy of a shell script.

Parameters:
toRewrite - the name of the file to be copied.
Returns:
true if the file was successfully rewritten, false if the file remains unchanged.
Throws:
SecurityException - if the configured security policy is too restrictive.
IOException - if the input files could not be read or the output file could not be written.
InterruptException - another thread interrupted us.
InterruptedException

translateLeaf

protected static String translateLeaf(String leaf)

rewriteAsBatch

public static void rewriteAsBatch(Reader input,
                                  PrintWriter output,
                                  File parentDir)
                           throws InterruptedException,
                                  IOException
Produce a batch file corresponding to a shell script file.

Parameters:
input - the Reader from which the original shell script should be read.
output - the PrintWriter to which the created batch file should be written.
parentDir - the directory containing the input file.
Throws:
IOException - if the input file could not be read or the output file could not be written.
InterruptException - another thread interrupted us.
InterruptedException

getBacktickProcess

protected static Process getBacktickProcess(String commandPath,
                                            StringTokenizer newCommand,
                                            File parentDir)
                                     throws IOException
Throws:
IOException