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 and Type | Method and Description |
---|---|
List |
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 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 argument, if any, of this option.
|
String |
getOptionValue(String opt,
String defaultValue)
Retrieve the 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 |
iterator()
Returns an iterator over the Option members of CommandLine.
|
public boolean hasOption(String opt)
opt
- Short name of the optionpublic boolean hasOption(char opt)
opt
- character name of the optionpublic 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 getArgList()
List
.public Iterator iterator()
Iterator
over the processed Option
members of this CommandLine
Copyright © 2002-2021 The Apache Software Foundation. All Rights Reserved.