public class Argument
extends java.lang.Object
Constructor and Description |
---|
Argument(java.lang.String[] args)
Constructor with argument parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
addArgument(java.lang.String option,
java.lang.String description,
int paramCount)
Method to add arguments.
|
void |
addBooleanArgument(java.lang.String option,
java.lang.String description)
Method to add arguments.
|
void |
displayOptions()
Displays the usage or help options.
|
ArgumentRetriever |
getArgumentRetriever()
Method to retrieve values.
|
boolean |
isExceptionOccured()
Allows user to check if an exception occurred while parsing
the arguments
|
boolean |
isRethrowException()
Allows user to check if re-throwing of an exception is set.
|
boolean |
isShowStackTrace()
Checks if showing of stack traces is allowed by the user.
|
void |
processArguments()
Processes the arguments for later argument retrieval.
|
void |
setDelimiter(java.lang.String delim)
The delimiter being used to parse the options.
|
void |
setProgramDescription(java.lang.String pd)
Describes the calling class.
|
void |
setRethrowException(boolean rethrow)
Sets value to re-throw an exception.
|
void |
setShowOptions(boolean so)
Method that allows the user to allow options to be displayed if
an error occurs.
|
void |
setShowStackTrace(boolean show)
Allows stack trace to be shown when an exception occurs.
|
public Argument(java.lang.String[] args)
Constructor with argument parameters. The argument being passed is the
one passed in the main(String[] args)
args
- Main argumentspublic final void displayOptions()
Displays the usage or help options.
public final void processArguments() throws ArgumentException
Processes the arguments for later argument retrieval.
ArgumentException
- if an exception occurs and is
allowed to be re-thrownpublic final void addArgument(java.lang.String option, java.lang.String description, int paramCount)
Method to add arguments. Value being passed also is being
used by the displayOptions()
method.
option
- flag used in the argumentsdescription
- the description of the option providedparamCount
- parameter count to be used by the optionpublic final void addBooleanArgument(java.lang.String option, java.lang.String description)
Method to add arguments. Value being passed also is being
used by the displayOptions()
method.
option
- flag used in the argumentsdescription
- the description of the option providedpublic final void setDelimiter(java.lang.String delim)
The delimiter being used to parse the options. Default delimiter is "--" e.g --ls
delim
- the delimiter to be used by the optionpublic final void setShowOptions(boolean so)
Method that allows the user to allow options to be displayed if an error occurs.
so
- set option to true
if its to be shown
automatically if an exception occurs else false
public final void setProgramDescription(java.lang.String pd)
Describes the calling class.
pd
- description of the programpublic final boolean isShowStackTrace()
Checks if showing of stack traces is allowed by the user.
true
if a stack trace is allowed to
be shown otherwise false
public final void setShowStackTrace(boolean show)
Allows stack trace to be shown when an exception occurs.
show
- true
if stack trace should be shown
automatically else set to false
public final boolean isExceptionOccured()
Allows user to check if an exception occurred while parsing the arguments
true
if an exception occurred
otherwise false
public final boolean isRethrowException()
Allows user to check if re-throwing of an exception is set.
true
if exception is re-thrown
else false
public final void setRethrowException(boolean rethrow)
Sets value to re-throw an exception.
rethrow
- true
if the exception is to be re-thrown
to caller else set to false
public final ArgumentRetriever getArgumentRetriever()
Method to retrieve values.
ArgumentRetriever
object
that retrieves argument values