package org.mcraig.cs445.refentry;
/**
* Generate RefEntry servlet serialized object files.
* @author <a href="mailto:mark@mcraig.org">Mark Craig</a>
*/
class Build {
/** Filename of the sources Properties file. */
private static String SrcProps;
/** Filename of XSLT Properties file. */
private static String XSLTProps;
/** Filename of the common words Properties file. */
private static String CWProps;
/** Filename of the serialized common words object file. */
private static String CWFile;
/** Filename of the serialized RefEntryBackEnd object file. */
private static String BEFile;
/** USAGE message. */
private final static String usage =
"Usage:\n" +
"\tbuild -src <PropertiesFile> -xsl <PropertiesFile>\n" +
"\t -cw <PropertiesFile> -cwOut <File> -beOut <File>\n" +
"\tWhere <PropertiesFile> options are source (src), XSLT\n" +
"\tstylesheets (xsl), and common words (cw) Java properties\n" +
"\tfiles; the cwOut <File> is the name of the serialized\n" +
"\tobject file containing common words; the beOut <File>\n" +
"\tis the name of the serialized RefEntryBackEnd object file.";
/** Print a usage message to System.err and exit. */
private static void usage() {
System.err.println(usage);
System.exit(1);
}
/**
* Build a RefEntry servlet.
* @param args Arguments expected as per the Usage message.
*/
public static void main(String[] args) {
handleInput(args);
Serializer s = new Serializer();
s.build(SrcProps, XSLTProps, CWProps, CWFile, BEFile);
}
/** Handle command line input. */
static void handleInput(String[] args) {
if (args.length != 10) usage();
if (args[0].equals("-src")) SrcProps = args[1];
else {
System.err.println(args[0] + " not recognized.");
usage();
}
if (args[2].equals("-xsl")) XSLTProps = args[3];
else {
System.err.println(args[2] + " not recognized.");
usage();
}
if (args[4].equals("-cw")) CWProps = args[5];
else {
System.err.println(args[4] + " not recognized.");
usage();
}
if (args[6].equals("-cwOut")) CWFile = args[7];
else {
System.err.println(args[6] + " not recognized.");
usage();
}
if (args[8].equals("-beOut")) BEFile = args[9];
else {
System.err.println(args[8] + " not recognized.");
usage();
}
}
} |