public class Arguments extends Object
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");
| Modifier and Type | Class and Description |
|---|---|
static class |
Arguments.Arg |
static class |
Arguments.MissingArgumentError |
static class |
Arguments.Opt
Optional arguments.
|
static class |
Arguments.Req
Required arguments.
|
| Constructor and Description |
|---|
Arguments()
Create a new CommandLine object with no arguments.
|
Arguments(String[] args)
Create a new CommandLine object with an initial argument array.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addArgument(String str,
String next)
Add a new argument to this command line.
|
<TArg extends Arguments.Arg> |
extract(TArg arg) |
String |
get(int i) |
String |
getValue(String name)
Return the value of a binding (e.g.
|
int |
size()
Returns the number of remaining command line arguments.
|
String |
toString() |
String[] |
toStringArray() |
public Arguments(String[] args)
args - array of options and argument that will be parsed.public Arguments()
public int size()
public String get(int i)
public int addArgument(String str, String next)
str - a stringpublic <TArg extends Arguments.Arg> TArg extract(TArg arg) throws Arguments.MissingArgumentError
Arguments.MissingArgumentErrorpublic String getValue(String name)
name - string name of the option or bindingpublic String[] toStringArray()
Copyright © 2013–2014 0xdata. All rights reserved.