Package com.portal.common
Class LoaderOptions
java.lang.Object
com.portal.common.CommandLineParser
com.portal.common.Options
com.portal.common.LoaderOptions
This class derives from the Options class to implement a command line
syntax and set of options that apply to all of the "pin loader"
programs. The syntax is: optional flag options followed by the
name of the configuration file to load into Portal.
[-option] ... file_name
The options defined by this class are:
-v | If this option is present then the command line program will display comprehensive feedback as it executes. |
-d | If this flag is present then comprehensive debug information will be logged to the appropriate log file. |
Some examples (that include the program to run):
load_device_map -d device_service_map
load_business_params -d -v business_params
If you have additional options that are unique to your program then you will need to extend this class to support those options. The bulk of the extension can be achieved by adding option definitions for your new options in the constructor of your derived class. See the Options class for an example on how to do this.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.portal.common.Options
Options.DateOptionDef, Options.DecimalOptionDef, Options.FlagOptionDef, Options.IntOptionDef, Options.OptionDef, Options.StringOptionDef
Nested classes/interfaces inherited from class com.portal.common.CommandLineParser
CommandLineParser.InvalidOptionsException, CommandLineParser.NoSuchOptionException, CommandLineParser.OptionDataException, CommandLineParser.OptionException, CommandLineParser.ValueOutOfBoundsException
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The debug option.static final String
The verbose option.Fields inherited from class com.portal.common.CommandLineParser
ALL
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LoaderOptions
(String[] args) You cannot all this constructor directly because you must derive from this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic LoaderOptions
createLoaderOptions
(String[] args) Factory method used to create a LoaderOptions.static LoaderOptions
Factory method used to create a LoaderOptions.Convienence method to return the name of the file to load configuration information into Portal.protected String
Get the help string that describes the syntax required by your options class.boolean
isDebug()
Convienence method to return the state of the debug option.boolean
Convienence method to return the state of the verbose option.protected void
This method is called by theCommandLineParser.parse
method after it has successfully parsed the command line.Methods inherited from class com.portal.common.Options
addOptionDef, getBigDecimal, getBoolean, getDate, getHelp, getInteger, getOptionDef, getOptValues, getString, getStrings, isHelp, storeAllTokensAsLeadingTokens, toString, validateLeadingTokens, validateOption, validateRequiredParameters, validateTrailingTokens
Methods inherited from class com.portal.common.CommandLineParser
constructErrMsg, constructErrMsg, containsOption, createParser, getArgs, getLeadingToken, getLeadingTokens, getNumLeadingTokens, getNumOptions, getNumTrailingTokens, getNumValues, getStrFromBundle, getStrFromBundle, getTrailingToken, getTrailingTokens, getValue, getValues, getValues, parse, strArrayToString
-
Field Details
-
VERBOSE
The verbose option. If this option is present on the command line then the program will display comprehensive progress feedback.- See Also:
-
DEBUG
The debug option. If this option is present on the command line then the program will display comprehensive diagnostic information.- See Also:
-
-
Constructor Details
-
LoaderOptions
You cannot all this constructor directly because you must derive from this class. In the constructor of your derived class you must call theCommandLineParse.parse
method after your constructor has finished all initialization. This is because theCommandLineParser.parse
method calls the methods overriden in the Options class which depend on the option definitions defined in the constructor of your derived class. All constructor initialization must be complete for theCommandLineParser.parse
method to work correctly.- Parameters:
args
- The array of command line arguments passed to the program.- Throws:
CommandLineParser.InvalidOptionsException
- An error was encountered when parsing the command line arguments. See theOptions
constructor for details on the possible various errors encountered.
-
-
Method Details
-
createLoaderOptions
public static LoaderOptions createLoaderOptions(String[] args) throws CommandLineParser.InvalidOptionsException Factory method used to create a LoaderOptions. Call this method to construct a LoaderOptions.- Parameters:
args
- The array of command line arguments passed to the program.- Returns:
- An instance of a LoaderOptions.
- Throws:
CommandLineParser.InvalidOptionsException
- An error was encountered when parsing the command line arguments. See theOptions
constructor for details on the possible various errors encountered.
-
createLoaderOptionsAndExitOnErrorOrHelp
Factory method used to create a LoaderOptions. Call this method to construct a LoaderOptions and exit if an error is encountered in the options or if a request has been made to display help (display then help and then exit).- Parameters:
args
- The array of command line arguments passed to the program.- Returns:
- An instance of a LoaderOptions.
-
isDebug
public boolean isDebug()Convienence method to return the state of the debug option. You could acheive the same result by callingcontainsOption(mDebug)
.- Returns:
- true if your program needs to log comprehensive debug information while it executes, otherwise return false.
-
isVerbose
public boolean isVerbose()Convienence method to return the state of the verbose option. You could acheive the same result by callingcontainsOption(mVerbose)
.- Returns:
- true if your program needs to display comprehensive feedback while it executes, otherwise return false.
-
getFileName
Convienence method to return the name of the file to load configuration information into Portal.- Returns:
- the name of the file to load into Portal.
-
getSyntaxHelp
Get the help string that describes the syntax required by your options class.- Specified by:
getSyntaxHelp
in classOptions
- Returns:
- The appropriate help string.
-
postParse
This method is called by theCommandLineParser.parse
method after it has successfully parsed the command line. Typically, this is the place where you extract option values into local member variables.- Overrides:
postParse
in classCommandLineParser
- Throws:
CommandLineParser.InvalidOptionsException
- An error was detected when extracting option values into local member variables.
-