org.pz.platypus
Class Platypus

java.lang.Object
  extended by org.pz.platypus.Platypus

public class Platypus
extends java.lang.Object

The main line.

Author:
alb

Field Summary
private static Literals lits
           
 
Constructor Summary
Platypus()
           
 
Method Summary
private static void addInputFileToFileList(CommandLineArgs clArgs, GDD gdd)
          add the input file to the file list
private static void displayCopyright()
          output the copyright notice to console
static void findOutputFilePluginType(CommandLineArgs ClArgs, GDD Gdd)
          tries to determine the prefix in the config file for the output plugin.
private static java.lang.String findPluginJar(java.lang.String pluginJarLookupName, GDD gdd)
          Get the actual name of the plugin, based on its lookup value in config file.
private static java.lang.String getConfigFilename(CommandLineArgs ClArgs, GDD Gdd)
          Get the name of the config file either from the command file or from the default location
private static java.lang.String loadOutputPlugin(GDD gdd, CommandLineArgs clArgs)
          Gets the full canonical name of the plugin (full path + file name).
private static void logUnexpectedError(java.lang.Exception ex, GDD gdd)
          Prints out the error message in the event of an unexpected error.
static void main(java.lang.String[] args)
          Where the rubber meets the road...
static CommandLineArgs processCommandLine(java.lang.String[] args, GDD gdd)
          Process the command line: store it, validate it, and process the args.
static void processConfigFile(CommandLineArgs Clargs, GDD Gdd)
          Finds the config file, reads it in, and places an instance of it in GDD.
static void processInputFile(GDD gdd, CommandLineArgs clArgs)
          Reads and parses the input file(s).
static void putFormatInSystemStrings(CommandLineArgs clArgs, GDD gdd)
          Places the output format into the SystemStrings lookup table
private static void runOutputPlugin(java.lang.String pluginName, GDD gdd, CommandLineArgs clArgs)
          The method that actually calls and runs the output plugin
private static GDD setupGdd(Literals lits)
          GDD is the global document data block.
static void setupLiterals(java.lang.String baseFilename)
          Load the default literals file, which is a property file.
static void showUsage(GDD Gdd)
          Show the usage options.
static void storeVersionNumber(GDD Gdd)
          Stores the current Platypus version number in the table of system strings under _version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lits

private static Literals lits
Constructor Detail

Platypus

public Platypus()
Method Detail

addInputFileToFileList

private static void addInputFileToFileList(CommandLineArgs clArgs,
                                           GDD gdd)
add the input file to the file list

Parameters:
clArgs - command line containing the name of the input file
gdd - GDD containing the FileLits for this program

displayCopyright

private static void displayCopyright()
output the copyright notice to console


findOutputFilePluginType

public static void findOutputFilePluginType(CommandLineArgs ClArgs,
                                            GDD Gdd)
tries to determine the prefix in the config file for the output plugin. (such as: pdf) First checks the -format option on the command line. If it's not specified there, checks the extension of the output file. Prefix is the lower-case version of the string, and it is stored in the Gdd.

Parameters:
ClArgs - the command line args
Gdd - the GDD
Throws:
java.util.MissingResourceException - if the output file format cannot be determined.

findPluginJar

private static java.lang.String findPluginJar(java.lang.String pluginJarLookupName,
                                              GDD gdd)
Get the actual name of the plugin, based on its lookup value in config file. Check whether the plug-in is in the default PLATYPUS_HOME\plugins directory. if not, check whether the configuration file gives the plug-ins location.

Parameters:
pluginJarLookupName - name of the plugin file (a JAR file) in the PLATYPUS_HOME\plugins
gdd - the GDD
Returns:
the jar file name

loadOutputPlugin

private static java.lang.String loadOutputPlugin(GDD gdd,
                                                 CommandLineArgs clArgs)
                                          throws java.util.MissingResourceException
Gets the full canonical name of the plugin (full path + file name). By getting the PLATYPUS_HOME directory, tacking on the \plugins subdir, then adding the output format.jar;

Parameters:
gdd - the GDD
clArgs - the command line args
Returns:
plugin location
Throws:
java.util.MissingResourceException - in event the PLATYPUS_HOME directory has not been defined.

runOutputPlugin

private static void runOutputPlugin(java.lang.String pluginName,
                                    GDD gdd,
                                    CommandLineArgs clArgs)
The method that actually calls and runs the output plugin

Parameters:
pluginName - name of the plugin file
gdd - the GDD
clArgs - command-line args

logUnexpectedError

private static void logUnexpectedError(java.lang.Exception ex,
                                       GDD gdd)
Prints out the error message in the event of an unexpected error. Called only from the Platypus.main() and serves as the backup exception handler if some exception is not handled elsewhere.

Parameters:
ex - the exception
gdd - the GDD

processCommandLine

public static CommandLineArgs processCommandLine(java.lang.String[] args,
                                                 GDD gdd)
                                          throws HelpMessagePrinted,
                                                 org.apache.commons.cli.ParseException
Process the command line: store it, validate it, and process the args.

Parameters:
args - the command-line args
gdd - the GDD
Returns:
the CommandLineArgs structure that is filled in by this method
Throws:
HelpMessagePrinted - if the user specified -help on the command line. In this case, no further processing is needed (after the help message has been displayed).
org.apache.commons.cli.ParseException - it the CLI args handling fails in CommandLineArgs

putFormatInSystemStrings

public static void putFormatInSystemStrings(CommandLineArgs clArgs,
                                            GDD gdd)
Places the output format into the SystemStrings lookup table

Parameters:
clArgs - command-line args
gdd - the GDD

processConfigFile

public static void processConfigFile(CommandLineArgs Clargs,
                                     GDD Gdd)
                              throws java.util.MissingResourceException
Finds the config file, reads it in, and places an instance of it in GDD. If the file can't be found, this method throws MissingResourceException, which is caught in the main line. At that point, Platypus is shut down (the error message having already been written to stderr).

Parameters:
Clargs - the command line args
Gdd - the GDD
Throws:
java.util.MissingResourceException - in the event the config file cannot be loaded

getConfigFilename

private static java.lang.String getConfigFilename(CommandLineArgs ClArgs,
                                                  GDD Gdd)
Get the name of the config file either from the command file or from the default location

Parameters:
Gdd - the GDD
ClArgs - object containing the command-line args
Returns:
string containing the name of the config file.

processInputFile

public static void processInputFile(GDD gdd,
                                    CommandLineArgs clArgs)
                             throws java.lang.NoSuchFieldException
Reads and parses the input file(s).

Parameters:
gdd - the GDD
clArgs - the command-line arguments
Throws:
java.lang.NoSuchFieldException - if no input file is specified, or it's invalid.

setupGdd

private static GDD setupGdd(Literals lits)
GDD is the global document data block. It holds data items frequently used in processing Platypus files. Note the setup steps here need to be sequenced this way, as each depends on steps taken by the previous step(s).

Parameters:
lits - the Literals
Returns:
GDD the new gdd

setupLiterals

public static void setupLiterals(java.lang.String baseFilename)
                          throws java.util.MissingResourceException
Load the default literals file, which is a property file.

Parameters:
baseFilename - base of the Literals filename. ".properties" extension will be appended
Throws:
java.util.MissingResourceException - if an error occurs while file is read and loaded.

showUsage

public static void showUsage(GDD Gdd)
Show the usage options. Generally displayed after -help or in the event of command-line option errors.

Parameters:
Gdd - GDD containing the Literals

storeVersionNumber

public static void storeVersionNumber(GDD Gdd)
Stores the current Platypus version number in the table of system strings under _version

Parameters:
Gdd - global document data structure

main

public static void main(java.lang.String[] args)
                 throws org.apache.commons.cli.ParseException
Where the rubber meets the road...

Parameters:
args - command-line args
Throws:
org.apache.commons.cli.ParseException


Copyright © 2008-10 Pacific Data Works LLC