|
Qizx/Open v0.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.xfra.qizxopen.util.CLOptions
Command line option analyzer.
Nested Class Summary | |
static class |
CLOptions.Exception
|
Field Summary | |
static int |
ALL_ARG
Gets all following arguments to a String array field. |
static int |
HELP_ARG
Prints help. |
static int |
NEXT_ARG
Gets the following argument to a String field. |
static int |
RESET_ARG
Resets a boolean field (no argument). |
static int |
SET_ARG
Sets a boolean field (no argument). |
static int |
STICKY_ARG
Gets the end of the argument to a String field. |
Constructor Summary | |
CLOptions(java.lang.String appName)
Creation with an application name. |
Method Summary | |
void |
argument(java.lang.String key,
java.lang.String field,
int cardinality,
java.lang.String help)
Declares an argument (aka Anonymous Option). |
void |
declare(java.lang.String key,
int type,
java.lang.String help)
|
void |
declare(java.lang.String key,
java.lang.String field,
int type,
java.lang.String help)
Declares an option. |
void |
parse(java.lang.String[] args,
java.lang.Object storage)
Parses the command line. |
void |
printHelp(java.io.PrintStream out)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NEXT_ARG
public static final int STICKY_ARG
public static final int SET_ARG
public static final int RESET_ARG
public static final int ALL_ARG
public static final int HELP_ARG
Constructor Detail |
public CLOptions(java.lang.String appName)
Options must then be defined by declare().
appName
- name of the applicationMethod Detail |
public void declare(java.lang.String key, java.lang.String field, int type, java.lang.String help)
key
- appearance of the option switch. A null key means an anonymous argument.
an anonymous argument may be repeatable if the type is ALL_ARG.field
- name of a Java field of the 'storage' argument of next():
receives the value. Its type is used for automatic conversion.
A field ALL_ARG must be of type String[].type
- values: NEXT_ARG, SET_ARG, RESET_ARG, ALL_ARG, HELP_ARG.help
- option help description.public void declare(java.lang.String key, int type, java.lang.String help)
public void argument(java.lang.String key, java.lang.String field, int cardinality, java.lang.String help)
cardinality
- A value of 1 means that the argument must be present once,
0 that the argument is optional, 2 or more that the argument may be repeated
(in that case, each call to next will get the next value).
Only the last argument may be optional or repeated.public void parse(java.lang.String[] args, java.lang.Object storage) throws CLOptions.Exception
The values of options are stored into the (public) fields of 'storage' that have the name specified in declare().
Checks
CLOptions.Exception
public void printHelp(java.io.PrintStream out)
|
Copyright Xavier FRANC 2003-2004 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |