|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwater.Arguments
public class Arguments
Utility for processing command Simple command line processing. This class provides functionality for parsing command line arguments that is coded over and over again in main methods. The model is that command line arguments have the form:
option_args* free_form*where each element in option_args is an option starting with a '-' character and each element in free_form is a string. Option arguments have the syntax:
'-'NAME[=VALUE]where NAME is the option identifier and VALUE is the string argument for that option.
An example use of the class is as follows:
static void main(String[] args) { Arguments cl = new Arguments(); cl.parse(args); if (cl.getOption("verbose") != null) ... ; String file = cl.getArgument(0); String path = cl.getOption("classpath");
Nested Class Summary | |
---|---|
static class |
Arguments.Arg
|
static class |
Arguments.MissingArgumentError
|
static class |
Arguments.Opt
Optional arguments. |
static class |
Arguments.Req
Required arguments. |
Constructor Summary | |
---|---|
Arguments()
Create a new CommandLine object with no arguments. |
|
Arguments(java.lang.String[] args)
Create a new CommandLine object with an initial argument array. |
Method Summary | |
---|---|
int |
addArgument(java.lang.String str,
java.lang.String next)
Add a new argument to this command line. |
void |
extract(Arguments.Arg arg)
|
int |
firstFlag()
Index of first flag, or -1 if command line contains only options. |
java.lang.String |
get(int i)
|
java.lang.String |
getValue(java.lang.String name)
Return the value of a binding (e.g. |
int |
size()
Returns the number of remaining command line arguments. |
java.lang.String |
toString()
|
java.lang.String[] |
toStringArray()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Arguments(java.lang.String[] args)
args
- array of options and argument that will be parsed.public Arguments()
Method Detail |
---|
public int size()
public int firstFlag()
public java.lang.String get(int i)
public int addArgument(java.lang.String str, java.lang.String next)
str
- a stringpublic void extract(Arguments.Arg arg) throws Arguments.MissingArgumentError
Arguments.MissingArgumentError
public java.lang.String getValue(java.lang.String name)
name
- string name of the option or binding
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String[] toStringArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |