|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.ArgumentParser
public class ArgumentParser
Provide a cleaner way of handling arguments to public static void main (String args[]).
Field Summary | |
---|---|
static java.lang.String |
BooleanDefault
|
static java.lang.String[] |
globalArgs
Cache of VM command line arguments aribaapi ariba because the util unit test uses it. |
static boolean |
globalIgnoreCase
Indicates if we should ignore the case of the comand line arguments aribaapi ariba because unit test uses it. |
static boolean |
IgnoreCaseDefault
|
static java.lang.String |
NoPrefix
|
static java.lang.Object |
Null
Constant for lame Map and vector classes. |
static java.lang.String |
OptionalClose
|
static java.lang.String |
OptionalOpen
|
static java.lang.String |
RequiredClose
|
static java.lang.String |
RequiredOpen
|
static java.lang.String |
SwitchPrefix
|
static int |
TypeBoolean
|
static int |
TypeDouble
|
static int |
TypeFile
|
static int |
TypeInteger
|
static int |
TypeIntegerList
|
static int |
TypeString
|
static int |
TypeURL
|
static java.lang.String |
ValidChoices
|
Constructor Summary | |
---|---|
ArgumentParser(java.lang.String usage,
java.lang.String[] args)
Constructor takes the args to parse and user supplied usage string |
|
ArgumentParser(java.lang.String usage,
java.lang.String[] args,
boolean ignoreCase)
Constructor takes the args to parse and user supplied usage string |
|
ArgumentParser(java.lang.String usage,
java.lang.String[] args,
boolean ignoreCase,
boolean exitUponParsingError)
Constructor takes the args to parse and user supplied usage string |
Method Summary | |
---|---|
void |
addOptionalBoolean(java.lang.String name,
boolean defaultValue)
Add an optional boolean argument |
void |
addOptionalBoolean(java.lang.String name,
boolean defaultValue,
java.lang.String usage)
Add an optional boolean argument |
void |
addOptionalDouble(java.lang.String name,
double defaultValue,
java.lang.String usage)
Add an optional double argument |
void |
addOptionalFile(java.lang.String name,
java.io.File defaultValue,
java.lang.String usage)
Add an optional file argument |
void |
addOptionalInteger(java.lang.String name,
int defaultValue,
java.lang.String usage)
Add an optional integer argument |
void |
addOptionalIntegerList(java.lang.String name,
java.util.List defaultValue,
java.lang.String usage)
Add an optional integer range argument |
void |
addOptionalString(java.lang.String name,
java.lang.String defaultValue,
java.lang.String usage)
Add an optional string argument |
void |
addOptionalURL(java.lang.String name,
java.net.URL defaultValue,
java.lang.String usage)
Add an optional url argument |
void |
addRequiredBoolean(java.lang.String name)
Add a required boolean argument |
void |
addRequiredBoolean(java.lang.String name,
java.lang.String usage)
Add a required boolean argument |
void |
addRequiredDouble(java.lang.String name,
java.lang.String usage)
Add a required double argument |
void |
addRequiredFile(java.lang.String name,
java.lang.String usage)
Add a required file argument |
void |
addRequiredInteger(java.lang.String name,
java.lang.String usage)
Add a required integer argument |
void |
addRequiredIntegerList(java.lang.String name,
java.lang.String usage)
Add a required integer range argument |
void |
addRequiredString(java.lang.String name,
java.lang.String usage)
Add a required string argument |
void |
addRequiredURL(java.lang.String name,
java.lang.String usage)
Add a required url argument |
java.lang.String[] |
args()
Return the arguments for purposes such as printing |
static void |
create(java.lang.String className,
java.lang.String[] args)
Create an instance of the command line client. |
static void |
create(java.lang.String className,
java.lang.String[] args,
boolean ignoreCase)
Convenience method for creating a command line client without the optional context. |
static void |
create(java.lang.String className,
java.lang.String[] args,
boolean ignoreCase,
java.lang.Object context)
Create a command line client. |
static void |
create(java.lang.String className,
java.lang.String[] args,
java.lang.Object context)
|
boolean |
getBoolean(java.lang.String name)
retrieve the value of a boolean argument |
double |
getDouble(java.lang.String name)
retrieve the value of a double argument |
java.io.File |
getFile(java.lang.String name)
retrieve the value of a file argument |
static java.lang.String |
getHackedParameter(java.lang.String name)
This is needed to get the nodename from the command line before the log is created and before most of the rest of the setup is done. |
int |
getInteger(java.lang.String name)
retrieve the value of a integer argument |
java.util.List |
getIntegerList(java.lang.String name)
retrieve the value of a integer range argument |
java.util.List |
getListOf(java.lang.String name)
Returns a vector of values for the argument name specified. |
java.lang.String |
getString(java.lang.String name)
retrieve the value of a string argument |
java.net.URL |
getURL(java.lang.String name)
retrieve the value of a url argument |
java.lang.String |
image()
Print the argument list |
static java.lang.String |
negate(java.lang.String name)
given foo returns noFoo |
static CommandLine |
newInstance(java.lang.String className,
java.lang.String[] args)
The first part of create : creates a new instance of the
specified comand line client class. |
static CommandLine |
newInstance(java.lang.String className,
java.lang.String[] args,
boolean ignoreCase)
The first part of create : creates a new instance of the
specified comand line client class. |
static void |
startup(CommandLine client)
The second part of create, starting an existing instance. |
void |
usage()
Print a usage statement and exit |
void |
usage(java.lang.String error)
Print a usage statement and exit |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String[] globalArgs
public static boolean IgnoreCaseDefault
public static boolean globalIgnoreCase
public static final int TypeString
public static final int TypeBoolean
public static final int TypeInteger
public static final int TypeDouble
public static final int TypeFile
public static final int TypeURL
public static final int TypeIntegerList
public static final java.lang.String RequiredOpen
public static final java.lang.String RequiredClose
public static final java.lang.String OptionalOpen
public static final java.lang.String OptionalClose
public static final java.lang.String BooleanDefault
public static final java.lang.String ValidChoices
public static final java.lang.String SwitchPrefix
public static final java.lang.String NoPrefix
public static final java.lang.Object Null
Constructor Detail |
---|
public ArgumentParser(java.lang.String usage, java.lang.String[] args)
usage
- specifies command line option usageargs
- the command line argumentspublic ArgumentParser(java.lang.String usage, java.lang.String[] args, boolean ignoreCase)
usage
- specifies command line option usageargs
- the command line argumentsignoreCase
- when true flags of differing case compare equalpublic ArgumentParser(java.lang.String usage, java.lang.String[] args, boolean ignoreCase, boolean exitUponParsingError)
usage
- specifies command line option usageargs
- the command line argumentsignoreCase
- when true flags of differing case compare equalexitUponParsingError
- when false parsing error will be reported
by an IllegalArgumentException while when true the VM will exitMethod Detail |
---|
public static void create(java.lang.String className, java.lang.String[] args)
setupArgument
to let the client set up its commmand
line arguments;
(2) processArguments
to let the client process and parse
its arguments;
(3) startup
to run the client.
className
- the command line client classargs
- the command line arguments of the class, must be non nullCommandLine
public static CommandLine newInstance(java.lang.String className, java.lang.String[] args)
create
: creates a new instance of the
specified comand line client class. Sometimes we need to create it without
starting it right away.
className
- the class name of the command line clientargs
- its associated command line arguments, must be non-null.public static void create(java.lang.String className, java.lang.String[] args, boolean ignoreCase, java.lang.Object context)
setupArgument
to let the client set up its commmand
line arguments;
(2) processArguments
to let the client process and parse
its arguments;
(3) startup
to run the client.
className
- the command line client classargs
- the command line arguments of the class. Must be non null.ignoreCase
- when true flags of differing case compare equalcontext
- information to be passed to the command, in addition to
the args.CommandLine
public static void create(java.lang.String className, java.lang.String[] args, boolean ignoreCase)
className
- the command line client classargs
- the command line arguments of the class. Must be non null.ignoreCase
- when true flags of differing case compare equal.public static void create(java.lang.String className, java.lang.String[] args, java.lang.Object context)
public static CommandLine newInstance(java.lang.String className, java.lang.String[] args, boolean ignoreCase)
create
: creates a new instance of the
specified comand line client class. Sometimes we need to create it without
starting it right away.
className
- the class name of the command line clientargs
- its associated command line arguments, must be non-null.ignoreCase
- when true flags of differing case compare equalpublic static void startup(CommandLine client)
client
- the command line client to start executing.
must be non null.
aribaapi ariba because unit test uses it.public java.lang.String[] args()
public void addRequiredString(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalString(java.lang.String name, java.lang.String defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentdefaultValue
- the default value to use if the
option does not appear in the command linepublic void addRequiredInteger(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalInteger(java.lang.String name, int defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentdefaultValue
- the default value to use if the
option does not appear in the command linepublic void addRequiredDouble(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalDouble(java.lang.String name, double defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentdefaultValue
- the default value to use if the
option does not appear in the command linepublic void addRequiredBoolean(java.lang.String name)
name
- name of the command line optionpublic void addRequiredBoolean(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalBoolean(java.lang.String name, boolean defaultValue)
name
- name of the command line optiondefaultValue
- the default value to use if the
option does not appear in the command linepublic void addOptionalBoolean(java.lang.String name, boolean defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argument, if null
, the usage will not be displayed.defaultValue
- the default value to use if the
option does not appear in the command linepublic void addRequiredFile(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalFile(java.lang.String name, java.io.File defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentdefaultValue
- the default value to use if the
option does not appear in the command linepublic void addRequiredURL(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalURL(java.lang.String name, java.net.URL defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentdefaultValue
- the default value to use if the
option does not appear in the command linepublic void addRequiredIntegerList(java.lang.String name, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentpublic void addOptionalIntegerList(java.lang.String name, java.util.List defaultValue, java.lang.String usage)
name
- name of the command line optionusage
- usage of this argumentdefaultValue
- the default value to use if the
option does not appear in the command linepublic java.util.List getListOf(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public java.lang.String getString(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public boolean getBoolean(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public int getInteger(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public double getDouble(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public java.io.File getFile(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public java.net.URL getURL(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public java.util.List getIntegerList(java.lang.String name)
name
- the name of the parameter whose value is to be returned
public void usage(java.lang.String error)
error
- the usage stringpublic void usage()
public java.lang.String image()
public static java.lang.String negate(java.lang.String name)
name
- String to negate
public static java.lang.String getHackedParameter(java.lang.String name)
name
- the name of the parameter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |