java.io.Serializablepublic class ParsedOptions
extends java.lang.Object
implements java.io.Serializable
Options descriptor.
It allows querying of a boolean hasOption(String opt),
in addition to retrieving the getValue(String opt)
for options requiring arguments.
Additionally, any left-over or unrecognized arguments, are available for further processing.
| Modifier | Constructor | Description |
|---|---|---|
protected |
ParsedOptions() |
Creates a command line.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
addArg(java.lang.String arg) |
Add left-over unrecognized option/argument.
|
protected void |
addOption(Option opt) |
Add an option.
|
java.util.List<java.lang.String> |
getArgList() |
Retrieve any left-over non-recognized options and arguments.
|
java.lang.String[] |
getArgs() |
Retrieve any left-over non-recognized options and arguments.
|
Option[] |
getOptions() |
Returns an array of the processed
Options. |
<T> T |
getParsedValue(char opt) |
Return a version of this
Option converted to a particular type. |
<T> T |
getParsedValue(Option option) |
Return a version of this
Option converted to a particular type. |
<T> T |
getParsedValue(java.lang.String opt) |
Return a version of this
Option converted to a particular type. |
java.util.Properties |
getProperties(Option option) |
Retrieve the map of values associated to the option.
|
java.util.Properties |
getProperties(java.lang.String opt) |
Retrieve the map of values associated to the option.
|
java.lang.String |
getValue(char opt) |
Retrieve the first argument, if any, of this option.
|
java.lang.String |
getValue(char opt,
java.lang.String defaultValue) |
Retrieve the argument, if any, of an option.
|
java.lang.String |
getValue(Option option) |
Retrieve the first argument, if any, of this option.
|
java.lang.String |
getValue(Option option,
java.lang.String defaultValue) |
Retrieve the first argument, if any, of an option.
|
java.lang.String |
getValue(java.lang.String opt) |
Retrieve the first argument, if any, of this option.
|
java.lang.String |
getValue(java.lang.String opt,
java.lang.String defaultValue) |
Retrieve the first argument, if any, of an option.
|
java.lang.String[] |
getValues(char opt) |
Retrieves the array of values, if any, of an option.
|
java.lang.String[] |
getValues(Option option) |
Retrieves the array of values, if any, of an option.
|
java.lang.String[] |
getValues(java.lang.String opt) |
Retrieves the array of values, if any, of an option.
|
boolean |
hasArgs() |
Checks if non-recognized options or arguments exists.
|
boolean |
hasOption(char opt) |
Query to see if an option has been set.
|
boolean |
hasOption(Option opt) |
Query to see if an option has been set.
|
boolean |
hasOption(java.lang.String opt) |
Query to see if an option has been set.
|
boolean |
hasOptions() |
Checks if options exists.
|
java.util.Iterator<Option> |
iterator() |
Returns an iterator over the Option members of ParsedOptions.
|
public boolean hasOption(Option opt)
opt - the option to checkpublic boolean hasOption(java.lang.String opt)
opt - short name of the optionpublic boolean hasOption(char opt)
opt - character name of the optionpublic boolean hasOptions()
public <T> T getParsedValue(Option option) throws OptionParserException
Option converted to a particular type.T - the generic typeoption - the optionOptionParserException - if there are problems turning the option value into the desired typepublic <T> T getParsedValue(java.lang.String opt)
throws OptionParserException
Option converted to a particular type.T - the generic typeopt - the name of the optionOptionParserException - if there are problems turning the option value into the desired typepublic <T> T getParsedValue(char opt)
throws OptionParserException
Option converted to a particular type.T - the generic typeopt - the name of the optionOptionParserException - if there are problems turning the option value into the desired typepublic java.lang.String getValue(Option option)
option - the name of the optionnullpublic java.lang.String getValue(java.lang.String opt)
opt - the name of the optionnullpublic java.lang.String getValue(char opt)
opt - the character name of the optionnullpublic java.lang.String[] getValues(Option option)
option - string name of the optionnullpublic java.lang.String[] getValues(java.lang.String opt)
opt - string name of the optionnullpublic java.lang.String[] getValues(char opt)
opt - character name of the optionnullpublic java.lang.String getValue(Option option, java.lang.String defaultValue)
option - the name of the optiondefaultValue - the default value to be returned if the option
is not specifieddefaultValuepublic java.lang.String getValue(java.lang.String opt,
java.lang.String defaultValue)
opt - the name of the optiondefaultValue - the default value to be returned if the option
is not specifieddefaultValuepublic java.lang.String getValue(char opt,
java.lang.String defaultValue)
opt - character name of the optiondefaultValue - the default value to be returned if the option
is not specifieddefaultValuepublic java.util.Properties getProperties(Option option)
-Dparam1=value1
-Dparam2=value2. The first argument of the option is the key, and
the 2nd argument is the value. If the option has only one argument
(-Dfoo) it is considered as a boolean flag and the value is
"true".option - the option to be processednull
even if the option doesn't existspublic java.util.Properties getProperties(java.lang.String opt)
-Dparam1=value1
-Dparam2=value2. The first argument of the option is the key, and
the 2nd argument is the value. If the option has only one argument
(-Dfoo) it is considered as a boolean flag and the value is
"true".opt - the name of the optionnull
even if the option doesn't existsprotected void addOption(Option opt)
opt - the option to be processedpublic java.util.Iterator<Option> iterator()
Iterator over the processed Option
members of this ParsedOptionspublic Option[] getOptions()
Options.Optionspublic boolean hasArgs()
public java.lang.String[] getArgs()
public java.util.List<java.lang.String> getArgList()
Listprotected void addArg(java.lang.String arg)
arg - the unrecognized option/argumentCopyright © 2008–2018 The Aspectran Project. All rights reserved.