public class CommandLine extends Object implements Serializable
Options
descriptor.
It allows querying of a boolean hasOption(String opt)
,
in addition to retrieving the getOptionValue(String opt)
for options requiring arguments.
Additionally, any left-over or unrecognized arguments, are available for further processing.
Modifier | Constructor and Description |
---|---|
protected |
CommandLine()
Creates a command line.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addArg(String arg)
Add left-over unrecognized option/argument.
|
protected void |
addOption(Option opt)
Add an option to the command line.
|
List<String> |
getArgList()
Retrieve any left-over non-recognized options and arguments
|
String[] |
getArgs()
Retrieve any left-over non-recognized options and arguments
|
Object |
getOptionObject(char opt)
Return the
Object type of this Option . |
Object |
getOptionObject(String opt)
Deprecated.
due to System.err message. Instead use getParsedOptionValue(String)
|
Properties |
getOptionProperties(String opt)
Retrieve the map of values associated to the option.
|
Option[] |
getOptions()
Returns an array of the processed
Option s. |
String |
getOptionValue(char opt)
Retrieve the first argument, if any, of this option.
|
String |
getOptionValue(char opt,
String defaultValue)
Retrieve the argument, if any, of an option.
|
String |
getOptionValue(String opt)
Retrieve the first argument, if any, of this option.
|
String |
getOptionValue(String opt,
String defaultValue)
Retrieve the first argument, if any, of an option.
|
String[] |
getOptionValues(char opt)
Retrieves the array of values, if any, of an option.
|
String[] |
getOptionValues(String opt)
Retrieves the array of values, if any, of an option.
|
Object |
getParsedOptionValue(String opt)
Return a version of this
Option converted to a particular type. |
boolean |
hasOption(char opt)
Query to see if an option has been set.
|
boolean |
hasOption(String opt)
Query to see if an option has been set.
|
Iterator<Option> |
iterator()
Returns an iterator over the Option members of CommandLine.
|
protected CommandLine()
public boolean hasOption(String opt)
opt
- Short name of the optionpublic boolean hasOption(char opt)
opt
- character name of the option@Deprecated public Object getOptionObject(String opt)
Object
type of this Option
.opt
- the name of the optionOption
public Object getParsedOptionValue(String opt) throws ParseException
Option
converted to a particular type.opt
- the name of the optionParseException
- if there are problems turning the option value into the desired typePatternOptionBuilder
public Object getOptionObject(char opt)
Object
type of this Option
.opt
- the name of the optionpublic String getOptionValue(String opt)
opt
- the name of the optionpublic String getOptionValue(char opt)
opt
- the character name of the optionpublic String[] getOptionValues(String opt)
opt
- string name of the optionpublic String[] getOptionValues(char opt)
opt
- character name of the optionpublic String getOptionValue(String opt, String defaultValue)
opt
- name of the optiondefaultValue
- is the default value to be returned if the option
is not specifieddefaultValue
.public String getOptionValue(char opt, String defaultValue)
opt
- character name of the optiondefaultValue
- is the default value to be returned if the option
is not specifieddefaultValue
.public Properties getOptionProperties(String opt)
opt
- name of the optionpublic String[] getArgs()
public List<String> getArgList()
List
.protected void addArg(String arg)
arg
- the unrecognised option/argument.protected void addOption(Option opt)
opt
- the processed optionpublic Iterator<Option> iterator()
Iterator
over the processed Option
members of this CommandLine
public Option[] getOptions()
Option
s.Option
s.Copyright © 2002–2015 The Apache Software Foundation. All rights reserved.