public class Options.Instance
extends java.lang.Object
Options
object contains all options found in
arguments on a command line. The choice of options is taken from the set of
options Options
presents. All constraints applied by
Options
and the Option
s it contains are used when
extracting options from command line argumentsModifier and Type | Method and Description |
---|---|
boolean |
containsOption(Option opt)
Tests to see if the specified option has an instance in this object
|
boolean |
containsOption(java.lang.String name)
Tests to see if the specified option has an instance in this object.
|
Option.Instance |
getOption(Option opt)
Returns the instance of the specified option that is stored in this
Options instance, or null if there is no
instance of the specified option here. |
Option.Instance |
getOption(java.lang.String name)
Returns the instance of the specified option that is stored in this
Options instance, or null if there is no
instance of the specified option here. |
java.util.LinkedList<java.lang.String> |
parse(java.util.LinkedList<java.lang.String> argQueue) |
java.util.LinkedList<java.lang.String> |
parse(java.lang.String[] arguments)
Parses a set of arguments, extracts options from them and stores them in
this instance.
|
void |
validate()
Makes sure all required options have instances in this
Options instance. |
public boolean containsOption(Option opt)
opt
- The option to check fortrue
if there is an instance of the specified option
in this object. false
otherwise.public boolean containsOption(java.lang.String name)
name
- The long or short name of the option to look fortrue
if there is an instance of the specified option
in this object. false
otherwise.public Option.Instance getOption(Option opt)
Options
instance, or null
if there is no
instance of the specified option here.opt
- The option to check foropt
, or null
if
opt
doesn't have an instance stored here.public Option.Instance getOption(java.lang.String name)
Options
instance, or null
if there is no
instance of the specified option here. The option may be specified by
long name or short namename
- The long or short name of the option to look foropt
, or null
if
opt
doesn't have an instance stored here.public java.util.LinkedList<java.lang.String> parse(java.lang.String[] arguments) throws java.lang.IllegalArgumentException
Parses a set of arguments, extracts options from them and stores them in this instance. All arguments that are not options are returned in the order they were discovered. Options are identified by the following properties:
Once an option is identified, it is processed in the following way:
Example 1: Below are options, a, b and c. a and c take arguments. b does not.
-abc arg1 arg2 arg3 arg4This produces the following result:
a = arg1
b (no value)
c = art2 remaining arguments = arg3 and arg4
Example 2: Below are options, P, assign-arg and flag. All take arguments except flag.
-Pprop=value --assign-arg=val arg1 --flag arg 2This produces the following result:
P = prop=value
assign-arg = val
flag (no value)
remaining arguments = arg1 and arg2
arguments
- The arguments to parse and extract options and values fromjava.lang.IllegalArgumentException
public java.util.LinkedList<java.lang.String> parse(java.util.LinkedList<java.lang.String> argQueue)
public void validate() throws java.lang.IllegalStateException
Options
instance.java.lang.IllegalStateException
- If a required option does not have an instance in this
Options
instance.