Class ParsedOptions
java.lang.Object
com.aspectran.shell.command.option.ParsedOptions
- All Implemented Interfaces:
Serializable
Represents list of arguments parsed against a
Options
descriptor.
It allows querying of a boolean hasOption(String name)
,
in addition to retrieving the getValue(String name)
for options requiring arguments.
Additionally, any left-over or unrecognized arguments, are available for further processing.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add left-over unrecognized option/argument.protected void
Add an option.Retrieve any left-over non-recognized options and arguments.String[]
getArgs()
Retrieve any left-over non-recognized options and arguments.Option[]
Returns an array of the processedOption
s.getProperties
(Option option) Retrieve the map of values associated to the option.getProperties
(String name) Retrieve the map of values associated to the option.<T> T
getTypedValue
(char name) Return a version of thisOption
converted to a particular type.<T> T
getTypedValue
(Option option) Return a version of thisOption
converted to a particular type.<T> T
getTypedValue
(String name) Return a version of thisOption
converted to a particular type.getValue
(char name) Retrieve the first argument, if any, of this option.Retrieve the argument, if any, of an option.Retrieve the first argument, if any, of this option.Retrieve the first argument, if any, of an option.Retrieve the first argument, if any, of this option.Retrieve the first argument, if any, of an option.String[]
getValues
(char opt) Retrieves the array of values, if any, of an option.String[]
Retrieves the array of values, if any, of an option.String[]
Retrieves the array of values, if any, of an option.boolean
hasArgs()
Checks if non-recognized options or arguments exists.boolean
hasOption
(char name) Query to see if an option has been set.boolean
Query to see if an option has been set.boolean
Query to see if an option has been set.boolean
Checks if options exists.iterator()
Returns an iterator over the Option members of ParsedOptions.resolveOption
(String name) Retrieves the option object given the long or short option as a String.
-
Constructor Details
-
ParsedOptions
protected ParsedOptions()
-
-
Method Details
-
hasOption
Query to see if an option has been set.- Parameters:
opt
- the option to check- Returns:
- true if set, false if not
-
hasOption
Query to see if an option has been set.- Parameters:
name
- short name of the option- Returns:
- true if set, false if not
-
hasOption
public boolean hasOption(char name) Query to see if an option has been set.- Parameters:
name
- character name of the option- Returns:
- true if set, false if not
-
hasOptions
public boolean hasOptions()Checks if options exists.- Returns:
- true if options exists; false otherwise
-
getTypedValue
Return a version of thisOption
converted to a particular type.- Type Parameters:
T
- type to attempt to convert to- Parameters:
option
- the option- Returns:
- the value parsed into a particular object
- Throws:
OptionParserException
- if there are problems turning the option value into the desired type
-
getTypedValue
Return a version of thisOption
converted to a particular type.- Type Parameters:
T
- type to attempt to convert to- Parameters:
name
- the name of the option- Returns:
- the value parsed into a particular object
- Throws:
OptionParserException
- if there are problems turning the option value into the desired type
-
getTypedValue
Return a version of thisOption
converted to a particular type.- Type Parameters:
T
- type to attempt to convert to- Parameters:
name
- the name of the option- Returns:
- the value parsed into a particular object
- Throws:
OptionParserException
- if there are problems turning the option value into the desired type
-
getValue
Retrieve the first argument, if any, of this option.- Parameters:
option
- the name of the option- Returns:
- the value of the argument if option is set, and has an argument,
otherwise
null
-
getValue
Retrieve the first argument, if any, of this option.- Parameters:
name
- the name of the option- Returns:
- the value of the argument if option is set, and has an argument,
otherwise
null
-
getValue
Retrieve the first argument, if any, of this option.- Parameters:
name
- the character name of the option- Returns:
- the value of the argument if option is set, and has an argument,
otherwise
null
-
getValues
Retrieves the array of values, if any, of an option.- Parameters:
option
- string name of the option- Returns:
- the values of the argument if option is set, and has an argument,
otherwise
null
-
getValues
Retrieves the array of values, if any, of an option.- Parameters:
name
- string name of the option- Returns:
- the values of the argument if option is set, and has an argument,
otherwise
null
-
getValues
Retrieves the array of values, if any, of an option.- Parameters:
opt
- character name of the option- Returns:
- Values of the argument if option is set, and has an argument,
otherwise
null
-
getValue
Retrieve the first argument, if any, of an option.- Parameters:
option
- the name of the optiondefaultValue
- the default value to be returned if the option is not specified- Returns:
- the value of the argument if option is set, and has an argument,
otherwise
defaultValue
-
getValue
Retrieve the first argument, if any, of an option.- Parameters:
name
- the name of the optiondefaultValue
- the default value to be returned if the option is not specified- Returns:
- the value of the argument if option is set, and has an argument,
otherwise
defaultValue
-
getValue
Retrieve the argument, if any, of an option.- Parameters:
name
- character name of the optiondefaultValue
- the default value to be returned if the option is not specified- Returns:
- the value of the argument if option is set, and has an argument,
otherwise
defaultValue
-
resolveOption
Retrieves the option object given the long or short option as a String.- Parameters:
name
- the short or long name of the option- Returns:
- the canonicalized option
-
getProperties
Retrieve the map of values associated to the option. This is convenient for options specifying Java properties like-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"
.- Parameters:
option
- the option to be processed- Returns:
- the Properties mapped by the option, never
null
even if the option doesn't exists
-
getProperties
Retrieve the map of values associated to the option. This is convenient for options specifying Java properties like-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"
.- Parameters:
name
- the name of the option- Returns:
- the Properties mapped by the option, never
null
even if the option doesn't exists
-
addOption
Add an option. The values of the option are stored.- Parameters:
opt
- the option to be processed
-
iterator
Returns an iterator over the Option members of ParsedOptions.- Returns:
- an
Iterator
over the processedOption
members of thisParsedOptions
-
getOptions
Returns an array of the processedOption
s.- Returns:
- an array of the processed
Option
s
-
hasArgs
public boolean hasArgs()Checks if non-recognized options or arguments exists.- Returns:
- true if non-recognized options or arguments exists; false otherwise
-
getArgs
Retrieve any left-over non-recognized options and arguments.- Returns:
- remaining items passed in but not parsed as an array
-
getFirstArg
-
getArgList
Retrieve any left-over non-recognized options and arguments.- Returns:
- remaining items passed in but not parsed as a
List
-
addArg
Add left-over unrecognized option/argument.- Parameters:
arg
- the unrecognized option/argument
-